@mieweb/ui 0.10.0-dev.2 → 0.10.0-dev.21
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/agent/mieweb-ui.instructions.md +13 -1
- package/dist/CsvBlock-FX5YNGNE.cjs +17 -0
- package/dist/{CsvBlock-ROJCKJDP.cjs.map → CsvBlock-FX5YNGNE.cjs.map} +1 -1
- package/dist/CsvBlock-VLMG7GUO.js +8 -0
- package/dist/{CsvBlock-UWPMTLE2.js.map → CsvBlock-VLMG7GUO.js.map} +1 -1
- package/dist/HtmlPreviewBlock-5JE7L3GR.js +8 -0
- package/dist/{HtmlPreviewBlock-ME5U3XNS.js.map → HtmlPreviewBlock-5JE7L3GR.js.map} +1 -1
- package/dist/HtmlPreviewBlock-UO37JQ3K.cjs +17 -0
- package/dist/{HtmlPreviewBlock-DWFN6EUB.cjs.map → HtmlPreviewBlock-UO37JQ3K.cjs.map} +1 -1
- package/dist/Input-yN516s5_.d.cts +3 -0
- package/dist/Input-yN516s5_.d.ts +3 -0
- package/dist/MermaidBlock-3XHFBAMV.js +8 -0
- package/dist/{MermaidBlock-2B6CPD6Y.js.map → MermaidBlock-3XHFBAMV.js.map} +1 -1
- package/dist/MermaidBlock-RZ75RPZA.cjs +17 -0
- package/dist/{MermaidBlock-D2UC5M55.cjs.map → MermaidBlock-RZ75RPZA.cjs.map} +1 -1
- package/dist/SurveyBlock-MUVJ3JUI.js +8 -0
- package/dist/{SurveyBlock-4DO62RBT.js.map → SurveyBlock-MUVJ3JUI.js.map} +1 -1
- package/dist/SurveyBlock-VH47YXZC.cjs +17 -0
- package/dist/{SurveyBlock-4CD4AYMJ.cjs.map → SurveyBlock-VH47YXZC.cjs.map} +1 -1
- package/dist/ag-grid.d.cts +142 -1
- package/dist/ag-grid.d.ts +142 -1
- package/dist/{chunk-ACCAXVOG.js → chunk-2ABWFQQH.js} +133 -55
- package/dist/chunk-2ABWFQQH.js.map +1 -0
- package/dist/{chunk-Y5HFM7LO.js → chunk-2BARVD4C.js} +3 -3
- package/dist/{chunk-Y5HFM7LO.js.map → chunk-2BARVD4C.js.map} +1 -1
- package/dist/{chunk-G3JX3UAU.cjs → chunk-3KPDQG5O.cjs} +5 -5
- package/dist/{chunk-G3JX3UAU.cjs.map → chunk-3KPDQG5O.cjs.map} +1 -1
- package/dist/chunk-3YBS4WUQ.js +52 -0
- package/dist/chunk-3YBS4WUQ.js.map +1 -0
- package/dist/chunk-4HC2IBOX.js +258 -0
- package/dist/chunk-4HC2IBOX.js.map +1 -0
- package/dist/chunk-4IS3QCOQ.cjs +453 -0
- package/dist/chunk-4IS3QCOQ.cjs.map +1 -0
- package/dist/chunk-4NCDU5IG.cjs +56 -0
- package/dist/chunk-4NCDU5IG.cjs.map +1 -0
- package/dist/{chunk-E4IBHYJ7.cjs → chunk-6N6LIAUJ.cjs} +9 -9
- package/dist/{chunk-E4IBHYJ7.cjs.map → chunk-6N6LIAUJ.cjs.map} +1 -1
- package/dist/chunk-74ENCTIK.js +162 -0
- package/dist/chunk-74ENCTIK.js.map +1 -0
- package/dist/{chunk-GOALNQZ2.js → chunk-7YO7DNUV.js} +4 -83
- package/dist/chunk-7YO7DNUV.js.map +1 -0
- package/dist/{chunk-VILW53UZ.js → chunk-BIQ7GSO2.js} +3 -3
- package/dist/{chunk-VILW53UZ.js.map → chunk-BIQ7GSO2.js.map} +1 -1
- package/dist/chunk-BM35CACB.js +148 -0
- package/dist/chunk-BM35CACB.js.map +1 -0
- package/dist/{chunk-XI34EGK5.cjs → chunk-CPPUT74P.cjs} +9 -9
- package/dist/{chunk-XI34EGK5.cjs.map → chunk-CPPUT74P.cjs.map} +1 -1
- package/dist/{chunk-WNM7IZJ7.js → chunk-DSB4DKWG.js} +7 -7
- package/dist/{chunk-WNM7IZJ7.js.map → chunk-DSB4DKWG.js.map} +1 -1
- package/dist/chunk-DXEPYK3I.cjs +92 -0
- package/dist/chunk-DXEPYK3I.cjs.map +1 -0
- package/dist/{chunk-JI244Y7C.js → chunk-EK3BCET6.js} +57 -4
- package/dist/chunk-EK3BCET6.js.map +1 -0
- package/dist/{chunk-5JJ2DAE4.js → chunk-ENMXHZNE.js} +3 -3
- package/dist/{chunk-5JJ2DAE4.js.map → chunk-ENMXHZNE.js.map} +1 -1
- package/dist/{chunk-XCP454Q6.js → chunk-F4N67NAF.js} +12 -3
- package/dist/chunk-F4N67NAF.js.map +1 -0
- package/dist/{chunk-VKELAMAZ.js → chunk-FBLVPM2K.js} +3 -3
- package/dist/{chunk-VKELAMAZ.js.map → chunk-FBLVPM2K.js.map} +1 -1
- package/dist/{chunk-VU6UTJRM.js → chunk-FIKO4WR6.js} +3 -3
- package/dist/{chunk-VU6UTJRM.js.map → chunk-FIKO4WR6.js.map} +1 -1
- package/dist/{chunk-DEDN5HAG.js → chunk-FZURBQJ2.js} +3 -3
- package/dist/{chunk-DEDN5HAG.js.map → chunk-FZURBQJ2.js.map} +1 -1
- package/dist/{chunk-ENKFJJZX.js → chunk-G45FBKKV.js} +5 -5
- package/dist/{chunk-ENKFJJZX.js.map → chunk-G45FBKKV.js.map} +1 -1
- package/dist/{chunk-JHULS3EC.js → chunk-GBUVIGD5.js} +89 -3
- package/dist/chunk-GBUVIGD5.js.map +1 -0
- package/dist/chunk-GU5OS7JJ.cjs +281 -0
- package/dist/chunk-GU5OS7JJ.cjs.map +1 -0
- package/dist/{chunk-V7D3YGUV.js → chunk-GVLNXPJX.js} +4 -4
- package/dist/{chunk-V7D3YGUV.js.map → chunk-GVLNXPJX.js.map} +1 -1
- package/dist/chunk-GVM6DTR5.js +90 -0
- package/dist/chunk-GVM6DTR5.js.map +1 -0
- package/dist/{chunk-3QEVGSFG.cjs → chunk-GYXUS65N.cjs} +5 -5
- package/dist/{chunk-3QEVGSFG.cjs.map → chunk-GYXUS65N.cjs.map} +1 -1
- package/dist/{chunk-WGPLUCBD.js → chunk-H2IAMSHK.js} +3 -3
- package/dist/{chunk-WGPLUCBD.js.map → chunk-H2IAMSHK.js.map} +1 -1
- package/dist/{chunk-7ZXAQTV4.cjs → chunk-HIZWOAWY.cjs} +8 -8
- package/dist/{chunk-7ZXAQTV4.cjs.map → chunk-HIZWOAWY.cjs.map} +1 -1
- package/dist/{chunk-ELPW32ZI.cjs → chunk-HQ4CGVWX.cjs} +41 -41
- package/dist/{chunk-ELPW32ZI.cjs.map → chunk-HQ4CGVWX.cjs.map} +1 -1
- package/dist/{chunk-6EN3IQQI.cjs → chunk-I4LXSHKO.cjs} +4 -4
- package/dist/{chunk-6EN3IQQI.cjs.map → chunk-I4LXSHKO.cjs.map} +1 -1
- package/dist/{chunk-NV2CWBI2.cjs → chunk-IEY3ZJIT.cjs} +12 -3
- package/dist/chunk-IEY3ZJIT.cjs.map +1 -0
- package/dist/{chunk-2YCERQWC.js → chunk-IH55BEB3.js} +4 -4
- package/dist/{chunk-2YCERQWC.js.map → chunk-IH55BEB3.js.map} +1 -1
- package/dist/chunk-IT775BYG.js +179 -0
- package/dist/chunk-IT775BYG.js.map +1 -0
- package/dist/chunk-IYWG72DM.js +166 -0
- package/dist/chunk-IYWG72DM.js.map +1 -0
- package/dist/{chunk-IX6KFB3K.cjs → chunk-JELTRRR5.cjs} +9 -9
- package/dist/{chunk-IX6KFB3K.cjs.map → chunk-JELTRRR5.cjs.map} +1 -1
- package/dist/{chunk-FXO5ARBB.cjs → chunk-KDW6BD4O.cjs} +4 -4
- package/dist/{chunk-FXO5ARBB.cjs.map → chunk-KDW6BD4O.cjs.map} +1 -1
- package/dist/chunk-KHSFJTEX.js +1924 -0
- package/dist/chunk-KHSFJTEX.js.map +1 -0
- package/dist/{chunk-UV2FVNWT.cjs → chunk-LFPJ3OUM.cjs} +5 -5
- package/dist/{chunk-UV2FVNWT.cjs.map → chunk-LFPJ3OUM.cjs.map} +1 -1
- package/dist/{chunk-WNAA6CLE.cjs → chunk-LHBWRMNC.cjs} +94 -2
- package/dist/chunk-LHBWRMNC.cjs.map +1 -0
- package/dist/{chunk-X4XPNTCZ.cjs → chunk-LJZKEMAH.cjs} +135 -57
- package/dist/chunk-LJZKEMAH.cjs.map +1 -0
- package/dist/{chunk-2QKBTPUC.cjs → chunk-MQPG3KVK.cjs} +8 -8
- package/dist/{chunk-2QKBTPUC.cjs.map → chunk-MQPG3KVK.cjs.map} +1 -1
- package/dist/{chunk-WIAQQNFU.cjs → chunk-MYHV2ND3.cjs} +37 -3
- package/dist/chunk-MYHV2ND3.cjs.map +1 -0
- package/dist/{chunk-OE5CKRUC.js → chunk-MZNCLXXU.js} +4 -4
- package/dist/{chunk-OE5CKRUC.js.map → chunk-MZNCLXXU.js.map} +1 -1
- package/dist/{chunk-XEAT7XJG.cjs → chunk-N2CJJHHB.cjs} +4 -4
- package/dist/{chunk-XEAT7XJG.cjs.map → chunk-N2CJJHHB.cjs.map} +1 -1
- package/dist/chunk-N7C4OEP7.cjs +356 -0
- package/dist/chunk-N7C4OEP7.cjs.map +1 -0
- package/dist/chunk-OGNADPM4.cjs +170 -0
- package/dist/chunk-OGNADPM4.cjs.map +1 -0
- package/dist/{chunk-5GUOOLPR.cjs → chunk-P5CMZZRZ.cjs} +5 -5
- package/dist/{chunk-5GUOOLPR.cjs.map → chunk-P5CMZZRZ.cjs.map} +1 -1
- package/dist/{chunk-U42F3HLE.cjs → chunk-QNDP6PE5.cjs} +57 -4
- package/dist/chunk-QNDP6PE5.cjs.map +1 -0
- package/dist/{chunk-H4ZXMQQW.js → chunk-QOVJ6Z6R.js} +3 -3
- package/dist/{chunk-H4ZXMQQW.js.map → chunk-QOVJ6Z6R.js.map} +1 -1
- package/dist/{chunk-GD7EBGC4.cjs → chunk-R2O72G6Z.cjs} +19 -19
- package/dist/{chunk-GD7EBGC4.cjs.map → chunk-R2O72G6Z.cjs.map} +1 -1
- package/dist/{chunk-TMMVIUUN.js → chunk-R6KPWIGO.js} +4 -4
- package/dist/{chunk-TMMVIUUN.js.map → chunk-R6KPWIGO.js.map} +1 -1
- package/dist/{chunk-VPWJCJCX.cjs → chunk-S45EERW3.cjs} +5 -5
- package/dist/{chunk-VPWJCJCX.cjs.map → chunk-S45EERW3.cjs.map} +1 -1
- package/dist/{chunk-WNZAYBVB.cjs → chunk-SQ2D7AON.cjs} +45 -45
- package/dist/{chunk-WNZAYBVB.cjs.map → chunk-SQ2D7AON.cjs.map} +1 -1
- package/dist/{chunk-P2CA3XGI.js → chunk-SYRLCTDV.js} +3 -3
- package/dist/{chunk-P2CA3XGI.js.map → chunk-SYRLCTDV.js.map} +1 -1
- package/dist/{chunk-7ZDPD5ZX.cjs → chunk-T4L7Q5FA.cjs} +7 -7
- package/dist/{chunk-7ZDPD5ZX.cjs.map → chunk-T4L7Q5FA.cjs.map} +1 -1
- package/dist/{chunk-ZGRCSNPK.js → chunk-TF7YWJHU.js} +3 -3
- package/dist/{chunk-ZGRCSNPK.js.map → chunk-TF7YWJHU.js.map} +1 -1
- package/dist/{chunk-2IZLKPUW.js → chunk-THLIL6PY.js} +3 -3
- package/dist/{chunk-2IZLKPUW.js.map → chunk-THLIL6PY.js.map} +1 -1
- package/dist/{chunk-N6IY47YA.cjs → chunk-TTSSUOEV.cjs} +8 -8
- package/dist/{chunk-N6IY47YA.cjs.map → chunk-TTSSUOEV.cjs.map} +1 -1
- package/dist/{chunk-5MCBWTIF.cjs → chunk-TYE5K5WV.cjs} +4 -4
- package/dist/{chunk-5MCBWTIF.cjs.map → chunk-TYE5K5WV.cjs.map} +1 -1
- package/dist/{chunk-22CYDCXA.js → chunk-TZJQB4P2.js} +37 -4
- package/dist/chunk-TZJQB4P2.js.map +1 -0
- package/dist/{chunk-VOKVG3ER.js → chunk-UBSH27C2.js} +4 -4
- package/dist/{chunk-VOKVG3ER.js.map → chunk-UBSH27C2.js.map} +1 -1
- package/dist/chunk-VINZZQBD.cjs +323 -0
- package/dist/chunk-VINZZQBD.cjs.map +1 -0
- package/dist/chunk-VPTASZ2O.cjs +171 -0
- package/dist/chunk-VPTASZ2O.cjs.map +1 -0
- package/dist/{chunk-SGFYA22I.cjs → chunk-VYPPQPSZ.cjs} +7 -7
- package/dist/{chunk-SGFYA22I.cjs.map → chunk-VYPPQPSZ.cjs.map} +1 -1
- package/dist/chunk-WCDJFMZO.cjs +1967 -0
- package/dist/chunk-WCDJFMZO.cjs.map +1 -0
- package/dist/{chunk-VNYW4C4J.cjs → chunk-X6A27RGO.cjs} +4 -84
- package/dist/chunk-X6A27RGO.cjs.map +1 -0
- package/dist/chunk-XBTKZCZF.js +333 -0
- package/dist/chunk-XBTKZCZF.js.map +1 -0
- package/dist/chunk-XDIMTPZU.cjs +202 -0
- package/dist/chunk-XDIMTPZU.cjs.map +1 -0
- package/dist/chunk-XVW5DPPP.js +429 -0
- package/dist/chunk-XVW5DPPP.js.map +1 -0
- package/dist/chunk-Y4E2WRUR.cjs +188 -0
- package/dist/chunk-Y4E2WRUR.cjs.map +1 -0
- package/dist/chunk-Y4QNLW7W.js +300 -0
- package/dist/chunk-Y4QNLW7W.js.map +1 -0
- package/dist/{chunk-KZFBQ7GY.js → chunk-YU55JD35.js} +3 -3
- package/dist/{chunk-KZFBQ7GY.js.map → chunk-YU55JD35.js.map} +1 -1
- package/dist/{chunk-OD47TTAW.cjs → chunk-Z4JR23IB.cjs} +9 -9
- package/dist/{chunk-OD47TTAW.cjs.map → chunk-Z4JR23IB.cjs.map} +1 -1
- package/dist/{chunk-3M7TAXNR.js → chunk-ZTW4KODY.js} +3 -3
- package/dist/{chunk-3M7TAXNR.js.map → chunk-ZTW4KODY.js.map} +1 -1
- package/dist/{chunk-3QGS6CXD.js → chunk-ZYL4SNOR.js} +3 -3
- package/dist/{chunk-3QGS6CXD.js.map → chunk-ZYL4SNOR.js.map} +1 -1
- package/dist/components/Alert/index.d.cts +1 -1
- package/dist/components/Alert/index.d.ts +1 -1
- package/dist/components/AlertDialog/index.cjs +6 -5
- package/dist/components/AlertDialog/index.d.cts +28 -3
- package/dist/components/AlertDialog/index.d.ts +28 -3
- package/dist/components/AlertDialog/index.js +5 -4
- package/dist/components/AudioRecorder/index.d.cts +2 -2
- package/dist/components/AudioRecorder/index.d.ts +2 -2
- package/dist/components/Autocomplete/index.d.cts +8 -2
- package/dist/components/Autocomplete/index.d.ts +8 -2
- package/dist/components/Avatar/index.d.cts +1 -1
- package/dist/components/Avatar/index.d.ts +1 -1
- package/dist/components/Badge/index.d.cts +1 -1
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/BoardView/index.cjs +24 -0
- package/dist/components/BoardView/index.cjs.map +1 -0
- package/dist/components/BoardView/index.d.cts +129 -0
- package/dist/components/BoardView/index.d.ts +129 -0
- package/dist/components/BoardView/index.js +7 -0
- package/dist/components/BoardView/index.js.map +1 -0
- package/dist/components/Button/index.cjs +4 -3
- package/dist/components/Button/index.d.cts +2 -1
- package/dist/components/Button/index.d.ts +2 -1
- package/dist/components/Button/index.js +2 -1
- package/dist/components/CalendarView/index.cjs +23 -0
- package/dist/components/CalendarView/index.cjs.map +1 -0
- package/dist/components/CalendarView/index.d.cts +39 -0
- package/dist/components/CalendarView/index.d.ts +39 -0
- package/dist/components/CalendarView/index.js +10 -0
- package/dist/components/CalendarView/index.js.map +1 -0
- package/dist/components/Card/index.d.cts +3 -3
- package/dist/components/Card/index.d.ts +3 -3
- package/dist/components/Collapsible/index.cjs +5 -5
- package/dist/components/Collapsible/index.js +2 -2
- package/dist/components/CustomizableDashboard/index.cjs +10 -9
- package/dist/components/CustomizableDashboard/index.js +3 -2
- package/dist/components/Dropdown/index.cjs +9 -9
- package/dist/components/Dropdown/index.d.cts +2 -1
- package/dist/components/Dropdown/index.d.ts +2 -1
- package/dist/components/Dropdown/index.js +2 -2
- package/dist/components/FloatingWindow/index.cjs +5 -4
- package/dist/components/FloatingWindow/index.js +3 -2
- package/dist/components/GanttView/index.cjs +20 -0
- package/dist/components/GanttView/index.cjs.map +1 -0
- package/dist/components/GanttView/index.d.cts +36 -0
- package/dist/components/GanttView/index.d.ts +36 -0
- package/dist/components/GanttView/index.js +7 -0
- package/dist/components/GanttView/index.js.map +1 -0
- package/dist/components/KeyboardShortcutsOverlay/index.cjs +5 -5
- package/dist/components/KeyboardShortcutsOverlay/index.js +3 -3
- package/dist/components/ListView/index.cjs +23 -0
- package/dist/components/ListView/index.cjs.map +1 -0
- package/dist/components/ListView/index.d.cts +124 -0
- package/dist/components/ListView/index.d.ts +124 -0
- package/dist/components/ListView/index.js +10 -0
- package/dist/components/ListView/index.js.map +1 -0
- package/dist/components/Markdown/index.cjs +20 -19
- package/dist/components/Markdown/index.js +8 -7
- package/dist/components/MediaEditor/index.cjs +11 -10
- package/dist/components/MediaEditor/index.d.cts +91 -2
- package/dist/components/MediaEditor/index.d.ts +91 -2
- package/dist/components/MediaEditor/index.js +6 -5
- package/dist/components/MediaPlayer/index.cjs +6 -5
- package/dist/components/MediaPlayer/index.d.cts +1 -1
- package/dist/components/MediaPlayer/index.d.ts +1 -1
- package/dist/components/MediaPlayer/index.js +3 -2
- package/dist/components/MegaMenu/index.cjs +6 -5
- package/dist/components/MegaMenu/index.js +3 -2
- package/dist/components/Modal/index.cjs +10 -10
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/Pagination/index.d.cts +1 -1
- package/dist/components/Pagination/index.d.ts +1 -1
- package/dist/components/PhoneInput/index.d.cts +36 -3
- package/dist/components/PhoneInput/index.d.ts +36 -3
- package/dist/components/Progress/index.d.cts +1 -1
- package/dist/components/Progress/index.d.ts +1 -1
- package/dist/components/Q/index.d.cts +2 -2
- package/dist/components/Q/index.d.ts +2 -2
- package/dist/components/QuickAction/index.d.cts +1 -1
- package/dist/components/QuickAction/index.d.ts +1 -1
- package/dist/components/RadialExplorer/index.cjs +4 -3
- package/dist/components/RadialExplorer/index.js +3 -2
- package/dist/components/RecordButton/index.d.cts +1 -1
- package/dist/components/RecordButton/index.d.ts +1 -1
- package/dist/components/RichTextEditor/index.cjs +8 -7
- package/dist/components/RichTextEditor/index.d.cts +7 -2
- package/dist/components/RichTextEditor/index.d.ts +7 -2
- package/dist/components/RichTextEditor/index.js +5 -4
- package/dist/components/ScrollArea/index.d.cts +1 -1
- package/dist/components/ScrollArea/index.d.ts +1 -1
- package/dist/components/SectionSpyNav/index.cjs +4 -3
- package/dist/components/SectionSpyNav/index.js +3 -2
- package/dist/components/Select/index.d.cts +1 -2
- package/dist/components/Select/index.d.ts +1 -2
- package/dist/components/Skeleton/index.d.cts +1 -1
- package/dist/components/Skeleton/index.d.ts +1 -1
- package/dist/components/Slider/index.d.cts +2 -2
- package/dist/components/Slider/index.d.ts +2 -2
- package/dist/components/Spinner/index.d.cts +2 -2
- package/dist/components/Spinner/index.d.ts +2 -2
- package/dist/components/SuperChat/index.cjs +478 -281
- package/dist/components/SuperChat/index.cjs.map +1 -1
- package/dist/components/SuperChat/index.d.cts +2 -4
- package/dist/components/SuperChat/index.d.ts +2 -4
- package/dist/components/SuperChat/index.js +468 -271
- package/dist/components/SuperChat/index.js.map +1 -1
- package/dist/components/SuperChat/plugins/index.cjs +5 -5
- package/dist/components/SuperChat/plugins/index.d.cts +2 -3
- package/dist/components/SuperChat/plugins/index.d.ts +2 -3
- package/dist/components/SuperChat/plugins/index.js +4 -4
- package/dist/components/Text/index.d.cts +3 -3
- package/dist/components/Text/index.d.ts +3 -3
- package/dist/components/Textarea/index.d.cts +1 -2
- package/dist/components/Textarea/index.d.ts +1 -2
- package/dist/components/ThemeProvider/index.d.cts +3 -1
- package/dist/components/ThemeProvider/index.d.ts +3 -1
- package/dist/components/TranscriptView/index.d.cts +85 -4
- package/dist/components/TranscriptView/index.d.ts +85 -4
- package/dist/components/ViewSet/index.cjs +24 -0
- package/dist/components/ViewSet/index.cjs.map +1 -0
- package/dist/components/ViewSet/index.d.cts +300 -0
- package/dist/components/ViewSet/index.d.ts +300 -0
- package/dist/components/ViewSet/index.js +15 -0
- package/dist/components/ViewSet/index.js.map +1 -0
- package/dist/components/ViewSwitcher/index.cjs +20 -0
- package/dist/components/ViewSwitcher/index.cjs.map +1 -0
- package/dist/components/ViewSwitcher/index.d.cts +57 -0
- package/dist/components/ViewSwitcher/index.d.ts +57 -0
- package/dist/components/ViewSwitcher/index.js +7 -0
- package/dist/components/ViewSwitcher/index.js.map +1 -0
- package/dist/datavis.cjs +3 -2
- package/dist/datavis.cjs.map +1 -1
- package/dist/datavis.d.cts +167 -13
- package/dist/datavis.d.ts +167 -13
- package/dist/datavis.js +2 -1
- package/dist/datavis.js.map +1 -1
- package/dist/esheet.cjs +9 -8
- package/dist/esheet.cjs.map +1 -1
- package/dist/esheet.d.cts +183 -1
- package/dist/esheet.d.ts +183 -1
- package/dist/esheet.js +6 -5
- package/dist/esheet.js.map +1 -1
- package/dist/hooks/index.cjs +49 -16
- package/dist/hooks/index.d.cts +590 -31
- package/dist/hooks/index.d.ts +590 -31
- package/dist/hooks/index.js +3 -2
- package/dist/index.cjs +1375 -1088
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8596 -683
- package/dist/index.d.ts +8596 -683
- package/dist/index.js +433 -340
- package/dist/index.js.map +1 -1
- package/dist/kerebron.cjs +58 -19
- package/dist/kerebron.cjs.map +1 -1
- package/dist/kerebron.css +115 -0
- package/dist/kerebron.d.cts +37 -0
- package/dist/kerebron.d.ts +37 -0
- package/dist/kerebron.js +58 -19
- package/dist/kerebron.js.map +1 -1
- package/dist/motion.cjs +7 -7
- package/dist/motion.d.cts +186 -2
- package/dist/motion.d.ts +186 -2
- package/dist/motion.js +2 -2
- package/dist/q.d.cts +25 -3
- package/dist/q.d.ts +25 -3
- package/dist/{speaker-verify-5GTWAN5Y.cjs → speaker-verify-4NEJAK6C.cjs} +57 -90
- package/dist/speaker-verify-4NEJAK6C.cjs.map +1 -0
- package/dist/{speaker-verify-R67P433H.js → speaker-verify-AWSKI6DI.js} +57 -90
- package/dist/speaker-verify-AWSKI6DI.js.map +1 -0
- package/dist/styles/effects.css +33 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind-preset.cjs +4 -4
- package/dist/tailwind-preset.js +1 -1
- package/dist/templates.cjs +103 -0
- package/dist/templates.cjs.map +1 -0
- package/dist/templates.d.cts +560 -0
- package/dist/templates.d.ts +560 -0
- package/dist/templates.js +10 -0
- package/dist/templates.js.map +1 -0
- package/dist/types-C3HQe74F.d.cts +86 -0
- package/dist/types-C3HQe74F.d.ts +86 -0
- package/dist/{types-B97JNRNQ.d.cts → types-DOxdTwmq.d.cts} +170 -2
- package/dist/{types-gZXrfLj6.d.ts → types-DOxdTwmq.d.ts} +170 -2
- package/dist/utils/index.d.cts +13 -2
- package/dist/utils/index.d.ts +13 -2
- package/package.json +29 -12
- package/dist/Animated-XmH6k8pZ.d.cts +0 -188
- package/dist/Animated-XmH6k8pZ.d.ts +0 -188
- package/dist/CsvBlock-ROJCKJDP.cjs +0 -16
- package/dist/CsvBlock-UWPMTLE2.js +0 -7
- package/dist/HtmlPreviewBlock-DWFN6EUB.cjs +0 -16
- package/dist/HtmlPreviewBlock-ME5U3XNS.js +0 -7
- package/dist/MedicationEditor-Bp4NLy7y.d.cts +0 -352
- package/dist/MedicationEditor-Bp4NLy7y.d.ts +0 -352
- package/dist/MermaidBlock-2B6CPD6Y.js +0 -7
- package/dist/MermaidBlock-D2UC5M55.cjs +0 -16
- package/dist/SurveyBlock-4CD4AYMJ.cjs +0 -16
- package/dist/SurveyBlock-4DO62RBT.js +0 -7
- package/dist/chunk-22CYDCXA.js.map +0 -1
- package/dist/chunk-ACCAXVOG.js.map +0 -1
- package/dist/chunk-GOALNQZ2.js.map +0 -1
- package/dist/chunk-JHULS3EC.js.map +0 -1
- package/dist/chunk-JI244Y7C.js.map +0 -1
- package/dist/chunk-NV2CWBI2.cjs.map +0 -1
- package/dist/chunk-U42F3HLE.cjs.map +0 -1
- package/dist/chunk-VNYW4C4J.cjs.map +0 -1
- package/dist/chunk-WIAQQNFU.cjs.map +0 -1
- package/dist/chunk-WNAA6CLE.cjs.map +0 -1
- package/dist/chunk-X4XPNTCZ.cjs.map +0 -1
- package/dist/chunk-XCP454Q6.js.map +0 -1
- package/dist/html-MdxqSzjD.d.cts +0 -13
- package/dist/html-MdxqSzjD.d.ts +0 -13
- package/dist/orderRows-BUJYgSc7.d.cts +0 -221
- package/dist/orderRows-BUJYgSc7.d.ts +0 -221
- package/dist/speaker-verify-5GTWAN5Y.cjs.map +0 -1
- package/dist/speaker-verify-R67P433H.js.map +0 -1
- package/dist/transcript-Cg7uSW-C.d.cts +0 -84
- package/dist/transcript-Cg7uSW-C.d.ts +0 -84
- package/dist/types-CnPEwzlp.d.cts +0 -254
- package/dist/types-CnPEwzlp.d.ts +0 -254
- package/dist/useAnchoredPosition-CKwLSQW8.d.cts +0 -76
- package/dist/useAnchoredPosition-CKwLSQW8.d.ts +0 -76
- package/dist/useTheme-B9SWu6ui.d.cts +0 -24
- package/dist/useTheme-B9SWu6ui.d.ts +0 -24
- package/dist/useTranscriptEdits-CGzlemHT.d.cts +0 -182
- package/dist/useTranscriptEdits-D32bLs0l.d.ts +0 -182
package/dist/kerebron.js
CHANGED
|
@@ -4,37 +4,65 @@ import { forwardRef, useRef, useState, useEffect, useImperativeHandle } from 're
|
|
|
4
4
|
import { CoreEditor } from '@kerebron/editor';
|
|
5
5
|
import { createAssetLoad } from '@kerebron/wasm/web';
|
|
6
6
|
import { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';
|
|
7
|
+
import { ExtensionMediaUpload } from '@kerebron/extension-basic-editor/ExtensionMediaUpload';
|
|
7
8
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
9
|
import { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';
|
|
9
10
|
|
|
10
11
|
var unsafeExtensions = ["autocomplete", "hover"];
|
|
11
12
|
var SafeAdvancedEditorKit = class {
|
|
12
|
-
constructor(forCollab) {
|
|
13
|
+
constructor(forCollab, mediaUpload) {
|
|
13
14
|
this.forCollab = forCollab;
|
|
15
|
+
this.mediaUpload = mediaUpload;
|
|
14
16
|
}
|
|
15
17
|
forCollab;
|
|
18
|
+
mediaUpload;
|
|
16
19
|
name = "advanced-editor";
|
|
17
20
|
getExtensions() {
|
|
18
21
|
const dropped = [...unsafeExtensions];
|
|
19
22
|
if (this.forCollab) dropped.push("history");
|
|
20
|
-
|
|
23
|
+
if (this.mediaUpload) dropped.push("mediaUpload");
|
|
24
|
+
const extensions = new AdvancedEditorKit().getExtensions().filter(
|
|
21
25
|
(extension) => !("name" in extension && dropped.includes(extension.name))
|
|
22
26
|
);
|
|
27
|
+
if (this.mediaUpload) {
|
|
28
|
+
extensions.push(new ExtensionMediaUpload(this.mediaUpload));
|
|
29
|
+
}
|
|
30
|
+
return extensions;
|
|
23
31
|
}
|
|
24
32
|
};
|
|
25
|
-
async function createEditorKits(config) {
|
|
26
|
-
if (!config)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
async function createEditorKits(config, mediaUpload) {
|
|
34
|
+
if (!config) {
|
|
35
|
+
return {
|
|
36
|
+
kits: [new SafeAdvancedEditorKit(false, mediaUpload)],
|
|
37
|
+
collaborative: false
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit-SJPDPXU4.js');
|
|
42
|
+
const url = config.wsUrl ?? defaultWsUrl();
|
|
43
|
+
return {
|
|
44
|
+
kits: [
|
|
45
|
+
new SafeAdvancedEditorKit(true, mediaUpload),
|
|
46
|
+
new HuddleYjsKit(
|
|
47
|
+
url,
|
|
48
|
+
config.params ?? {},
|
|
49
|
+
config.WebSocketPolyfill,
|
|
50
|
+
config.user
|
|
51
|
+
)
|
|
52
|
+
],
|
|
53
|
+
collaborative: true
|
|
54
|
+
};
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.warn(
|
|
57
|
+
"[RichEditor] Collaborative editing unavailable \u2014 the Yjs kit failed to load. Continuing as a local editor.",
|
|
58
|
+
error
|
|
59
|
+
);
|
|
60
|
+
config.onUnavailable?.(error);
|
|
61
|
+
return {
|
|
62
|
+
kits: [new SafeAdvancedEditorKit(false, mediaUpload)],
|
|
63
|
+
collaborative: false
|
|
64
|
+
};
|
|
65
|
+
}
|
|
38
66
|
}
|
|
39
67
|
var MARKDOWN_TYPE = "text/x-markdown";
|
|
40
68
|
var initialLoadQueue = Promise.resolve();
|
|
@@ -54,7 +82,8 @@ var RichEditor = forwardRef(
|
|
|
54
82
|
className,
|
|
55
83
|
"aria-label": ariaLabel,
|
|
56
84
|
"aria-labelledby": ariaLabelledBy,
|
|
57
|
-
assetLoad
|
|
85
|
+
assetLoad,
|
|
86
|
+
mediaUpload
|
|
58
87
|
}, ref) {
|
|
59
88
|
const isDark = useIsDarkMode();
|
|
60
89
|
const hostRef = useRef(null);
|
|
@@ -66,6 +95,9 @@ var RichEditor = forwardRef(
|
|
|
66
95
|
const loadingRef = useRef(false);
|
|
67
96
|
const disabledRef = useRef(disabled);
|
|
68
97
|
const [md, setMd] = useState("");
|
|
98
|
+
const lastSerializedDoc = useRef(null);
|
|
99
|
+
const showPreviewRef = useRef(showPreview);
|
|
100
|
+
showPreviewRef.current = showPreview;
|
|
69
101
|
useEffect(() => {
|
|
70
102
|
disabledRef.current = disabled;
|
|
71
103
|
editorInstance.current?.view.setProps({
|
|
@@ -91,19 +123,26 @@ var RichEditor = forwardRef(
|
|
|
91
123
|
host.appendChild(mount);
|
|
92
124
|
const onTransaction = async () => {
|
|
93
125
|
if (loadingRef.current || !editorInstance.current) return;
|
|
126
|
+
const { doc } = editorInstance.current.view.state;
|
|
127
|
+
if (doc === lastSerializedDoc.current) return;
|
|
128
|
+
lastSerializedDoc.current = doc;
|
|
94
129
|
try {
|
|
95
130
|
const buffer = await editorInstance.current.saveDocument(MARKDOWN_TYPE);
|
|
96
131
|
const markdown = new globalThis.TextDecoder().decode(buffer);
|
|
97
132
|
if (disposed) return;
|
|
98
133
|
valueRef.current = markdown;
|
|
99
|
-
setMd(markdown);
|
|
134
|
+
if (showPreviewRef.current) setMd(markdown);
|
|
100
135
|
onChangeRef.current?.(markdown);
|
|
101
136
|
} catch (err) {
|
|
137
|
+
lastSerializedDoc.current = null;
|
|
102
138
|
console.error("Failed to save markdown:", err);
|
|
103
139
|
}
|
|
104
140
|
};
|
|
105
141
|
const setup = async () => {
|
|
106
|
-
const editorKits = await createEditorKits(
|
|
142
|
+
const { kits: editorKits, collaborative } = await createEditorKits(
|
|
143
|
+
collab,
|
|
144
|
+
mediaUpload
|
|
145
|
+
);
|
|
107
146
|
if (disposed) return;
|
|
108
147
|
editor = CoreEditor.create({
|
|
109
148
|
element: mount,
|
|
@@ -125,7 +164,7 @@ var RichEditor = forwardRef(
|
|
|
125
164
|
});
|
|
126
165
|
editor.addEventListener("transaction", onTransaction);
|
|
127
166
|
const joinRoom = () => {
|
|
128
|
-
if (collab && editor && !disposed) {
|
|
167
|
+
if (collaborative && collab && editor && !disposed) {
|
|
129
168
|
editor.run.changeRoom?.(collab.room);
|
|
130
169
|
reseedWhenRoomStaysEmpty();
|
|
131
170
|
}
|
package/dist/kerebron.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/RichEditor/editorKits.ts","../src/components/RichEditor/RichEditor.tsx","../src/components/RichEditor/CodeEditor.tsx"],"names":["RichEditor","useRef","useEffect","CoreEditor","createAssetLoad","jsx"],"mappings":";;;;;;;;;AA4DA,IAAM,gBAAA,GAAmB,CAAC,cAAA,EAAgB,OAAO,CAAA;AAIjD,IAAM,wBAAN,MAAiD;AAAA,EAE/C,YAA6B,SAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,SAAA,GAAA,SAAA;AAAA,EAAqB;AAAA,EAArB,SAAA;AAAA,EAD7B,IAAA,GAAO,iBAAA;AAAA,EAGP,aAAA,GAAgB;AACd,IAAA,MAAM,OAAA,GAAoB,CAAC,GAAG,gBAAgB,CAAA;AAC9C,IAAA,IAAI,IAAA,CAAK,SAAA,EAAW,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,aAAa,CAAA;AAGpD,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,MAAA,CACG,gBAAA,CAAiB,YAAA,EAAc,KAAK,CAAA,CACpC,KAAA,CAAM,CAAC,GAAA,KAAQ,OAAA,CAAQ,KAAA,CAAM,sBAAA,EAAwB,GAAG,CAAC,CAAA;AAAA,IAC9D;AAGA,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,eAAe,aAAa,CAAA;AACvD,MAAA,MAAA,CAAO,OAAA,EAAQ;AAAA,IACjB,CAAA;AAAA,EAGF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACEC,GAAAA,CAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,IAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,GAAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,SAAA,EAAW,SAAA,EAAU,cAAA,EAAe,GAChD,CAAA,EACF,CAAA;AAEJ;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA","file":"kerebron.js","sourcesContent":["/**\n * Editor kit assembly for {@link RichEditor}, for both plain and collaborative\n * (Yjs) mode.\n *\n * Both modes start from {@link AdvancedEditorKit} and drop the extensions that\n * are unsafe for our usage — see {@link unsafeExtensions} — then collaborative\n * mode adds the Yjs pieces on top.\n *\n * The Yjs pieces live in `collabKit.ts` behind a dynamic `import()`, so\n * `@kerebron/extension-yjs`, `yjs` and `y-protocols` remain truly optional\n * peers — plain-mode consumers never load them.\n */\nimport type { EditorKit } from '@kerebron/editor';\nimport { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';\n\nexport interface CollabConfig {\n /** Room id — one shared document per room (e.g. a post id). */\n room: string;\n /**\n * WebSocket base URL for the Yjs relay. Defaults to\n * `<ws|wss>://<location.host>/yjs`. The room id is appended by the provider.\n */\n wsUrl?: string;\n /** Extra query params for the socket (e.g. `{ token }` for auth). */\n params?: Record<string, string>;\n /**\n * Who this editor is, published on awareness (`kerebron:user`) so peers see\n * a named, coloured cursor. Without it remote cursors do not render — the\n * position plugin skips awareness states that carry no user — and the\n * `id` is what the cursor colour is derived from (kerebron's `User` shape).\n */\n user?: { id: string; name: string; color?: string };\n /**\n * Custom WebSocket implementation handed to the Yjs provider — e.g. a\n * loopback socket for demos/tests, or a polyfill outside the browser.\n * Defaults to `globalThis.WebSocket`.\n */\n WebSocketPolyfill?: typeof globalThis.WebSocket;\n}\n\n/**\n * Extensions dropped from {@link AdvancedEditorKit}, and why.\n *\n * `autocomplete` and `hover` debounce their DOM handlers (200ms) and then call\n * `dispatchMeta`, which reads `this.editor.state` with no guard that the editor\n * is still alive. Any teardown or document swap inside that debounce window\n * lands the deferred call on a dead view and throws\n * `null.matchesNode()` inside ProseMirror's `EditorView.updateStateInner`,\n * leaving the view permanently broken. Two ways to hit it:\n * - remount (e.g. a `key` change) while the pointer is over the editor, which\n * fires the debounced `onMouseLeave` after the view is destroyed;\n * - a Yjs remote update replacing the document tree under a pending callback.\n * The first applies to *every* editor, so both extensions come out in both\n * modes. No functional cost — autocomplete popups and node-hover tooltips are\n * compositor conveniences, not required for editing.\n *\n * `history` is collab-only: ExtensionYjs supplies its own CRDT-aware undo/redo\n * and the editor throws `Extension conflict: yjs vs history` if both are\n * present. Plain mode keeps it, so undo/redo still works there.\n */\nconst unsafeExtensions = ['autocomplete', 'hover'] as const;\n\n/** {@link AdvancedEditorKit} minus {@link unsafeExtensions} (and, for collab\n * mode, minus `history`). */\nclass SafeAdvancedEditorKit implements EditorKit {\n name = 'advanced-editor';\n constructor(private readonly forCollab: boolean) {}\n\n getExtensions() {\n const dropped: string[] = [...unsafeExtensions];\n if (this.forCollab) dropped.push('history');\n\n return new AdvancedEditorKit()\n .getExtensions()\n .filter(\n (extension) =>\n !('name' in extension && dropped.includes(extension.name))\n );\n }\n}\n\n/** MarkYChange + ExtensionYjs live in `collabKit.ts` (lazy-loaded). */\n\n/**\n * Build the editor kits for a session. Pass `config` to join a collaborative\n * room; omit it for a plain local editor.\n *\n * Async because collaborative mode lazy-loads the Yjs kit (and its optional\n * peer deps) on first use; plain mode resolves immediately.\n */\nexport async function createEditorKits(\n config?: CollabConfig\n): Promise<EditorKit[]> {\n if (!config) return [new SafeAdvancedEditorKit(false)];\n\n const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit');\n const url = config.wsUrl ?? defaultWsUrl();\n return [\n new SafeAdvancedEditorKit(true),\n new HuddleYjsKit(\n url,\n config.params ?? {},\n config.WebSocketPolyfill,\n config.user\n ),\n ];\n}\n","'use client';\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\n\nimport { CoreEditor, type AssetLoad } from '@kerebron/editor';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nimport { useIsDarkMode } from '../../hooks/useIsDarkMode';\nimport { createEditorKits, type CollabConfig } from './editorKits';\n\nexport type { CollabConfig } from './editorKits';\n\nconst MARKDOWN_TYPE = 'text/x-markdown';\n\n/**\n * The markdown converter's tree-sitter WASM init is not concurrency-safe, so\n * every editor's *first* load queues behind the previous one. Later loads (a\n * `value` change) are free — by then the grammars are warm.\n */\nlet initialLoadQueue: Promise<unknown> = Promise.resolve();\n\nfunction queueInitialLoad(load: () => Promise<void>): Promise<void> {\n const queued = initialLoadQueue.catch(() => undefined).then(load);\n initialLoadQueue = queued.catch(() => undefined);\n return queued;\n}\n\nexport interface RichEditorProps {\n /** Markdown to load. Changing it reloads the editor unless `collab` is set. */\n value?: string;\n /** Called with the editor's markdown content whenever it changes. */\n onChange?: (value: string) => void;\n /** Whether to render the live markdown output preview. Defaults to `false`. */\n showPreview?: boolean;\n /**\n * Enable live collaborative editing (Yjs) for the given room. When set, the\n * editor connects to the `/yjs` websocket relay and every peer in the same\n * `room` co-edits one shared document. Uncontrolled like `value` — remount via\n * `key` to switch rooms.\n */\n collab?: CollabConfig;\n /** Read-only surface: no typing, and the content dims. */\n disabled?: boolean;\n /**\n * Id for the editor host element — an `aria-labelledby`/`aria-describedby`\n * anchor. The host is a `div`, not a labelable control, so a\n * `<label htmlFor>` will not associate; name the editor with `aria-label`\n * or `aria-labelledby` instead.\n */\n id?: string;\n /** Extra classes on the editor surface, beside `kb-component`. */\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /**\n * Where the tree-sitter WASM grammars load from. Defaults to\n * `createAssetLoad('/kerebron-wasm')`; supply your own when the host serves\n * `@kerebron/wasm`'s `assets/` somewhere else.\n */\n assetLoad?: AssetLoad;\n}\n\nexport interface RichEditorHandle {\n /**\n * The editor's markdown, awaiting the initial load. `onChange` can lag the\n * last keystroke, so read this on submit rather than trusting mirrored state.\n */\n getContent: () => Promise<string>;\n /** Focus the editor, restoring the caret where the writer left it. */\n focus: () => void;\n}\n\n/**\n * Markdown editor over Kerebron's `CoreEditor`.\n *\n * The editor mounts into a **disposable child div**: `CoreEditor.destroy()`\n * replaces its host element with a clone, which would strand React's ref (and,\n * under StrictMode's double-mount, leave the live editor detached behind a\n * dead clone).\n */\nconst RichEditor = forwardRef<RichEditorHandle, RichEditorProps>(\n function RichEditor(\n {\n value = '',\n onChange,\n showPreview = false,\n collab,\n disabled = false,\n id,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n assetLoad,\n },\n ref\n ) {\n const isDark = useIsDarkMode();\n const hostRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n // Mirrors what the editor last held, so an echo of our own `onChange`\n // doesn't reload the document out from under the caret.\n const valueRef = useRef(value);\n const readyRef = useRef<Promise<void> | null>(null);\n const loadingRef = useRef(false);\n const disabledRef = useRef(disabled);\n\n const [md, setMd] = useState<string>('');\n\n useEffect(() => {\n disabledRef.current = disabled;\n editorInstance.current?.view.setProps({\n editable: () => !disabledRef.current,\n });\n }, [disabled]);\n\n useEffect(() => {\n // In collab mode the CRDT owns the content; reloading would fight it.\n if (collab || value === valueRef.current) return;\n valueRef.current = value;\n const editor = editorInstance.current;\n if (!editor) return;\n\n loadingRef.current = true;\n void editor\n .loadDocumentText(MARKDOWN_TYPE, value)\n .catch(() => undefined)\n .finally(() => {\n if (editorInstance.current === editor) loadingRef.current = false;\n });\n // `collab` is fixed for the lifetime of the instance.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value]);\n\n useEffect(() => {\n if (!hostRef.current) return;\n const host = hostRef.current;\n\n // Set on cleanup so async continuations (kit loading and the\n // `loadDocumentText` chain) don't touch the editor after `destroy()`.\n let disposed = false;\n let editor: CoreEditor | null = null;\n\n const mount = document.createElement('div');\n host.appendChild(mount);\n\n // Listen to transactions and update markdown preview\n const onTransaction = async () => {\n // Programmatic loads are not edits — reporting them would echo the\n // caller's own `value` back through `onChange`.\n if (loadingRef.current || !editorInstance.current) return;\n\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n if (disposed) return;\n valueRef.current = markdown;\n setMd(markdown);\n onChangeRef.current?.(markdown);\n } catch (err) {\n console.error('Failed to save markdown:', err);\n }\n };\n\n // Initialize the editor. Both modes drop the teardown-unsafe extensions;\n // collaborative mode additionally swaps `history` for the Yjs CRDT sync\n // and lazy-loads the Yjs kit (see `editorKits.ts` for why).\n const setup = async () => {\n const editorKits = await createEditorKits(collab);\n if (disposed) return;\n\n editor = CoreEditor.create({\n element: mount,\n uri: 'file:///untitled.md',\n assetLoad: assetLoad ?? createAssetLoad('/kerebron-wasm'),\n editorKits,\n readOnly: disabledRef.current,\n });\n\n editorInstance.current = editor;\n // The contenteditable surface has no implicit ARIA role, so labeling\n // attributes are only permitted alongside an explicit textbox role.\n const surfaceAttributes =\n ariaLabel || ariaLabelledBy\n ? {\n role: 'textbox',\n 'aria-multiline': 'true',\n ...(ariaLabel ? { 'aria-label': ariaLabel } : {}),\n ...(ariaLabelledBy\n ? { 'aria-labelledby': ariaLabelledBy }\n : {}),\n }\n : null;\n editor.view.setProps({\n editable: () => !disabledRef.current,\n ...(surfaceAttributes ? { attributes: surfaceAttributes } : {}),\n });\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content, then populate the preview once on mount.\n //\n // In collaborative mode we still load the local markdown first, then\n // join the room: the Yjs binding seeds an *empty* shared document from\n // this content on the first join, and overwrites the editor with the\n // shared content when the room already has edits — so the stored\n // markdown is the starting point without ever double-inserting.\n const joinRoom = () => {\n if (collab && editor && !disposed) {\n (\n editor.run as Record<string, (...args: unknown[]) => boolean>\n ).changeRoom?.(collab.room);\n reseedWhenRoomStaysEmpty();\n }\n };\n\n // The Yjs binding is supposed to seed an empty room from the local\n // content, but the sync import can land as an overwrite that blanks\n // the just-loaded seed (observed with extension-yjs 0.8.x). Heal it:\n // once the join settles, an empty document with a non-empty seed\n // means nobody's content won — reload the seed, which the binding\n // then pushes into the room. Joiners pass no value, so exactly one\n // participant ever does this.\n const seed = valueRef.current;\n const reseedWhenRoomStaysEmpty = () => {\n if (!seed) return;\n const check = async (attempt: number) => {\n if (disposed || !editorInstance.current) return;\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const current = new globalThis.TextDecoder()\n .decode(buffer)\n .trim();\n if (disposed || !editorInstance.current) return;\n if (current) return; // somebody's content arrived — done\n if (attempt >= 2) {\n await editorInstance.current.loadDocumentText(\n MARKDOWN_TYPE,\n seed\n );\n return;\n }\n setTimeout(() => void check(attempt + 1), 300);\n } catch {\n // A failed probe must not break the editor; the room stays as-is.\n }\n };\n setTimeout(() => void check(0), 300);\n };\n\n if (valueRef.current) {\n await queueInitialLoad(() =>\n editor!.loadDocumentText(MARKDOWN_TYPE, valueRef.current)\n );\n await onTransaction();\n joinRoom();\n } else {\n void onTransaction();\n joinRoom();\n }\n };\n\n readyRef.current = setup().catch((err) =>\n console.error('Failed to set up editor:', err)\n );\n\n // Cleanup on unmount\n return () => {\n disposed = true;\n editorInstance.current = null; // makes onTransaction's guard effective\n editor?.removeEventListener('transaction', onTransaction);\n editor?.destroy();\n readyRef.current = null;\n host.replaceChildren();\n };\n // Initial `value`/`collab` are intentionally only applied on mount\n // (uncontrolled). Remount via `key` to switch rooms.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n getContent: async (): Promise<string> => {\n await readyRef.current;\n const editor = editorInstance.current;\n if (!editor) return valueRef.current;\n const buffer = await editor.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n valueRef.current = markdown;\n return markdown;\n },\n focus: (): void => {\n const apply = (): void => {\n const view = editorInstance.current?.view as\n | { focus?: () => void }\n | undefined;\n if (view?.focus) {\n view.focus();\n return;\n }\n hostRef.current\n ?.querySelector<HTMLElement>('[contenteditable=\"true\"], textarea')\n ?.focus();\n };\n // Callers focus on mount; the editor may still be loading its kits.\n if (editorInstance.current) apply();\n else void readyRef.current?.then(apply);\n },\n }),\n []\n );\n\n return (\n <div>\n <div>\n <div\n ref={hostRef}\n id={id}\n className={[\n 'kb-component',\n isDark ? 'kb-component--dark' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-disabled={disabled || undefined}\n style={{\n isolation: 'isolate',\n opacity: disabled ? 0.65 : undefined,\n pointerEvents: disabled ? 'none' : undefined,\n }}\n />\n </div>\n\n {showPreview && (\n <div>\n <div>\n <h5>Markdown Output</h5>\n <pre>{md}</pre>\n </div>\n </div>\n )}\n </div>\n );\n }\n);\n\nRichEditor.displayName = 'RichEditor';\n\nexport { RichEditor };\n","import React, { useEffect, useRef } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface CodeEditorProps {\n /** Initial source code to load into the editor. */\n value?: string;\n /** Called with the editor's contents whenever they change. */\n onChange?: (value: string) => void;\n /** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */\n lang?: string;\n}\n\nconst CodeEditor: React.FC<CodeEditorProps> = ({\n value = '',\n onChange,\n lang = 'typescript',\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => {\n const root = editorRef.current;\n if (!root) return;\n\n const applySelectLabel = () => {\n root.querySelectorAll('select.codejar-select').forEach((element) => {\n if (!element.getAttribute('aria-label')) {\n element.setAttribute('aria-label', 'Code editor language');\n }\n });\n };\n\n applySelectLabel();\n const observer = new MutationObserver(() => applySelectLabel());\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.ts',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new CodeEditorKit(lang)],\n });\n\n editorInstance.current = editor;\n\n // Surface edits to callers.\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer = await editorInstance.current.saveDocument('text/plain');\n onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));\n } catch (err) {\n console.error('Failed to read code:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content on mount.\n if (value) {\n editor\n .loadDocumentText('text/plain', value)\n .catch((err) => console.error('Failed to load code:', err));\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value`/`lang` are intentionally only applied on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n </div>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n\nexport { CodeEditor };\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/RichEditor/editorKits.ts","../src/components/RichEditor/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I,CAAC;AAAA,KACrC,CAAA;AAED,IAAA,cAAA,CAAe,OAAA,GAAU,MAAA;AAGzB,IAAA,MAAM,gBAAgB,YAAY;AAChC,MAAA,IAAI,CAAC,eAAe,OAAA,EAAS;AAE7B,MAAA,IAAI;AACF,QAAA,MAAM,MAAA,GAAS,MAAM,cAAA,CAAe,OAAA,CAAQ,aAAa,YAAY,CAAA;AACrE,QAAA,WAAA,CAAY,UAAU,IAAI,UAAA,CAAW,aAAY,CAAE,MAAA,CAAO,MAAM,CAAC,CAAA;AAAA,MACnE,SAAS,GAAA,EAAK;AACZ,QAAA,OAAA,CAAQ,KAAA,CAAM,wBAAwB,GAAG,CAAA;AAAA,MAC3C;AAAA,IACF,CAAA;AAEA,IAAA,MAAA,CAAO,gBAAA,CAAiB,eAAe,aAAa,CAAA;AAGpD,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,MAAA,CACG,gBAAA,CAAiB,YAAA,EAAc,KAAK,CAAA,CACpC,KAAA,CAAM,CAAC,GAAA,KAAQ,OAAA,CAAQ,KAAA,CAAM,sBAAA,EAAwB,GAAG,CAAC,CAAA;AAAA,IAC9D;AAGA,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,eAAe,aAAa,CAAA;AACvD,MAAA,MAAA,CAAO,OAAA,EAAQ;AAAA,IACjB,CAAA;AAAA,EAGF,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,uBACEC,GAAAA,CAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,IAAC,KAAA,EAAA,EACC,QAAA,kBAAAA,GAAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,SAAA,EAAW,SAAA,EAAU,cAAA,EAAe,GAChD,CAAA,EACF,CAAA;AAEJ;AAEA,UAAA,CAAW,WAAA,GAAc,YAAA","file":"kerebron.js","sourcesContent":["/**\n * Editor kit assembly for {@link RichEditor}, for both plain and collaborative\n * (Yjs) mode.\n *\n * Both modes start from {@link AdvancedEditorKit} and drop the extensions that\n * are unsafe for our usage — see {@link unsafeExtensions} — then collaborative\n * mode adds the Yjs pieces on top.\n *\n * The Yjs pieces live in `collabKit.ts` behind a dynamic `import()`, so\n * `@kerebron/extension-yjs`, `yjs` and `y-protocols` remain truly optional\n * peers — plain-mode consumers never load them.\n */\nimport type { EditorKit } from '@kerebron/editor';\nimport { AdvancedEditorKit } from '@kerebron/editor-kits/AdvancedEditorKit';\nimport {\n ExtensionMediaUpload,\n type MediaUploadOptions,\n} from '@kerebron/extension-basic-editor/ExtensionMediaUpload';\n\nexport type { MediaUploadOptions };\n\nexport interface CollabConfig {\n /** Room id — one shared document per room (e.g. a post id). */\n room: string;\n /**\n * WebSocket base URL for the Yjs relay. Defaults to\n * `<ws|wss>://<location.host>/yjs`. The room id is appended by the provider.\n */\n wsUrl?: string;\n /** Extra query params for the socket (e.g. `{ token }` for auth). */\n params?: Record<string, string>;\n /**\n * Who this editor is, published on awareness (`kerebron:user`) so peers see\n * a named, coloured cursor. Without it remote cursors do not render — the\n * position plugin skips awareness states that carry no user — and the\n * `id` is what the cursor colour is derived from (kerebron's `User` shape).\n */\n user?: { id: string; name: string; color?: string };\n /**\n * Custom WebSocket implementation handed to the Yjs provider — e.g. a\n * loopback socket for demos/tests, or a polyfill outside the browser.\n * Defaults to `globalThis.WebSocket`.\n */\n WebSocketPolyfill?: typeof globalThis.WebSocket;\n /**\n * Called when collaborative editing could not be started at all — the Yjs\n * kit failed to load (see {@link createEditorKits}). The editor mounts\n * anyway, as a local one; this is how the host finds out that edits are no\n * longer shared, so it can say so, or tear its own editor down if unshared\n * editing would be unsafe.\n *\n * Not for connection trouble: a room that is reachable but currently\n * disconnected still has the Yjs kit loaded, and the provider retries on its\n * own. This fires once, before the editor is created.\n */\n onUnavailable?: (error: unknown) => void;\n}\n\n/** What {@link createEditorKits} resolves to. */\nexport interface EditorKits {\n kits: EditorKit[];\n /**\n * Whether the returned kits can actually collaborate. False when `config`\n * asked for a room but the Yjs kit could not be loaded, so callers know not\n * to join one.\n */\n collaborative: boolean;\n}\n\n/**\n * Extensions dropped from {@link AdvancedEditorKit}, and why.\n *\n * `autocomplete` and `hover` debounce their DOM handlers (200ms) and then call\n * `dispatchMeta`, which reads `this.editor.state` with no guard that the editor\n * is still alive. Any teardown or document swap inside that debounce window\n * lands the deferred call on a dead view and throws\n * `null.matchesNode()` inside ProseMirror's `EditorView.updateStateInner`,\n * leaving the view permanently broken. Two ways to hit it:\n * - remount (e.g. a `key` change) while the pointer is over the editor, which\n * fires the debounced `onMouseLeave` after the view is destroyed;\n * - a Yjs remote update replacing the document tree under a pending callback.\n * The first applies to *every* editor, so both extensions come out in both\n * modes. No functional cost — autocomplete popups and node-hover tooltips are\n * compositor conveniences, not required for editing.\n *\n * `history` is collab-only: ExtensionYjs supplies its own CRDT-aware undo/redo\n * and the editor throws `Extension conflict: yjs vs history` if both are\n * present. Plain mode keeps it, so undo/redo still works there.\n */\nconst unsafeExtensions = ['autocomplete', 'hover'] as const;\n\n/**\n * {@link AdvancedEditorKit} minus {@link unsafeExtensions} (and, for collab\n * mode, minus `history`), with `mediaUpload` reconfigured when the host asks.\n *\n * `AdvancedEditorKit` constructs `ExtensionMediaUpload` with no options, and an\n * extension's options are fixed at construction — so the only way to configure\n * it is to drop that instance and append one of our own.\n */\nclass SafeAdvancedEditorKit implements EditorKit {\n name = 'advanced-editor';\n constructor(\n private readonly forCollab: boolean,\n private readonly mediaUpload?: MediaUploadOptions\n ) {}\n\n getExtensions() {\n const dropped: string[] = [...unsafeExtensions];\n if (this.forCollab) dropped.push('history');\n if (this.mediaUpload) dropped.push('mediaUpload');\n\n const extensions = new AdvancedEditorKit()\n .getExtensions()\n .filter(\n (extension) =>\n !('name' in extension && dropped.includes(extension.name))\n );\n\n if (this.mediaUpload) {\n extensions.push(new ExtensionMediaUpload(this.mediaUpload));\n }\n return extensions;\n }\n}\n\n/** MarkYChange + ExtensionYjs live in `collabKit.ts` (lazy-loaded). */\n\n/**\n * Build the editor kits for a session. Pass `config` to join a collaborative\n * room; omit it for a plain local editor. Pass `mediaUpload` to configure how\n * pasted/dropped files are handled — most importantly `uploadHandler`, without\n * which every image is embedded in the document as a base64 `data:` URL.\n *\n * Async because collaborative mode lazy-loads the Yjs kit (and its optional\n * peer deps) on first use; plain mode resolves immediately.\n *\n * That lazy load is allowed to fail. `@kerebron/extension-yjs`, `yjs` and\n * `y-protocols` are optional peers, so the chunk can be absent (peers never\n * installed), stale (a dev server's dependency hash moved under a running\n * page) or simply unreachable (a partial deploy, an offline client). None of\n * that is a reason to leave the caller without an editor: collaboration is an\n * enhancement, editing is the feature. So a failed load degrades to the local\n * kit and reports itself through {@link CollabConfig.onUnavailable} rather\n * than rejecting.\n */\nexport async function createEditorKits(\n config?: CollabConfig,\n mediaUpload?: MediaUploadOptions\n): Promise<EditorKits> {\n if (!config) {\n return {\n kits: [new SafeAdvancedEditorKit(false, mediaUpload)],\n collaborative: false,\n };\n }\n\n try {\n const { HuddleYjsKit, defaultWsUrl } = await import('./collabKit');\n const url = config.wsUrl ?? defaultWsUrl();\n return {\n kits: [\n new SafeAdvancedEditorKit(true, mediaUpload),\n new HuddleYjsKit(\n url,\n config.params ?? {},\n config.WebSocketPolyfill,\n config.user\n ),\n ],\n collaborative: true,\n };\n } catch (error) {\n console.warn(\n '[RichEditor] Collaborative editing unavailable — the Yjs kit failed to load. Continuing as a local editor.',\n error\n );\n config.onUnavailable?.(error);\n // Degrading to a local editor must not also drop `mediaUpload`: without it\n // the stock extension comes back and pasted files are embedded as base64.\n return {\n kits: [new SafeAdvancedEditorKit(false, mediaUpload)],\n collaborative: false,\n };\n }\n}\n","'use client';\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\n\nimport { CoreEditor, type AssetLoad } from '@kerebron/editor';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nimport { useIsDarkMode } from '../../hooks/useIsDarkMode';\nimport {\n createEditorKits,\n type CollabConfig,\n type MediaUploadOptions,\n} from './editorKits';\n\nexport type { CollabConfig, MediaUploadOptions } from './editorKits';\n\nconst MARKDOWN_TYPE = 'text/x-markdown';\n\n/**\n * The markdown converter's tree-sitter WASM init is not concurrency-safe, so\n * every editor's *first* load queues behind the previous one. Later loads (a\n * `value` change) are free — by then the grammars are warm.\n */\nlet initialLoadQueue: Promise<unknown> = Promise.resolve();\n\nfunction queueInitialLoad(load: () => Promise<void>): Promise<void> {\n const queued = initialLoadQueue.catch(() => undefined).then(load);\n initialLoadQueue = queued.catch(() => undefined);\n return queued;\n}\n\nexport interface RichEditorProps {\n /** Markdown to load. Changing it reloads the editor unless `collab` is set. */\n value?: string;\n /** Called with the editor's markdown content whenever it changes. */\n onChange?: (value: string) => void;\n /** Whether to render the live markdown output preview. Defaults to `false`. */\n showPreview?: boolean;\n /**\n * Enable live collaborative editing (Yjs) for the given room. When set, the\n * editor connects to the `/yjs` websocket relay and every peer in the same\n * `room` co-edits one shared document. Uncontrolled like `value` — remount via\n * `key` to switch rooms.\n *\n * Best-effort: if the Yjs kit cannot be loaded the editor still mounts, as a\n * local one, and `collab.onUnavailable` is called. Pass that callback if\n * unshared editing is something your users need to be told about.\n */\n collab?: CollabConfig;\n /** Read-only surface: no typing, and the content dims. */\n disabled?: boolean;\n /**\n * Id for the editor host element — an `aria-labelledby`/`aria-describedby`\n * anchor. The host is a `div`, not a labelable control, so a\n * `<label htmlFor>` will not associate; name the editor with `aria-label`\n * or `aria-labelledby` instead.\n */\n id?: string;\n /** Extra classes on the editor surface, beside `kb-component`. */\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n /**\n * Where the tree-sitter WASM grammars load from. Defaults to\n * `createAssetLoad('/kerebron-wasm')`; supply your own when the host serves\n * `@kerebron/wasm`'s `assets/` somewhere else.\n */\n assetLoad?: AssetLoad;\n /**\n * How files pasted or dropped into the editor are handled.\n *\n * **Set `uploadHandler` if your documents are persisted anywhere.** Without\n * it, a pasted image is embedded in the document as a base64 `data:` URL and\n * a video as a blob object URL: a 4 MB screenshot becomes ~5.8 MB of\n * markdown, which most APIs will refuse, and an object URL is dead as soon as\n * the page reloads. `uploadHandler` receives the file and returns the URL to\n * reference it by, so the document carries a link instead of the bytes.\n *\n * ```tsx\n * <RichEditor\n * mediaUpload={{ uploadHandler: (file) => uploadToMyMediaStore(file) }}\n * />\n * ```\n *\n * Read once, when the editor mounts — like {@link collab}, remount via `key`\n * to change it.\n */\n mediaUpload?: MediaUploadOptions;\n}\n\nexport interface RichEditorHandle {\n /**\n * The editor's markdown, awaiting the initial load. `onChange` can lag the\n * last keystroke, so read this on submit rather than trusting mirrored state.\n */\n getContent: () => Promise<string>;\n /** Focus the editor, restoring the caret where the writer left it. */\n focus: () => void;\n}\n\n/**\n * Markdown editor over Kerebron's `CoreEditor`.\n *\n * The editor mounts into a **disposable child div**: `CoreEditor.destroy()`\n * replaces its host element with a clone, which would strand React's ref (and,\n * under StrictMode's double-mount, leave the live editor detached behind a\n * dead clone).\n */\nconst RichEditor = forwardRef<RichEditorHandle, RichEditorProps>(\n function RichEditor(\n {\n value = '',\n onChange,\n showPreview = false,\n collab,\n disabled = false,\n id,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n assetLoad,\n mediaUpload,\n },\n ref\n ) {\n const isDark = useIsDarkMode();\n const hostRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n // Mirrors what the editor last held, so an echo of our own `onChange`\n // doesn't reload the document out from under the caret.\n const valueRef = useRef(value);\n const readyRef = useRef<Promise<void> | null>(null);\n const loadingRef = useRef(false);\n const disabledRef = useRef(disabled);\n\n const [md, setMd] = useState<string>('');\n // Serializing the document is the expensive part of a transaction, so the\n // last doc that was serialized is kept to recognise the transactions that\n // did not change it. ProseMirror documents are immutable, so identity is an\n // exact test.\n const lastSerializedDoc = useRef<unknown>(null);\n // Read inside the transaction handler, which is created once on mount.\n const showPreviewRef = useRef(showPreview);\n showPreviewRef.current = showPreview;\n\n useEffect(() => {\n disabledRef.current = disabled;\n editorInstance.current?.view.setProps({\n editable: () => !disabledRef.current,\n });\n }, [disabled]);\n\n useEffect(() => {\n // In collab mode the CRDT owns the content; reloading would fight it.\n if (collab || value === valueRef.current) return;\n valueRef.current = value;\n const editor = editorInstance.current;\n if (!editor) return;\n\n loadingRef.current = true;\n void editor\n .loadDocumentText(MARKDOWN_TYPE, value)\n .catch(() => undefined)\n .finally(() => {\n if (editorInstance.current === editor) loadingRef.current = false;\n });\n // `collab` is fixed for the lifetime of the instance.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value]);\n\n useEffect(() => {\n if (!hostRef.current) return;\n const host = hostRef.current;\n\n // Set on cleanup so async continuations (kit loading and the\n // `loadDocumentText` chain) don't touch the editor after `destroy()`.\n let disposed = false;\n let editor: CoreEditor | null = null;\n\n const mount = document.createElement('div');\n host.appendChild(mount);\n\n // Listen to transactions and update markdown preview\n const onTransaction = async () => {\n // Programmatic loads are not edits — reporting them would echo the\n // caller's own `value` back through `onChange`.\n if (loadingRef.current || !editorInstance.current) return;\n\n // ProseMirror fires a transaction for every selection change too —\n // arrow keys, clicks, a blur. Serializing the whole document to\n // markdown for those costs a full tree-sitter pass and two React\n // renders for a caret move, so only a changed document is re-read.\n const { doc } = editorInstance.current.view.state;\n if (doc === lastSerializedDoc.current) return;\n lastSerializedDoc.current = doc;\n\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n if (disposed) return;\n valueRef.current = markdown;\n // `md` only feeds the preview pane; setting it with the preview off\n // re-renders the editor on every keystroke for nothing.\n if (showPreviewRef.current) setMd(markdown);\n onChangeRef.current?.(markdown);\n } catch (err) {\n // The document was marked as serialized before the attempt, to keep\n // selection-only transactions arriving mid-save from re-entering.\n // A failure has to undo that, or this document is never retried.\n lastSerializedDoc.current = null;\n console.error('Failed to save markdown:', err);\n }\n };\n\n // Initialize the editor. Both modes drop the teardown-unsafe extensions;\n // collaborative mode additionally swaps `history` for the Yjs CRDT sync\n // and lazy-loads the Yjs kit (see `editorKits.ts` for why).\n const setup = async () => {\n // `collaborative` is false when a room was asked for but the Yjs kit\n // could not be loaded — the editor is still created, just a local one,\n // so there is no room to join below.\n const { kits: editorKits, collaborative } = await createEditorKits(\n collab,\n mediaUpload\n );\n if (disposed) return;\n\n editor = CoreEditor.create({\n element: mount,\n uri: 'file:///untitled.md',\n assetLoad: assetLoad ?? createAssetLoad('/kerebron-wasm'),\n editorKits,\n readOnly: disabledRef.current,\n });\n\n editorInstance.current = editor;\n // The contenteditable surface has no implicit ARIA role, so labeling\n // attributes are only permitted alongside an explicit textbox role.\n const surfaceAttributes =\n ariaLabel || ariaLabelledBy\n ? {\n role: 'textbox',\n 'aria-multiline': 'true',\n ...(ariaLabel ? { 'aria-label': ariaLabel } : {}),\n ...(ariaLabelledBy\n ? { 'aria-labelledby': ariaLabelledBy }\n : {}),\n }\n : null;\n editor.view.setProps({\n editable: () => !disabledRef.current,\n ...(surfaceAttributes ? { attributes: surfaceAttributes } : {}),\n });\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content, then populate the preview once on mount.\n //\n // In collaborative mode we still load the local markdown first, then\n // join the room: the Yjs binding seeds an *empty* shared document from\n // this content on the first join, and overwrites the editor with the\n // shared content when the room already has edits — so the stored\n // markdown is the starting point without ever double-inserting.\n const joinRoom = () => {\n if (collaborative && collab && editor && !disposed) {\n (\n editor.run as Record<string, (...args: unknown[]) => boolean>\n ).changeRoom?.(collab.room);\n reseedWhenRoomStaysEmpty();\n }\n };\n\n // The Yjs binding is supposed to seed an empty room from the local\n // content, but the sync import can land as an overwrite that blanks\n // the just-loaded seed (observed with extension-yjs 0.8.x). Heal it:\n // once the join settles, an empty document with a non-empty seed\n // means nobody's content won — reload the seed, which the binding\n // then pushes into the room. Joiners pass no value, so exactly one\n // participant ever does this.\n const seed = valueRef.current;\n const reseedWhenRoomStaysEmpty = () => {\n if (!seed) return;\n const check = async (attempt: number) => {\n if (disposed || !editorInstance.current) return;\n try {\n const buffer =\n await editorInstance.current.saveDocument(MARKDOWN_TYPE);\n const current = new globalThis.TextDecoder()\n .decode(buffer)\n .trim();\n if (disposed || !editorInstance.current) return;\n if (current) return; // somebody's content arrived — done\n if (attempt >= 2) {\n await editorInstance.current.loadDocumentText(\n MARKDOWN_TYPE,\n seed\n );\n return;\n }\n setTimeout(() => void check(attempt + 1), 300);\n } catch {\n // A failed probe must not break the editor; the room stays as-is.\n }\n };\n setTimeout(() => void check(0), 300);\n };\n\n if (valueRef.current) {\n await queueInitialLoad(() =>\n editor!.loadDocumentText(MARKDOWN_TYPE, valueRef.current)\n );\n await onTransaction();\n joinRoom();\n } else {\n void onTransaction();\n joinRoom();\n }\n };\n\n readyRef.current = setup().catch((err) =>\n console.error('Failed to set up editor:', err)\n );\n\n // Cleanup on unmount\n return () => {\n disposed = true;\n editorInstance.current = null; // makes onTransaction's guard effective\n editor?.removeEventListener('transaction', onTransaction);\n editor?.destroy();\n readyRef.current = null;\n host.replaceChildren();\n };\n // Initial `value`/`collab` are intentionally only applied on mount\n // (uncontrolled). Remount via `key` to switch rooms.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n getContent: async (): Promise<string> => {\n await readyRef.current;\n const editor = editorInstance.current;\n if (!editor) return valueRef.current;\n const buffer = await editor.saveDocument(MARKDOWN_TYPE);\n const markdown = new globalThis.TextDecoder().decode(buffer);\n valueRef.current = markdown;\n return markdown;\n },\n focus: (): void => {\n const apply = (): void => {\n const view = editorInstance.current?.view as\n | { focus?: () => void }\n | undefined;\n if (view?.focus) {\n view.focus();\n return;\n }\n hostRef.current\n ?.querySelector<HTMLElement>('[contenteditable=\"true\"], textarea')\n ?.focus();\n };\n // Callers focus on mount; the editor may still be loading its kits.\n if (editorInstance.current) apply();\n else void readyRef.current?.then(apply);\n },\n }),\n []\n );\n\n return (\n <div>\n <div>\n <div\n ref={hostRef}\n id={id}\n className={[\n 'kb-component',\n isDark ? 'kb-component--dark' : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ')}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-disabled={disabled || undefined}\n style={{\n isolation: 'isolate',\n opacity: disabled ? 0.65 : undefined,\n pointerEvents: disabled ? 'none' : undefined,\n }}\n />\n </div>\n\n {showPreview && (\n <div>\n <div>\n <h5>Markdown Output</h5>\n <pre>{md}</pre>\n </div>\n </div>\n )}\n </div>\n );\n }\n);\n\nRichEditor.displayName = 'RichEditor';\n\nexport { RichEditor };\n","import React, { useEffect, useRef } from 'react';\n\nimport { CoreEditor } from '@kerebron/editor';\nimport { CodeEditorKit } from '@kerebron/editor-kits/CodeEditorKit';\nimport { createAssetLoad } from '@kerebron/wasm/web';\n\nexport interface CodeEditorProps {\n /** Initial source code to load into the editor. */\n value?: string;\n /** Called with the editor's contents whenever they change. */\n onChange?: (value: string) => void;\n /** Language/grammar to use for syntax highlighting. Defaults to `typescript`. */\n lang?: string;\n}\n\nconst CodeEditor: React.FC<CodeEditorProps> = ({\n value = '',\n onChange,\n lang = 'typescript',\n}) => {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<CoreEditor | null>(null);\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n\n useEffect(() => {\n const root = editorRef.current;\n if (!root) return;\n\n const applySelectLabel = () => {\n root.querySelectorAll('select.codejar-select').forEach((element) => {\n if (!element.getAttribute('aria-label')) {\n element.setAttribute('aria-label', 'Code editor language');\n }\n });\n };\n\n applySelectLabel();\n const observer = new MutationObserver(() => applySelectLabel());\n observer.observe(root, { childList: true, subtree: true });\n return () => observer.disconnect();\n }, []);\n\n useEffect(() => {\n if (!editorRef.current) return;\n\n // Initialize the editor\n const editor = CoreEditor.create({\n element: editorRef.current,\n uri: 'file:///untitled.ts',\n assetLoad: createAssetLoad('/kerebron-wasm'),\n editorKits: [new CodeEditorKit(lang)],\n });\n\n editorInstance.current = editor;\n\n // Surface edits to callers.\n const onTransaction = async () => {\n if (!editorInstance.current) return;\n\n try {\n const buffer = await editorInstance.current.saveDocument('text/plain');\n onChangeRef.current?.(new globalThis.TextDecoder().decode(buffer));\n } catch (err) {\n console.error('Failed to read code:', err);\n }\n };\n\n editor.addEventListener('transaction', onTransaction);\n\n // Seed initial content on mount.\n if (value) {\n editor\n .loadDocumentText('text/plain', value)\n .catch((err) => console.error('Failed to load code:', err));\n }\n\n // Cleanup on unmount\n return () => {\n editor.removeEventListener('transaction', onTransaction);\n editor.destroy();\n };\n // Initial `value`/`lang` are intentionally only applied on mount.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div>\n <div>\n <div ref={editorRef} className=\"kb-component\" />\n </div>\n </div>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n\nexport { CodeEditor };\n"]}
|
package/dist/motion.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkIEY3ZJIT_cjs = require('./chunk-IEY3ZJIT.cjs');
|
|
4
4
|
require('./chunk-S5RVSXDV.cjs');
|
|
5
5
|
require('./chunk-EUAMEVVI.cjs');
|
|
6
6
|
var React = require('react');
|
|
@@ -46,7 +46,7 @@ function MotionProvider({
|
|
|
46
46
|
Nav: react.m.nav,
|
|
47
47
|
Span: react.m.span,
|
|
48
48
|
Presence,
|
|
49
|
-
...
|
|
49
|
+
...chunkIEY3ZJIT_cjs.createPresetPropBuilders()
|
|
50
50
|
}),
|
|
51
51
|
[disabled]
|
|
52
52
|
);
|
|
@@ -62,26 +62,26 @@ function MotionProvider({
|
|
|
62
62
|
// A disabled provider still supplies the runtime (with `enabled: false`)
|
|
63
63
|
// rather than `null`, so consumers can distinguish "disabled" from "never
|
|
64
64
|
// opted in" — see the `enabled` contract in `runtime.ts`.
|
|
65
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domAnimation, children: /* @__PURE__ */ jsxRuntime.jsx(react.MotionConfig, { reducedMotion, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.LazyMotion, { features: react.domAnimation, children: /* @__PURE__ */ jsxRuntime.jsx(react.MotionConfig, { reducedMotion, children: /* @__PURE__ */ jsxRuntime.jsx(chunkIEY3ZJIT_cjs.MotionRuntimeContext.Provider, { value: runtime, children }) }) })
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
MotionProvider.displayName = "MotionProvider";
|
|
69
69
|
|
|
70
70
|
Object.defineProperty(exports, "Animated", {
|
|
71
71
|
enumerable: true,
|
|
72
|
-
get: function () { return
|
|
72
|
+
get: function () { return chunkIEY3ZJIT_cjs.Animated; }
|
|
73
73
|
});
|
|
74
74
|
Object.defineProperty(exports, "AnimatedPresence", {
|
|
75
75
|
enumerable: true,
|
|
76
|
-
get: function () { return
|
|
76
|
+
get: function () { return chunkIEY3ZJIT_cjs.AnimatedPresence; }
|
|
77
77
|
});
|
|
78
78
|
Object.defineProperty(exports, "motionPresets", {
|
|
79
79
|
enumerable: true,
|
|
80
|
-
get: function () { return
|
|
80
|
+
get: function () { return chunkIEY3ZJIT_cjs.motionPresets; }
|
|
81
81
|
});
|
|
82
82
|
Object.defineProperty(exports, "useMotionRuntime", {
|
|
83
83
|
enumerable: true,
|
|
84
|
-
get: function () { return
|
|
84
|
+
get: function () { return chunkIEY3ZJIT_cjs.useMotionRuntime; }
|
|
85
85
|
});
|
|
86
86
|
exports.MotionProvider = MotionProvider;
|
|
87
87
|
//# sourceMappingURL=motion.cjs.map
|
package/dist/motion.d.cts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
export { A as Animated, a as AnimatedPresence, b as AnimatedProps, M as MotionEdge, c as MotionPreset, d as MotionRuntime, m as motionPresets, u as useMotionRuntime } from './Animated-XmH6k8pZ.cjs';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* `<MotionProvider>` — the opt-in switch.
|
|
@@ -49,4 +48,189 @@ declare namespace MotionProvider {
|
|
|
49
48
|
var displayName: string;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Motion presets — the shared vocabulary of animations.
|
|
53
|
+
*
|
|
54
|
+
* This module is intentionally **free of any `motion` import**. It ships in the
|
|
55
|
+
* main `@mieweb/ui` entry so components can describe *what* they animate
|
|
56
|
+
* without pulling in a runtime to actually do it. The `@mieweb/ui/motion` entry
|
|
57
|
+
* is what turns these descriptions into real animations.
|
|
58
|
+
*
|
|
59
|
+
* Every preset is expressed as an open/closed variant pair so the same
|
|
60
|
+
* definition serves both usages:
|
|
61
|
+
*
|
|
62
|
+
* - **toggle** — the element stays mounted and animates between `open` and
|
|
63
|
+
* `closed` (a drawer sliding in and out).
|
|
64
|
+
* - **presence** — the element mounts and unmounts, entering on `open` and
|
|
65
|
+
* exiting back to `closed` (a modal).
|
|
66
|
+
*/
|
|
67
|
+
/** Named animation recipes shared by components. */
|
|
68
|
+
type MotionPreset = 'drawerStart' | 'overlay' | 'modalContent' | 'sidebarLabel' | 'menu' | 'collapse' | 'toast' | 'fade' | 'pop';
|
|
69
|
+
/**
|
|
70
|
+
* A physical edge, already resolved from any logical (`start`/`end`) position
|
|
71
|
+
* and from writing direction.
|
|
72
|
+
*
|
|
73
|
+
* Presets that move an element along an axis take one of these as `custom`.
|
|
74
|
+
* Resolution is the component's job, not the preset's: only the component knows
|
|
75
|
+
* whether its `end` means right or left, and — for anything anchored — which
|
|
76
|
+
* side it actually landed on after flipping away from a viewport edge.
|
|
77
|
+
*/
|
|
78
|
+
type MotionEdge = 'top' | 'bottom' | 'left' | 'right';
|
|
79
|
+
/**
|
|
80
|
+
* A variant value. Either a plain target object or a function of the element's
|
|
81
|
+
* `custom` value — the latter lets a single preset adapt to context, e.g. a
|
|
82
|
+
* drawer flipping its off-canvas direction in RTL.
|
|
83
|
+
*/
|
|
84
|
+
type MotionVariant = Record<string, unknown> | ((custom: unknown) => Record<string, unknown>);
|
|
85
|
+
interface MotionPresetDefinition {
|
|
86
|
+
variants: {
|
|
87
|
+
open: MotionVariant;
|
|
88
|
+
closed: MotionVariant;
|
|
89
|
+
};
|
|
90
|
+
transition: Record<string, unknown>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* `custom` contract per preset:
|
|
94
|
+
*
|
|
95
|
+
* - `drawerStart` — `boolean`, whether the document direction is RTL.
|
|
96
|
+
* - `menu`, `toast` — a {@link MotionEdge}, already resolved from logical
|
|
97
|
+
* position and writing direction by the component.
|
|
98
|
+
* - `overlay`, `modalContent`, `sidebarLabel`, `collapse`, `fade`, `pop` —
|
|
99
|
+
* unused.
|
|
100
|
+
*/
|
|
101
|
+
declare const motionPresets: Record<MotionPreset, MotionPresetDefinition>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Motion runtime — the seam between components and an optional animation library.
|
|
105
|
+
*
|
|
106
|
+
* Components in the main entry never import `motion`. They ask this module for
|
|
107
|
+
* a runtime; if an app has opted in by rendering `<MotionProvider>` from
|
|
108
|
+
* `@mieweb/ui/motion`, they get one and animate. If not, `useMotionRuntime()`
|
|
109
|
+
* returns `null` and they fall back to their existing CSS transitions. That is
|
|
110
|
+
* what keeps `motion` out of the bundle of every app that hasn't asked for it —
|
|
111
|
+
* the opt-in is resolved in the *module graph*, not by a prop.
|
|
112
|
+
*
|
|
113
|
+
* Like `presets`, this module must stay free of any `motion` import.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
interface MotionPresenceProps {
|
|
117
|
+
children?: React.ReactNode;
|
|
118
|
+
/** Suppress the initial mount animation. */
|
|
119
|
+
initial?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Fires once every exiting child has finished and been removed.
|
|
122
|
+
*
|
|
123
|
+
* Needed by anything that guards the DOM while it is open — a focus trap, a
|
|
124
|
+
* scroll lock — because those guards must outlive `open` for as long as the
|
|
125
|
+
* subtree is still on screen. Never fires when no runtime is active, since
|
|
126
|
+
* there is no exit to wait for.
|
|
127
|
+
*/
|
|
128
|
+
onExitComplete?: () => void;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The capabilities a motion library must supply. Deliberately small: element
|
|
132
|
+
* factories, a presence wrapper, and prop builders. Components depend on this
|
|
133
|
+
* interface, never on a concrete library, so swapping or dropping the library
|
|
134
|
+
* stays a one-file change.
|
|
135
|
+
*/
|
|
136
|
+
interface MotionRuntime {
|
|
137
|
+
/**
|
|
138
|
+
* Whether animations should actually run.
|
|
139
|
+
*
|
|
140
|
+
* A disabled provider still supplies a runtime rather than `null` so that
|
|
141
|
+
* consumers can tell "disabled" apart from "never opted in": `Modal` uses it
|
|
142
|
+
* to decide whether an exit animation will ever report completion, and
|
|
143
|
+
* `AnimatedPresence` keeps its wrapper element stable across the flip.
|
|
144
|
+
* `Animated` itself renders the plain fallback tag whenever this is false —
|
|
145
|
+
* withholding animation props from a mounted motion component corrupts
|
|
146
|
+
* `toggle`-mode elements, so the swap (and the remount it implies) is the
|
|
147
|
+
* correct behaviour. See the render branches in `Animated`.
|
|
148
|
+
*/
|
|
149
|
+
enabled: boolean;
|
|
150
|
+
/** Animated `div`. */
|
|
151
|
+
Div: React.ElementType;
|
|
152
|
+
/** Animated `nav`. */
|
|
153
|
+
Nav: React.ElementType;
|
|
154
|
+
/** Animated `span`, for inline content that must not become a block. */
|
|
155
|
+
Span: React.ElementType;
|
|
156
|
+
/** Enables exit animations for conditionally rendered children. */
|
|
157
|
+
Presence: React.ComponentType<MotionPresenceProps>;
|
|
158
|
+
/**
|
|
159
|
+
* Props for an element that stays mounted and animates between states.
|
|
160
|
+
* Skips the initial animation so a closed drawer doesn't slide out on load.
|
|
161
|
+
*/
|
|
162
|
+
toggle: (preset: MotionPreset, open: boolean, custom?: unknown) => Record<string, unknown>;
|
|
163
|
+
/** Props for an element that mounts and unmounts inside `Presence`. */
|
|
164
|
+
presence: (preset: MotionPreset, custom?: unknown) => Record<string, unknown>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The active motion runtime, or `null` when the app has not opted in.
|
|
168
|
+
*
|
|
169
|
+
* Components must treat `null` as the normal case and keep a CSS path that
|
|
170
|
+
* looks good on its own — motion is an enhancement, never a requirement.
|
|
171
|
+
*/
|
|
172
|
+
declare function useMotionRuntime(): MotionRuntime | null;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* `Animated` / `AnimatedPresence` — the ergonomic layer components use.
|
|
176
|
+
*
|
|
177
|
+
* These exist so an individual component never has to branch on whether motion
|
|
178
|
+
* is available. It declares the preset it wants and the CSS classes that stand
|
|
179
|
+
* in when motion is absent; this module picks the element to render.
|
|
180
|
+
*
|
|
181
|
+
* Adding motion to a further component should be a matter of swapping its
|
|
182
|
+
* root `<div>` for an `<Animated>` and naming a preset — no new imports, no
|
|
183
|
+
* new dependency, and no behavior change for apps that have not opted in.
|
|
184
|
+
*/
|
|
185
|
+
|
|
186
|
+
interface AnimatedProps extends React.HTMLAttributes<HTMLElement> {
|
|
187
|
+
/** Intrinsic element to render. */
|
|
188
|
+
as?: 'div' | 'nav' | 'span';
|
|
189
|
+
/** Which shared animation recipe to use. */
|
|
190
|
+
preset: MotionPreset;
|
|
191
|
+
/**
|
|
192
|
+
* - `toggle` — element stays mounted and animates between open and closed.
|
|
193
|
+
* - `presence` — element mounts and unmounts; wrap it in `<AnimatedPresence>`
|
|
194
|
+
* so the exit animation gets a chance to run.
|
|
195
|
+
*/
|
|
196
|
+
mode: 'toggle' | 'presence';
|
|
197
|
+
/** Current state. Only read in `toggle` mode. */
|
|
198
|
+
open?: boolean;
|
|
199
|
+
/** Per-preset context value — see the `custom` contract in `presets.ts`. */
|
|
200
|
+
custom?: unknown;
|
|
201
|
+
/**
|
|
202
|
+
* Classes applied whenever this element is **not** animating — no provider,
|
|
203
|
+
* a disabled provider, or `enabled={false}`. This is where a component's
|
|
204
|
+
* existing CSS transition lives, so the two paths never both try to drive
|
|
205
|
+
* the same property.
|
|
206
|
+
*/
|
|
207
|
+
fallbackClassName?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Set `false` to stop this element animating even when a runtime is active.
|
|
210
|
+
*
|
|
211
|
+
* For states where an animated element would be wrong rather than merely
|
|
212
|
+
* unnecessary. Motion writes a `transform` to hold an element at its resting
|
|
213
|
+
* position, and a transformed ancestor becomes the containing block for any
|
|
214
|
+
* `position: fixed` descendant — so an element that is only sometimes
|
|
215
|
+
* animated should opt out the rest of the time.
|
|
216
|
+
*
|
|
217
|
+
* Flipping this (or the provider's `disabled`) swaps the element back to a
|
|
218
|
+
* plain tag, which **remounts** it — deliberately. See the note on the
|
|
219
|
+
* render branches below.
|
|
220
|
+
*/
|
|
221
|
+
enabled?: boolean;
|
|
222
|
+
}
|
|
223
|
+
declare const Animated: React.ForwardRefExoticComponent<AnimatedProps & React.RefAttributes<HTMLElement>>;
|
|
224
|
+
/**
|
|
225
|
+
* Keeps unmounting children on screen long enough to animate out.
|
|
226
|
+
*
|
|
227
|
+
* Without a runtime this is a pass-through, so children disappear immediately —
|
|
228
|
+
* which is exactly what they do today. Children rendered conditionally inside
|
|
229
|
+
* it need a stable `key`.
|
|
230
|
+
*/
|
|
231
|
+
declare function AnimatedPresence({ children, initial, onExitComplete, }: MotionPresenceProps): React.JSX.Element;
|
|
232
|
+
declare namespace AnimatedPresence {
|
|
233
|
+
var displayName: string;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export { Animated, AnimatedPresence, type AnimatedProps, type MotionEdge, type MotionPreset, MotionProvider, type MotionProviderProps, type MotionRuntime, motionPresets, useMotionRuntime };
|