@soroush.tech/design-system 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -36
- package/dist/AppBar.cjs +2 -2
- package/dist/AppBar.d.cts +3 -2
- package/dist/AppBar.d.mts +3 -2
- package/dist/AppBar.mjs +2 -2
- package/dist/Avatar.cjs +4 -4
- package/dist/Avatar.d.cts +3 -2
- package/dist/Avatar.d.mts +3 -2
- package/dist/Avatar.mjs +3 -2
- package/dist/Backdrop.cjs +1 -1
- package/dist/Backdrop.d.cts +1 -1
- package/dist/Backdrop.d.mts +1 -1
- package/dist/Backdrop.mjs +1 -1
- package/dist/Button.cjs +5 -12
- package/dist/Button.d.cts +1 -1
- package/dist/Button.d.mts +1 -1
- package/dist/Button.mjs +3 -9
- package/dist/ButtonGroup.cjs +2 -2
- package/dist/ButtonGroup.d.cts +1 -1
- package/dist/ButtonGroup.d.mts +1 -1
- package/dist/ButtonGroup.mjs +2 -2
- package/dist/Card.cjs +6 -7
- package/dist/Card.d.cts +3 -3
- package/dist/Card.d.mts +3 -3
- package/dist/Card.mjs +4 -4
- package/dist/Checkbox.cjs +2 -2
- package/dist/Checkbox.d.cts +42 -1
- package/dist/Checkbox.d.mts +42 -1
- package/dist/Checkbox.mjs +2 -2
- package/dist/CircularProgress.cjs +2 -2
- package/dist/CircularProgress.d.cts +3 -2
- package/dist/CircularProgress.d.mts +3 -2
- package/dist/CircularProgress.mjs +2 -2
- package/dist/Drawer.cjs +2 -2
- package/dist/Drawer.d.cts +2 -2
- package/dist/Drawer.d.mts +2 -2
- package/dist/Drawer.mjs +2 -2
- package/dist/Flex.cjs +3 -7
- package/dist/Flex.d.cts +1 -1
- package/dist/Flex.d.mts +1 -1
- package/dist/Flex.mjs +3 -9
- package/dist/FocusTrap.cjs +1 -1
- package/dist/FocusTrap.mjs +1 -1
- package/dist/Form.cjs +2 -3
- package/dist/Form.d.cts +1 -1
- package/dist/Form.d.mts +1 -1
- package/dist/Form.mjs +2 -3
- package/dist/{FormContext-CRmRgDgu.cjs → FormContext-BGCsWAFc.cjs} +0 -1
- package/dist/{FormContext-_G3sxJyQ.mjs → FormContext-LrjAGe6U.mjs} +0 -1
- package/dist/FormControl.cjs +6 -6
- package/dist/FormControl.d.cts +2 -2
- package/dist/FormControl.d.mts +2 -2
- package/dist/FormControl.mjs +5 -5
- package/dist/{FormControlContext-aeKTjRKY.cjs → FormControlContext-74gvPGFk.cjs} +0 -1
- package/dist/{FormControlContext-CyxdOxdN.mjs → FormControlContext-CC2kToms.mjs} +0 -1
- package/dist/FormHelperText.cjs +3 -3
- package/dist/FormHelperText.d.cts +1 -1
- package/dist/FormHelperText.d.mts +1 -1
- package/dist/FormHelperText.mjs +3 -3
- package/dist/FormLabel.cjs +3 -3
- package/dist/FormLabel.d.cts +17 -1
- package/dist/FormLabel.d.mts +17 -1
- package/dist/FormLabel.mjs +3 -3
- package/dist/Grid.cjs +3 -26
- package/dist/Grid.d.cts +4 -10
- package/dist/Grid.d.mts +4 -10
- package/dist/Grid.mjs +3 -25
- package/dist/{Icon-1YtNCUKo.cjs → Icon-BOjk5r39.cjs} +75 -5
- package/dist/{Icon-CAKRmFz3.mjs → Icon-CYjD0Bad.mjs} +74 -3
- package/dist/Icon.cjs +1 -1
- package/dist/Icon.d.cts +1 -1
- package/dist/Icon.d.mts +1 -1
- package/dist/Icon.mjs +1 -1
- package/dist/Image.cjs +1 -1
- package/dist/Image.d.cts +16 -1
- package/dist/Image.d.mts +16 -1
- package/dist/Image.mjs +1 -1
- package/dist/LinearProgress.cjs +2 -2
- package/dist/LinearProgress.d.cts +3 -2
- package/dist/LinearProgress.d.mts +3 -2
- package/dist/LinearProgress.mjs +2 -2
- package/dist/Link.cjs +5 -9
- package/dist/Link.d.cts +9 -1
- package/dist/Link.d.mts +9 -1
- package/dist/Link.mjs +4 -7
- package/dist/MenuItem.cjs +6 -7
- package/dist/MenuItem.d.cts +2 -1
- package/dist/MenuItem.d.mts +2 -1
- package/dist/MenuItem.mjs +4 -3
- package/dist/{Modal-BDMPTSXv.cjs → Modal-DZH-DzMZ.cjs} +2 -2
- package/dist/{Modal-DR60peRg.mjs → Modal-dy5l7gfH.mjs} +2 -2
- package/dist/Modal.cjs +1 -1
- package/dist/Modal.d.cts +1 -1
- package/dist/Modal.d.mts +1 -1
- package/dist/Modal.mjs +1 -1
- package/dist/NativeSelect.cjs +5 -5
- package/dist/NativeSelect.d.cts +3 -2
- package/dist/NativeSelect.d.mts +3 -2
- package/dist/NativeSelect.mjs +4 -3
- package/dist/Pagination/PaginationItem.cjs +3 -3
- package/dist/Pagination/PaginationItem.d.cts +1 -1
- package/dist/Pagination/PaginationItem.d.mts +1 -1
- package/dist/Pagination/PaginationItem.mjs +3 -3
- package/dist/Pagination.cjs +1 -1
- package/dist/Pagination.d.cts +2 -22
- package/dist/Pagination.d.mts +2 -22
- package/dist/Pagination.mjs +1 -1
- package/dist/Paper.cjs +5 -8
- package/dist/Paper.d.cts +1 -1
- package/dist/Paper.d.mts +1 -1
- package/dist/Paper.mjs +3 -4
- package/dist/{Popover-B61J7C79.mjs → Popover-Chgtjn-N.mjs} +3 -2
- package/dist/{Popover-CRDLmywF.cjs → Popover-pEVboMZO.cjs} +4 -4
- package/dist/Popover.cjs +1 -1
- package/dist/Popover.d.cts +4 -3
- package/dist/Popover.d.mts +4 -3
- package/dist/Popover.mjs +1 -1
- package/dist/Pressable.cjs +123 -0
- package/dist/Pressable.d.cts +2 -0
- package/dist/Pressable.d.mts +2 -0
- package/dist/Pressable.mjs +121 -0
- package/dist/Quote.cjs +1 -1
- package/dist/Quote.d.cts +13 -1
- package/dist/Quote.d.mts +13 -1
- package/dist/Quote.mjs +1 -1
- package/dist/Radio.cjs +2 -2
- package/dist/Radio.d.cts +2 -2
- package/dist/Radio.d.mts +2 -2
- package/dist/Radio.mjs +2 -2
- package/dist/Select.cjs +10 -32
- package/dist/Select.d.cts +3 -2
- package/dist/Select.d.mts +3 -2
- package/dist/Select.mjs +9 -30
- package/dist/Sidebar/Sidebar.cjs +94 -0
- package/dist/Sidebar/Sidebar.d.cts +59 -0
- package/dist/Sidebar/Sidebar.d.mts +59 -0
- package/dist/Sidebar/Sidebar.mjs +93 -0
- package/dist/Sidebar/SidebarItem.cjs +125 -0
- package/dist/Sidebar/SidebarItem.d.cts +39 -0
- package/dist/Sidebar/SidebarItem.d.mts +39 -0
- package/dist/Sidebar/SidebarItem.mjs +124 -0
- package/dist/Sidebar.cjs +7 -0
- package/dist/Sidebar.d.cts +4 -0
- package/dist/Sidebar.d.mts +4 -0
- package/dist/Sidebar.mjs +4 -0
- package/dist/SidebarContext-DgSLwjur.mjs +10 -0
- package/dist/SidebarContext-ao6lRfTX.d.cts +37 -0
- package/dist/SidebarContext-ao6lRfTX.d.mts +37 -0
- package/dist/SidebarContext-jG6OioC-.cjs +14 -0
- package/dist/Skeleton.cjs +1 -1
- package/dist/Skeleton.d.cts +2 -1
- package/dist/Skeleton.d.mts +2 -1
- package/dist/Skeleton.mjs +1 -1
- package/dist/Switch.cjs +4 -4
- package/dist/Switch.d.cts +2 -1
- package/dist/Switch.d.mts +2 -1
- package/dist/Switch.mjs +3 -2
- package/dist/Table/Table.cjs +2 -2
- package/dist/Table/Table.d.cts +47 -1
- package/dist/Table/Table.d.mts +47 -1
- package/dist/Table/Table.mjs +2 -2
- package/dist/Table/TableBody.cjs +1 -1
- package/dist/Table/TableBody.d.cts +21 -1
- package/dist/Table/TableBody.d.mts +21 -1
- package/dist/Table/TableBody.mjs +1 -1
- package/dist/Table/TableCell.cjs +3 -3
- package/dist/Table/TableCell.d.cts +1 -1
- package/dist/Table/TableCell.d.mts +1 -1
- package/dist/Table/TableCell.mjs +3 -3
- package/dist/Table/TableContainer.cjs +1 -1
- package/dist/Table/TableContainer.d.cts +17 -1
- package/dist/Table/TableContainer.d.mts +17 -1
- package/dist/Table/TableContainer.mjs +1 -1
- package/dist/Table/TableControl.d.cts +27 -1
- package/dist/Table/TableControl.d.mts +27 -1
- package/dist/Table/TableFooter.cjs +1 -1
- package/dist/Table/TableFooter.d.cts +21 -1
- package/dist/Table/TableFooter.d.mts +21 -1
- package/dist/Table/TableFooter.mjs +1 -1
- package/dist/Table/TableHead.cjs +1 -1
- package/dist/Table/TableHead.d.cts +21 -1
- package/dist/Table/TableHead.d.mts +21 -1
- package/dist/Table/TableHead.mjs +1 -1
- package/dist/Table/TablePagination.cjs +1 -1
- package/dist/Table/TablePagination.d.cts +44 -1
- package/dist/Table/TablePagination.d.mts +44 -1
- package/dist/Table/TablePagination.mjs +1 -1
- package/dist/Table/TablePaginationActions.cjs +4 -4
- package/dist/Table/TablePaginationActions.d.cts +1 -1
- package/dist/Table/TablePaginationActions.d.mts +1 -1
- package/dist/Table/TablePaginationActions.mjs +3 -2
- package/dist/Table/TableRow.cjs +3 -3
- package/dist/Table/TableRow.d.cts +29 -1
- package/dist/Table/TableRow.d.mts +29 -1
- package/dist/Table/TableRow.mjs +3 -3
- package/dist/Table/TableSortLabel.cjs +3 -3
- package/dist/Table/TableSortLabel.d.cts +1 -1
- package/dist/Table/TableSortLabel.d.mts +1 -1
- package/dist/Table/TableSortLabel.mjs +3 -3
- package/dist/Table/hooks.d.cts +39 -2
- package/dist/Table/hooks.d.mts +39 -2
- package/dist/Table.cjs +1 -1
- package/dist/Table.d.cts +14 -15
- package/dist/Table.d.mts +14 -15
- package/dist/Table.mjs +1 -1
- package/dist/{TableContext-qqp35o8z.cjs → TableContext-Bfg1C3Sr.cjs} +0 -1
- package/dist/{TableContext-2qH7XYJB.d.cts → TableContext-BoOxdk8p.d.cts} +1 -1
- package/dist/{TableContext-2qH7XYJB.d.mts → TableContext-DV31j6HO.d.mts} +1 -1
- package/dist/{TableContext-BRWPghAI.mjs → TableContext-Dyr89h_k.mjs} +0 -1
- package/dist/TextInput.cjs +228 -2
- package/dist/TextInput.d.cts +79 -1
- package/dist/TextInput.d.mts +79 -1
- package/dist/TextInput.mjs +226 -1
- package/dist/ToggleButton/ToggleButton.cjs +4 -4
- package/dist/ToggleButton/ToggleButton.d.cts +1 -1
- package/dist/ToggleButton/ToggleButton.d.mts +1 -1
- package/dist/ToggleButton/ToggleButton.mjs +3 -2
- package/dist/ToggleButton/ToggleButtonGroup.cjs +4 -4
- package/dist/ToggleButton/ToggleButtonGroup.d.cts +1 -1
- package/dist/ToggleButton/ToggleButtonGroup.d.mts +1 -1
- package/dist/ToggleButton/ToggleButtonGroup.mjs +3 -2
- package/dist/ToggleButton.d.cts +1 -1
- package/dist/ToggleButton.d.mts +1 -1
- package/dist/Typography.cjs +3 -3
- package/dist/Typography.d.cts +2 -2
- package/dist/Typography.d.mts +2 -2
- package/dist/Typography.mjs +2 -1
- package/dist/View.cjs +1 -3
- package/dist/View.d.cts +1 -1
- package/dist/View.d.mts +1 -1
- package/dist/View.mjs +1 -3
- package/dist/emotion-BAyqVw0c.mjs +6 -0
- package/dist/emotion-DviPkkGL.cjs +10 -0
- package/dist/engine.cjs +80 -0
- package/dist/engine.d.cts +21 -0
- package/dist/engine.d.mts +21 -0
- package/dist/engine.mjs +69 -0
- package/dist/{index-BqVgv2B_.d.mts → index--mvTGo8F.d.cts} +3 -2
- package/dist/{index-DSCMXFTn.d.cts → index-ATXjtAOY.d.mts} +2 -1
- package/dist/{index-CDVnvjIE.d.cts → index-B2hrssyF.d.mts} +2 -2
- package/dist/index-B3FrhO2r.d.cts +24 -0
- package/dist/{index-BnzUumAC2.d.mts → index-B7aaTHOe.d.cts} +2 -1
- package/dist/{index-DmJIuQJj.d.mts → index-BItZoGZ1.d.mts} +3 -2
- package/dist/{index-DASvoACZ.d.cts → index-BJ8OC_Zh.d.cts} +2 -2
- package/dist/{index-BLfFycfJ.d.mts → index-BL3jwIQU.d.mts} +9 -2
- package/dist/{index-4rC2j7fR.d.cts → index-BNP_iejT.d.cts} +3 -2
- package/dist/{index-Dy03o__A.d.mts → index-BfpjEqqt.d.cts} +2 -1
- package/dist/index-BoOs5h_b.d.mts +53 -0
- package/dist/{index-CeYkEXU2.d.cts → index-BwUnDd9W.d.mts} +2 -2
- package/dist/{index-BH8jQOdF.d.mts → index-C7j38wne.d.mts} +3 -2
- package/dist/{index-Dp81rWM1.d.cts → index-CA_X-mXg.d.cts} +9 -2
- package/dist/index-CO3Qq0I0.d.mts +49 -0
- package/dist/{index-BLRMuO_x.d.mts → index-CYTaYcm3.d.cts} +3 -4
- package/dist/index-Ca0Pj5m2.d.mts +24 -0
- package/dist/{index-DE5PtzPn.d.mts → index-CvaEVk-f.d.cts} +2 -2
- package/dist/{index-C0xMvDjL.d.mts → index-D8U2tk1L.d.mts} +2 -2
- package/dist/{index-Dm9HfgV6.d.mts → index-D8b5OCLe.d.mts} +17 -7
- package/dist/{index-B1rCD6Oo.d.cts → index-DEv2QslH.d.mts} +4 -6
- package/dist/{index-CyZYXDn0.d.cts → index-DF3Hweir.d.mts} +3 -2
- package/dist/{index-Bihpwn75.d.cts → index-DLJ-li1B.d.cts} +17 -7
- package/dist/{index-FwTocqhP.d.cts → index-DjtGkwRM.d.cts} +2 -3
- package/dist/{index-BX5-NfbX.d.cts → index-Ds__py2h.d.mts} +2 -1
- package/dist/{index-x80UG39F.d.cts → index-KZUd8B5E.d.mts} +3 -4
- package/dist/index-MsUtFRul.d.cts +53 -0
- package/dist/index-dtLxevvf.d.cts +49 -0
- package/dist/{index-pX7tBQdJ.d.mts → index-q6EgsH9R.d.mts} +2 -3
- package/dist/{index-8dzWTpFp.d.cts → index-v99yMdts.d.cts} +3 -2
- package/dist/{index-CxSNNzBT2.d.mts → index-yr4HkKOj.d.cts} +2 -2
- package/dist/{index-z35LEYG8.d.mts → index-zFYi0f1t.d.cts} +4 -6
- package/dist/index.cjs +2 -32
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/{src-DcNT2aIK.mjs → src-BJy4dM4f.mjs} +5 -10
- package/dist/{src-BiocWFSR.cjs → src-C8PIppTy.cjs} +2 -7
- package/dist/{hooks.cjs → style.cjs} +5 -23
- package/dist/style.d.cts +23 -0
- package/dist/style.d.mts +23 -0
- package/dist/{hooks.mjs → style.mjs} +6 -16
- package/dist/theme-Du6xgPsg.cjs +470 -0
- package/dist/{themes.mjs → theme-V6lYzd3j.mjs} +68 -14
- package/dist/theme.cjs +23 -0
- package/dist/theme.d.cts +3 -0
- package/dist/theme.d.mts +3 -0
- package/dist/theme.mjs +3 -0
- package/dist/{themeDefault-B-QjpGEO.cjs → themeDefault-Cebi08Cv.cjs} +1 -1
- package/dist/{themeDefault-CjXaY3ok.mjs → themeDefault-Z3KmyIbm.mjs} +1 -1
- package/dist/themes-CUV79qWU.d.cts +503 -0
- package/dist/themes-CUV79qWU.d.mts +503 -0
- package/dist/{useTableSort--XMWjujs.d.cts → useTablePagination-7jiSvKCh.d.cts} +25 -25
- package/dist/{useTableSort-CpDs4cGq.d.mts → useTablePagination-HaIcJPv-.d.mts} +25 -25
- package/dist/utils.cjs +0 -29
- package/dist/utils.d.cts +1 -19
- package/dist/utils.d.mts +1 -19
- package/dist/utils.mjs +1 -27
- package/package.json +431 -24
- package/dist/CodeBlock.cjs +0 -101
- package/dist/CodeBlock.d.cts +0 -2
- package/dist/CodeBlock.d.mts +0 -2
- package/dist/CodeBlock.mjs +0 -100
- package/dist/Field.cjs +0 -59
- package/dist/Field.d.cts +0 -36
- package/dist/Field.d.mts +0 -36
- package/dist/Field.mjs +0 -58
- package/dist/Markdown/Control.cjs +0 -61
- package/dist/Markdown/Control.d.cts +0 -18
- package/dist/Markdown/Control.d.mts +0 -18
- package/dist/Markdown/Control.mjs +0 -60
- package/dist/Markdown/Editor.cjs +0 -130
- package/dist/Markdown/Editor.d.cts +0 -40
- package/dist/Markdown/Editor.d.mts +0 -40
- package/dist/Markdown/Editor.mjs +0 -128
- package/dist/Markdown/Preview.cjs +0 -241
- package/dist/Markdown/Preview.d.cts +0 -55
- package/dist/Markdown/Preview.d.mts +0 -55
- package/dist/Markdown/Preview.mjs +0 -236
- package/dist/Markdown/Toolbar.cjs +0 -4
- package/dist/Markdown/Toolbar.d.cts +0 -13
- package/dist/Markdown/Toolbar.d.mts +0 -13
- package/dist/Markdown/Toolbar.mjs +0 -2
- package/dist/Markdown.cjs +0 -13
- package/dist/Markdown.d.cts +0 -80
- package/dist/Markdown.d.mts +0 -80
- package/dist/Markdown.mjs +0 -6
- package/dist/MarkdownContext-BN8A3W-J.mjs +0 -11
- package/dist/MarkdownContext-DSwjzpH8.cjs +0 -22
- package/dist/TextInput-6o37Zddp.cjs +0 -231
- package/dist/TextInput-D_lHYJlL.mjs +0 -224
- package/dist/ThemeProvider.cjs +0 -15
- package/dist/ThemeProvider.d.cts +0 -20
- package/dist/ThemeProvider.d.mts +0 -20
- package/dist/ThemeProvider.mjs +0 -14
- package/dist/Toolbar-B-W22Sk4.cjs +0 -459
- package/dist/Toolbar-KbR97iJS.mjs +0 -448
- package/dist/applyAction-B2B-hnP3.mjs +0 -98
- package/dist/applyAction-B2uVHxOE.cjs +0 -103
- package/dist/createTheme-Dts2F4R_.d.cts +0 -21
- package/dist/createTheme-Dts2F4R_.d.mts +0 -21
- package/dist/hooks/useCopyToClipboard.cjs +0 -33
- package/dist/hooks/useCopyToClipboard.d.cts +0 -16
- package/dist/hooks/useCopyToClipboard.d.mts +0 -16
- package/dist/hooks/useCopyToClipboard.mjs +0 -31
- package/dist/hooks.d.cts +0 -40
- package/dist/hooks.d.mts +0 -40
- package/dist/index-BPrjvi7B.d.cts +0 -13
- package/dist/index-BlfIbAMs.d.cts +0 -45
- package/dist/index-BoqlPb3Z.d.mts +0 -13
- package/dist/index-Bwi4kRpf.d.mts +0 -79
- package/dist/index-Bx24ZnOV.d.mts +0 -43
- package/dist/index-C-P_hipv.d.mts +0 -21
- package/dist/index-C5_ciaeo.d.cts +0 -79
- package/dist/index-CDcGTGR4.d.cts +0 -21
- package/dist/index-CEOZI-6L.d.mts +0 -48
- package/dist/index-CLU39rUS2.d.mts +0 -30
- package/dist/index-CM_KCTee.d.cts +0 -48
- package/dist/index-CT9uGKrs.d.cts +0 -30
- package/dist/index-CcYSvIJi.d.cts +0 -21
- package/dist/index-CdF_4ckE.d.mts +0 -11
- package/dist/index-Cl_yBpzW2.d.mts +0 -13
- package/dist/index-Cv_UOfYx.d.mts +0 -18
- package/dist/index-DBGE6yKw.d.mts +0 -16
- package/dist/index-DCQ2fsDu.d.mts +0 -40
- package/dist/index-DD2AVtiR.d.cts +0 -16
- package/dist/index-DOPXpr2J.d.cts +0 -43
- package/dist/index-DTkQSXQD.d.cts +0 -11
- package/dist/index-DeJWkpf9.d.cts +0 -16
- package/dist/index-DeiZHSwA.d.cts +0 -12
- package/dist/index-Des8BisQ.d.mts +0 -12
- package/dist/index-Dg8-CPOO.d.cts +0 -18
- package/dist/index-DgRS5Aqv.d.mts +0 -16
- package/dist/index-Dtzj8X58.d.cts +0 -40
- package/dist/index-DvW2eETV.d.mts +0 -21
- package/dist/index-GVsFY00r.d.cts +0 -21
- package/dist/index-Nqco3fsM.d.cts +0 -13
- package/dist/index-g-9DZ_KQ.d.cts +0 -28
- package/dist/index-g9EThkSg.d.mts +0 -21
- package/dist/index-kpk9e3xM2.d.mts +0 -45
- package/dist/index-u57CbuAU2.d.mts +0 -28
- package/dist/themes-D1SAp3SL.d.mts +0 -500
- package/dist/themes-D81JYbqm.d.cts +0 -500
- package/dist/themes.cjs +0 -318
- package/dist/themes.d.cts +0 -3
- package/dist/themes.d.mts +0 -3
- package/dist/useDefaultProps-Cb-5FNok.cjs +0 -19
- package/dist/useDefaultProps-CoApb4KT.mjs +0 -14
- package/dist/utils/styleCache.cjs +0 -7
- package/dist/utils/styleCache.d.cts +0 -3
- package/dist/utils/styleCache.d.mts +0 -4
- package/dist/utils/styleCache.mjs +0 -5
|
@@ -1,448 +0,0 @@
|
|
|
1
|
-
import { d as styled } from "./src-DcNT2aIK.mjs";
|
|
2
|
-
import { t as themeDefault } from "./themeDefault-CjXaY3ok.mjs";
|
|
3
|
-
import { Flex } from "./Flex.mjs";
|
|
4
|
-
import { Button } from "./Button.mjs";
|
|
5
|
-
import { ButtonGroup } from "./ButtonGroup.mjs";
|
|
6
|
-
import { Typography } from "./Typography.mjs";
|
|
7
|
-
import { t as Icon } from "./Icon-CAKRmFz3.mjs";
|
|
8
|
-
import { n as useMarkdownContext } from "./MarkdownContext-BN8A3W-J.mjs";
|
|
9
|
-
import { NativeSelect } from "./NativeSelect.mjs";
|
|
10
|
-
import { t as Popover } from "./Popover-B61J7C79.mjs";
|
|
11
|
-
import { useState } from "react";
|
|
12
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
-
//#region src/Markdown/utils/buildTableSnippet.ts
|
|
14
|
-
/**
|
|
15
|
-
* Builds a GFM table snippet with `rows` total rows (a header row plus `rows - 1` body rows)
|
|
16
|
-
* and `cols` columns, wrapped in blank lines so it sits on its own block.
|
|
17
|
-
*/
|
|
18
|
-
function buildTableSnippet(rows, cols) {
|
|
19
|
-
const row = (cell) => `| ${Array.from({ length: cols }, (_, index) => cell(index)).join(" | ")} |`;
|
|
20
|
-
return `\n${[
|
|
21
|
-
row((index) => `Column ${index + 1}`),
|
|
22
|
-
row(() => "---"),
|
|
23
|
-
...Array.from({ length: rows - 1 }, () => row(() => "Cell"))
|
|
24
|
-
].join("\n")}\n`;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/Markdown/utils/groupToolbarActions.ts
|
|
28
|
-
/**
|
|
29
|
-
* Splits actions into render segments: consecutive actions sharing a `group` id collapse into
|
|
30
|
-
* one segment (rendered as a joined `ButtonGroup`); ungrouped actions each get their own.
|
|
31
|
-
*/
|
|
32
|
-
function groupToolbarActions(actions) {
|
|
33
|
-
const segments = [];
|
|
34
|
-
actions.forEach((action) => {
|
|
35
|
-
const current = segments.at(-1);
|
|
36
|
-
if (current && action.group !== void 0 && current[0].group === action.group) current.push(action);
|
|
37
|
-
else segments.push([action]);
|
|
38
|
-
});
|
|
39
|
-
return segments;
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region src/Markdown/const.ts
|
|
43
|
-
const LIST_MARKER = /^(?:- \[[ xX]\] |- |\d+\. )/;
|
|
44
|
-
/**
|
|
45
|
-
* Every formatting action the toolbar exposes — one per markdown feature the `Markdown`
|
|
46
|
-
* renderer supports (GFM + the component map in `Markdown.Preview`). Data-driven so the
|
|
47
|
-
* toolbar and the transform logic stay in sync.
|
|
48
|
-
*/
|
|
49
|
-
const TOOLBAR_ACTIONS = [
|
|
50
|
-
{
|
|
51
|
-
id: "bold",
|
|
52
|
-
label: "B",
|
|
53
|
-
ariaLabel: "Bold",
|
|
54
|
-
emphasis: "bold",
|
|
55
|
-
group: "inline",
|
|
56
|
-
kind: "wrap",
|
|
57
|
-
prefix: "**",
|
|
58
|
-
suffix: "**",
|
|
59
|
-
placeholder: "bold text"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
id: "italic",
|
|
63
|
-
label: "I",
|
|
64
|
-
ariaLabel: "Italic",
|
|
65
|
-
emphasis: "italic",
|
|
66
|
-
group: "inline",
|
|
67
|
-
kind: "wrap",
|
|
68
|
-
prefix: "_",
|
|
69
|
-
suffix: "_",
|
|
70
|
-
placeholder: "italic text"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
id: "strikethrough",
|
|
74
|
-
label: "S",
|
|
75
|
-
ariaLabel: "Strikethrough",
|
|
76
|
-
emphasis: "strike",
|
|
77
|
-
group: "inline",
|
|
78
|
-
kind: "wrap",
|
|
79
|
-
prefix: "~~",
|
|
80
|
-
suffix: "~~",
|
|
81
|
-
placeholder: "struck text"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
id: "quote",
|
|
85
|
-
label: "Quote",
|
|
86
|
-
ariaLabel: "Blockquote",
|
|
87
|
-
icon: "format_quote",
|
|
88
|
-
kind: "linePrefix",
|
|
89
|
-
linePrefix: "> ",
|
|
90
|
-
family: /^> /
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: "ul",
|
|
94
|
-
label: "List",
|
|
95
|
-
ariaLabel: "Bulleted list",
|
|
96
|
-
icon: "format_list_bulleted",
|
|
97
|
-
group: "list",
|
|
98
|
-
kind: "linePrefix",
|
|
99
|
-
linePrefix: "- ",
|
|
100
|
-
family: LIST_MARKER
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
id: "ol",
|
|
104
|
-
label: "Ordered",
|
|
105
|
-
ariaLabel: "Numbered list",
|
|
106
|
-
icon: "format_list_numbered",
|
|
107
|
-
group: "list",
|
|
108
|
-
kind: "linePrefix",
|
|
109
|
-
linePrefix: "1. ",
|
|
110
|
-
family: LIST_MARKER
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
id: "task",
|
|
114
|
-
label: "Task",
|
|
115
|
-
ariaLabel: "Task list",
|
|
116
|
-
icon: "checklist",
|
|
117
|
-
group: "list",
|
|
118
|
-
kind: "linePrefix",
|
|
119
|
-
linePrefix: "- [ ] ",
|
|
120
|
-
family: LIST_MARKER
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
id: "link",
|
|
124
|
-
label: "Link",
|
|
125
|
-
ariaLabel: "Link",
|
|
126
|
-
icon: "link",
|
|
127
|
-
kind: "wrap",
|
|
128
|
-
prefix: "[",
|
|
129
|
-
suffix: "](url)",
|
|
130
|
-
placeholder: "link text"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
id: "image",
|
|
134
|
-
label: "Image",
|
|
135
|
-
ariaLabel: "Image",
|
|
136
|
-
icon: "image",
|
|
137
|
-
kind: "wrap",
|
|
138
|
-
prefix: "",
|
|
140
|
-
placeholder: "alt text"
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
id: "hr",
|
|
144
|
-
label: "HR",
|
|
145
|
-
ariaLabel: "Horizontal rule",
|
|
146
|
-
kind: "insert",
|
|
147
|
-
snippet: "\n\n---\n\n"
|
|
148
|
-
}
|
|
149
|
-
];
|
|
150
|
-
/** Fence languages offered by the code-block select; `value` is appended after the opening ```. */
|
|
151
|
-
const CODE_LANGUAGES = [
|
|
152
|
-
{
|
|
153
|
-
label: "Plain",
|
|
154
|
-
value: "text"
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
label: "HTML",
|
|
158
|
-
value: "html"
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
label: "CSS",
|
|
162
|
-
value: "css"
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
label: "JavaScript",
|
|
166
|
-
value: "js"
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
label: "TypeScript",
|
|
170
|
-
value: "ts"
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
label: "JSON",
|
|
174
|
-
value: "json"
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
label: "Bash",
|
|
178
|
-
value: "bash"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
label: "Python",
|
|
182
|
-
value: "python"
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
label: "Markdown",
|
|
186
|
-
value: "md"
|
|
187
|
-
}
|
|
188
|
-
];
|
|
189
|
-
/** Inline `code` — rendered next to the code-block select so both code controls sit together. */
|
|
190
|
-
const INLINE_CODE_ACTION = {
|
|
191
|
-
id: "inline-code",
|
|
192
|
-
label: "Code",
|
|
193
|
-
ariaLabel: "Inline code",
|
|
194
|
-
icon: "code",
|
|
195
|
-
kind: "wrap",
|
|
196
|
-
prefix: "`",
|
|
197
|
-
suffix: "`",
|
|
198
|
-
placeholder: "code"
|
|
199
|
-
};
|
|
200
|
-
/** Builds the fenced-code-block wrap action for a chosen `language`. */
|
|
201
|
-
const codeBlockAction = (language) => ({
|
|
202
|
-
id: "code-block",
|
|
203
|
-
label: "Code block",
|
|
204
|
-
ariaLabel: "Code block",
|
|
205
|
-
kind: "wrap",
|
|
206
|
-
prefix: `\`\`\`${language}\n`,
|
|
207
|
-
suffix: "\n```",
|
|
208
|
-
placeholder: "code",
|
|
209
|
-
block: true
|
|
210
|
-
});
|
|
211
|
-
const HEADING_MARKER = /^#{1,6} /;
|
|
212
|
-
const headingAction = (level) => ({
|
|
213
|
-
id: `h${level}`,
|
|
214
|
-
label: `H${level}`,
|
|
215
|
-
ariaLabel: `Heading ${level}`,
|
|
216
|
-
kind: "linePrefix",
|
|
217
|
-
linePrefix: `${"#".repeat(level)} `,
|
|
218
|
-
family: HEADING_MARKER,
|
|
219
|
-
toggle: false
|
|
220
|
-
});
|
|
221
|
-
/** Every heading level the `Markdown` renderer supports (h1–h6) — offered via the toolbar select. */
|
|
222
|
-
const HEADING_ACTIONS = [
|
|
223
|
-
1,
|
|
224
|
-
2,
|
|
225
|
-
3,
|
|
226
|
-
4,
|
|
227
|
-
5,
|
|
228
|
-
6
|
|
229
|
-
].map(headingAction);
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/Markdown/Toolbar/TablePicker.tsx
|
|
232
|
-
/** Smallest grid shown, and the hard cap it grows to as the hover nears the edge. */
|
|
233
|
-
const MIN_EXTENT = 8;
|
|
234
|
-
const MAX_EXTENT = 20;
|
|
235
|
-
const DEFAULT_EXTENT = {
|
|
236
|
-
rows: MIN_EXTENT,
|
|
237
|
-
cols: MIN_EXTENT
|
|
238
|
-
};
|
|
239
|
-
const growExtent = (current, hovered) => Math.min(MAX_EXTENT, Math.max(current, hovered + 1));
|
|
240
|
-
const Cell = styled("button", {
|
|
241
|
-
name: "MarkdownToolbar",
|
|
242
|
-
slot: "tablePickerCell",
|
|
243
|
-
label: "MarkdownEditorTableCell",
|
|
244
|
-
shouldForwardProp: (prop) => prop !== "isActive"
|
|
245
|
-
})(({ theme, isActive }) => ({
|
|
246
|
-
width: 16,
|
|
247
|
-
height: 16,
|
|
248
|
-
padding: 0,
|
|
249
|
-
margin: 0,
|
|
250
|
-
appearance: "none",
|
|
251
|
-
cursor: "pointer",
|
|
252
|
-
borderRadius: theme.radii.sm,
|
|
253
|
-
border: `${theme.borderWidths.thin} solid ${theme.border.light}`,
|
|
254
|
-
backgroundColor: isActive ? theme.palette[themeDefault(theme, "color", "primary")].main : theme.background[themeDefault(theme, "inputBg", "terminal")]
|
|
255
|
-
}));
|
|
256
|
-
/** A "Table" trigger that opens a hover grid for choosing table dimensions. */
|
|
257
|
-
function TablePicker({ onSelect }) {
|
|
258
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
259
|
-
const [hover, setHover] = useState({
|
|
260
|
-
rows: 0,
|
|
261
|
-
cols: 0
|
|
262
|
-
});
|
|
263
|
-
const [extent, setExtent] = useState(DEFAULT_EXTENT);
|
|
264
|
-
const open = anchorEl !== null;
|
|
265
|
-
const close = () => {
|
|
266
|
-
setAnchorEl(null);
|
|
267
|
-
setHover({
|
|
268
|
-
rows: 0,
|
|
269
|
-
cols: 0
|
|
270
|
-
});
|
|
271
|
-
setExtent(DEFAULT_EXTENT);
|
|
272
|
-
};
|
|
273
|
-
const hoverCell = (rows, cols) => {
|
|
274
|
-
setHover({
|
|
275
|
-
rows,
|
|
276
|
-
cols
|
|
277
|
-
});
|
|
278
|
-
setExtent((prev) => ({
|
|
279
|
-
rows: growExtent(prev.rows, rows),
|
|
280
|
-
cols: growExtent(prev.cols, cols)
|
|
281
|
-
}));
|
|
282
|
-
};
|
|
283
|
-
const pick = (rows, cols) => {
|
|
284
|
-
onSelect(rows, cols);
|
|
285
|
-
close();
|
|
286
|
-
};
|
|
287
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Button, {
|
|
288
|
-
type: "button",
|
|
289
|
-
variant: "outlined",
|
|
290
|
-
size: "sm",
|
|
291
|
-
"aria-label": "Table",
|
|
292
|
-
"aria-haspopup": "grid",
|
|
293
|
-
"aria-expanded": open,
|
|
294
|
-
onClick: (event) => setAnchorEl(event.currentTarget),
|
|
295
|
-
children: /* @__PURE__ */ jsx(Icon, {
|
|
296
|
-
name: "table",
|
|
297
|
-
size: "1.1rem"
|
|
298
|
-
})
|
|
299
|
-
}), /* @__PURE__ */ jsx(Popover, {
|
|
300
|
-
open,
|
|
301
|
-
anchorEl,
|
|
302
|
-
onClose: close,
|
|
303
|
-
anchorOrigin: {
|
|
304
|
-
vertical: "bottom",
|
|
305
|
-
horizontal: "left"
|
|
306
|
-
},
|
|
307
|
-
transformOrigin: {
|
|
308
|
-
vertical: "top",
|
|
309
|
-
horizontal: "left"
|
|
310
|
-
},
|
|
311
|
-
disableAriaHidden: true,
|
|
312
|
-
children: /* @__PURE__ */ jsxs(Flex, {
|
|
313
|
-
flexDirection: "column",
|
|
314
|
-
gap: 2,
|
|
315
|
-
p: 2,
|
|
316
|
-
children: [/* @__PURE__ */ jsx(Flex, {
|
|
317
|
-
flexDirection: "column",
|
|
318
|
-
gap: 1,
|
|
319
|
-
role: "grid",
|
|
320
|
-
"aria-label": "Table size",
|
|
321
|
-
children: Array.from({ length: extent.rows }, (_, r) => /* @__PURE__ */ jsx(Flex, {
|
|
322
|
-
flexDirection: "row",
|
|
323
|
-
gap: 1,
|
|
324
|
-
role: "row",
|
|
325
|
-
children: Array.from({ length: extent.cols }, (_, c) => {
|
|
326
|
-
const rows = r + 1;
|
|
327
|
-
const cols = c + 1;
|
|
328
|
-
return /* @__PURE__ */ jsx(Cell, {
|
|
329
|
-
type: "button",
|
|
330
|
-
role: "gridcell",
|
|
331
|
-
isActive: rows <= hover.rows && cols <= hover.cols,
|
|
332
|
-
"aria-label": `${rows} by ${cols}`,
|
|
333
|
-
onMouseEnter: () => hoverCell(rows, cols),
|
|
334
|
-
onFocus: () => hoverCell(rows, cols),
|
|
335
|
-
onClick: () => pick(rows, cols)
|
|
336
|
-
}, c);
|
|
337
|
-
})
|
|
338
|
-
}, r))
|
|
339
|
-
}), /* @__PURE__ */ jsx(Typography, {
|
|
340
|
-
variant: "caption",
|
|
341
|
-
color: "secondary",
|
|
342
|
-
align: "center",
|
|
343
|
-
m: 0,
|
|
344
|
-
children: hover.rows > 0 ? `${hover.rows} × ${hover.cols}` : "Select size"
|
|
345
|
-
})]
|
|
346
|
-
})
|
|
347
|
-
})] });
|
|
348
|
-
}
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/Markdown/Toolbar/Toolbar.tsx
|
|
351
|
-
const HEADING_OPTIONS = HEADING_ACTIONS.map((action) => ({
|
|
352
|
-
label: action.label,
|
|
353
|
-
value: action.id
|
|
354
|
-
}));
|
|
355
|
-
const HEADING_BY_ID = Object.fromEntries(HEADING_ACTIONS.map((action) => [action.id, action]));
|
|
356
|
-
const ToolbarRoot = styled(Flex, {
|
|
357
|
-
name: "MarkdownToolbar",
|
|
358
|
-
label: "MarkdownToolbar"
|
|
359
|
-
})();
|
|
360
|
-
const StrikeLabel = styled(Typography, {
|
|
361
|
-
name: "MarkdownToolbar",
|
|
362
|
-
slot: "strike",
|
|
363
|
-
label: "MarkdownStrike"
|
|
364
|
-
})({ textDecoration: "line-through" });
|
|
365
|
-
/** Renders a button's content: an icon, an emphasis-styled letter, or the plain label. */
|
|
366
|
-
function ActionLabel({ action }) {
|
|
367
|
-
if (action.icon) return /* @__PURE__ */ jsx(Icon, {
|
|
368
|
-
name: action.icon,
|
|
369
|
-
size: "1.1rem"
|
|
370
|
-
});
|
|
371
|
-
if (action.emphasis === "bold") return /* @__PURE__ */ jsx(Typography, {
|
|
372
|
-
as: "span",
|
|
373
|
-
variant: "inherit",
|
|
374
|
-
fontWeight: "extraBold",
|
|
375
|
-
children: action.label
|
|
376
|
-
});
|
|
377
|
-
if (action.emphasis === "italic") return /* @__PURE__ */ jsx(Typography, {
|
|
378
|
-
as: "span",
|
|
379
|
-
variant: "inherit",
|
|
380
|
-
fontStyle: "italic",
|
|
381
|
-
children: action.label
|
|
382
|
-
});
|
|
383
|
-
if (action.emphasis === "strike") return /* @__PURE__ */ jsx(StrikeLabel, {
|
|
384
|
-
as: "span",
|
|
385
|
-
variant: "inherit",
|
|
386
|
-
children: action.label
|
|
387
|
-
});
|
|
388
|
-
return /* @__PURE__ */ jsx(Fragment, { children: action.label });
|
|
389
|
-
}
|
|
390
|
-
/** Formatting buttons, heading + code-language selects, and the table-size picker. */
|
|
391
|
-
function Toolbar() {
|
|
392
|
-
const { dispatch } = useMarkdownContext();
|
|
393
|
-
const renderButton = (action) => /* @__PURE__ */ jsx(Button, {
|
|
394
|
-
type: "button",
|
|
395
|
-
variant: "outlined",
|
|
396
|
-
size: "sm",
|
|
397
|
-
"aria-label": action.ariaLabel,
|
|
398
|
-
onClick: () => dispatch(action),
|
|
399
|
-
children: /* @__PURE__ */ jsx(ActionLabel, { action })
|
|
400
|
-
}, action.id);
|
|
401
|
-
return /* @__PURE__ */ jsxs(ToolbarRoot, {
|
|
402
|
-
flexDirection: "row",
|
|
403
|
-
flexWrap: "wrap",
|
|
404
|
-
gap: 1,
|
|
405
|
-
role: "toolbar",
|
|
406
|
-
"aria-label": "Markdown formatting",
|
|
407
|
-
children: [
|
|
408
|
-
/* @__PURE__ */ jsx(NativeSelect, {
|
|
409
|
-
size: "sm",
|
|
410
|
-
variant: "outlined",
|
|
411
|
-
placeholder: "Heading",
|
|
412
|
-
value: "",
|
|
413
|
-
options: HEADING_OPTIONS,
|
|
414
|
-
onChange: (value) => dispatch(HEADING_BY_ID[String(value)]),
|
|
415
|
-
selectProps: { "aria-label": "Heading level" }
|
|
416
|
-
}),
|
|
417
|
-
groupToolbarActions(TOOLBAR_ACTIONS).map((segment) => segment.length > 1 ? /* @__PURE__ */ jsx(ButtonGroup, {
|
|
418
|
-
borderRadius: "sq",
|
|
419
|
-
size: "sm",
|
|
420
|
-
variant: "outlined",
|
|
421
|
-
children: segment.map(renderButton)
|
|
422
|
-
}, segment[0].id) : renderButton(segment[0])),
|
|
423
|
-
/* @__PURE__ */ jsx(TablePicker, { onSelect: (rows, cols) => dispatch({
|
|
424
|
-
id: "table",
|
|
425
|
-
label: "Table",
|
|
426
|
-
ariaLabel: "Table",
|
|
427
|
-
kind: "insert",
|
|
428
|
-
snippet: buildTableSnippet(rows, cols)
|
|
429
|
-
}) }),
|
|
430
|
-
/* @__PURE__ */ jsxs(Flex, {
|
|
431
|
-
flexDirection: "row",
|
|
432
|
-
gap: 0,
|
|
433
|
-
alignItems: "stretch",
|
|
434
|
-
children: [renderButton(INLINE_CODE_ACTION), /* @__PURE__ */ jsx(NativeSelect, {
|
|
435
|
-
size: "sm",
|
|
436
|
-
variant: "outlined",
|
|
437
|
-
placeholder: "Code",
|
|
438
|
-
value: "",
|
|
439
|
-
options: CODE_LANGUAGES,
|
|
440
|
-
onChange: (value) => dispatch(codeBlockAction(String(value))),
|
|
441
|
-
selectProps: { "aria-label": "Code block language" }
|
|
442
|
-
})]
|
|
443
|
-
})
|
|
444
|
-
]
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
//#endregion
|
|
448
|
-
export { TablePicker as n, Toolbar as t };
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
//#region src/Markdown/utils/applyAction.ts
|
|
2
|
-
const fusesWithMarker = (char) => !/[\s*_~`]/.test(char);
|
|
3
|
-
function stripWrap(action, { value, selectionStart, selectionEnd }) {
|
|
4
|
-
const { prefix, suffix } = action;
|
|
5
|
-
const selected = value.slice(selectionStart, selectionEnd);
|
|
6
|
-
const keep = (content) => content === action.placeholder ? "" : content;
|
|
7
|
-
if (selected.length >= prefix.length + suffix.length && selected.startsWith(prefix) && selected.endsWith(suffix)) {
|
|
8
|
-
const core = keep(selected.slice(prefix.length, selected.length - suffix.length));
|
|
9
|
-
return {
|
|
10
|
-
value: value.slice(0, selectionStart) + core + value.slice(selectionEnd),
|
|
11
|
-
selectionStart,
|
|
12
|
-
selectionEnd: selectionStart + core.length
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
if (selectionStart >= prefix.length && value.slice(selectionStart - prefix.length, selectionStart) === prefix && value.slice(selectionEnd, selectionEnd + suffix.length) === suffix) {
|
|
16
|
-
const start = selectionStart - prefix.length;
|
|
17
|
-
const core = keep(selected);
|
|
18
|
-
return {
|
|
19
|
-
value: value.slice(0, start) + core + value.slice(selectionEnd + suffix.length),
|
|
20
|
-
selectionStart: start,
|
|
21
|
-
selectionEnd: start + core.length
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
function wrapInline(action, { value, selectionStart, selectionEnd }) {
|
|
27
|
-
const selected = value.slice(selectionStart, selectionEnd);
|
|
28
|
-
const leadingLength = selected.length - selected.trimStart().length;
|
|
29
|
-
const trailingLength = selected.length - selected.trimEnd().length;
|
|
30
|
-
const core = selected.slice(leadingLength, selected.length - trailingLength) || action.placeholder;
|
|
31
|
-
let before = selected.slice(0, leadingLength);
|
|
32
|
-
if (!before && selectionStart > 0 && fusesWithMarker(value[selectionStart - 1])) before = " ";
|
|
33
|
-
let after = selected.slice(selected.length - trailingLength);
|
|
34
|
-
if (!after && selectionEnd < value.length && fusesWithMarker(value[selectionEnd])) after = " ";
|
|
35
|
-
const value_ = value.slice(0, selectionStart) + before + action.prefix + core + action.suffix + after + value.slice(selectionEnd);
|
|
36
|
-
const start = selectionStart + before.length + action.prefix.length;
|
|
37
|
-
return {
|
|
38
|
-
value: value_,
|
|
39
|
-
selectionStart: start,
|
|
40
|
-
selectionEnd: start + core.length
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function wrapBlock(action, { value, selectionStart, selectionEnd }) {
|
|
44
|
-
const core = value.slice(selectionStart, selectionEnd) || action.placeholder;
|
|
45
|
-
const before = selectionStart > 0 && value[selectionStart - 1] !== "\n" ? "\n" : "";
|
|
46
|
-
const after = selectionEnd < value.length && value[selectionEnd] !== "\n" ? "\n" : "";
|
|
47
|
-
const value_ = value.slice(0, selectionStart) + before + action.prefix + core + action.suffix + after + value.slice(selectionEnd);
|
|
48
|
-
const start = selectionStart + before.length + action.prefix.length;
|
|
49
|
-
return {
|
|
50
|
-
value: value_,
|
|
51
|
-
selectionStart: start,
|
|
52
|
-
selectionEnd: start + core.length
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function applyWrap(action, selection) {
|
|
56
|
-
if (action.block) return wrapBlock(action, selection);
|
|
57
|
-
return stripWrap(action, selection) ?? wrapInline(action, selection);
|
|
58
|
-
}
|
|
59
|
-
function toggleLinePrefix(action, line) {
|
|
60
|
-
if (!action.family) return action.linePrefix + line;
|
|
61
|
-
const existing = action.family.exec(line)?.[0] ?? "";
|
|
62
|
-
const stripped = line.slice(existing.length);
|
|
63
|
-
if (existing === action.linePrefix && action.toggle !== false) return stripped;
|
|
64
|
-
return action.linePrefix + stripped;
|
|
65
|
-
}
|
|
66
|
-
function applyLinePrefix(action, { value, selectionStart, selectionEnd }) {
|
|
67
|
-
const lineStart = selectionStart === 0 ? 0 : value.lastIndexOf("\n", selectionStart - 1) + 1;
|
|
68
|
-
const nextNewline = value.indexOf("\n", selectionEnd);
|
|
69
|
-
const lineEnd = nextNewline === -1 ? value.length : nextNewline;
|
|
70
|
-
const prefixed = value.slice(lineStart, lineEnd).split("\n").map((line) => toggleLinePrefix(action, line)).join("\n");
|
|
71
|
-
return {
|
|
72
|
-
value: value.slice(0, lineStart) + prefixed + value.slice(lineEnd),
|
|
73
|
-
selectionStart: lineStart,
|
|
74
|
-
selectionEnd: lineStart + prefixed.length
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function applyInsert(action, { value, selectionStart, selectionEnd }) {
|
|
78
|
-
const value_ = value.slice(0, selectionStart) + action.snippet + value.slice(selectionEnd);
|
|
79
|
-
const caret = selectionStart + action.snippet.length;
|
|
80
|
-
return {
|
|
81
|
-
value: value_,
|
|
82
|
-
selectionStart: caret,
|
|
83
|
-
selectionEnd: caret
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Pure transform: applies a toolbar `action` to the given selection and returns the next
|
|
88
|
-
* source plus the selection to restore around the inserted markdown. No DOM access.
|
|
89
|
-
*/
|
|
90
|
-
function applyAction(action, selection) {
|
|
91
|
-
switch (action.kind) {
|
|
92
|
-
case "wrap": return applyWrap(action, selection);
|
|
93
|
-
case "linePrefix": return applyLinePrefix(action, selection);
|
|
94
|
-
case "insert": return applyInsert(action, selection);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
export { applyAction as t };
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
//#region src/Markdown/utils/applyAction.ts
|
|
2
|
-
const fusesWithMarker = (char) => !/[\s*_~`]/.test(char);
|
|
3
|
-
function stripWrap(action, { value, selectionStart, selectionEnd }) {
|
|
4
|
-
const { prefix, suffix } = action;
|
|
5
|
-
const selected = value.slice(selectionStart, selectionEnd);
|
|
6
|
-
const keep = (content) => content === action.placeholder ? "" : content;
|
|
7
|
-
if (selected.length >= prefix.length + suffix.length && selected.startsWith(prefix) && selected.endsWith(suffix)) {
|
|
8
|
-
const core = keep(selected.slice(prefix.length, selected.length - suffix.length));
|
|
9
|
-
return {
|
|
10
|
-
value: value.slice(0, selectionStart) + core + value.slice(selectionEnd),
|
|
11
|
-
selectionStart,
|
|
12
|
-
selectionEnd: selectionStart + core.length
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
if (selectionStart >= prefix.length && value.slice(selectionStart - prefix.length, selectionStart) === prefix && value.slice(selectionEnd, selectionEnd + suffix.length) === suffix) {
|
|
16
|
-
const start = selectionStart - prefix.length;
|
|
17
|
-
const core = keep(selected);
|
|
18
|
-
return {
|
|
19
|
-
value: value.slice(0, start) + core + value.slice(selectionEnd + suffix.length),
|
|
20
|
-
selectionStart: start,
|
|
21
|
-
selectionEnd: start + core.length
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
function wrapInline(action, { value, selectionStart, selectionEnd }) {
|
|
27
|
-
const selected = value.slice(selectionStart, selectionEnd);
|
|
28
|
-
const leadingLength = selected.length - selected.trimStart().length;
|
|
29
|
-
const trailingLength = selected.length - selected.trimEnd().length;
|
|
30
|
-
const core = selected.slice(leadingLength, selected.length - trailingLength) || action.placeholder;
|
|
31
|
-
let before = selected.slice(0, leadingLength);
|
|
32
|
-
if (!before && selectionStart > 0 && fusesWithMarker(value[selectionStart - 1])) before = " ";
|
|
33
|
-
let after = selected.slice(selected.length - trailingLength);
|
|
34
|
-
if (!after && selectionEnd < value.length && fusesWithMarker(value[selectionEnd])) after = " ";
|
|
35
|
-
const value_ = value.slice(0, selectionStart) + before + action.prefix + core + action.suffix + after + value.slice(selectionEnd);
|
|
36
|
-
const start = selectionStart + before.length + action.prefix.length;
|
|
37
|
-
return {
|
|
38
|
-
value: value_,
|
|
39
|
-
selectionStart: start,
|
|
40
|
-
selectionEnd: start + core.length
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function wrapBlock(action, { value, selectionStart, selectionEnd }) {
|
|
44
|
-
const core = value.slice(selectionStart, selectionEnd) || action.placeholder;
|
|
45
|
-
const before = selectionStart > 0 && value[selectionStart - 1] !== "\n" ? "\n" : "";
|
|
46
|
-
const after = selectionEnd < value.length && value[selectionEnd] !== "\n" ? "\n" : "";
|
|
47
|
-
const value_ = value.slice(0, selectionStart) + before + action.prefix + core + action.suffix + after + value.slice(selectionEnd);
|
|
48
|
-
const start = selectionStart + before.length + action.prefix.length;
|
|
49
|
-
return {
|
|
50
|
-
value: value_,
|
|
51
|
-
selectionStart: start,
|
|
52
|
-
selectionEnd: start + core.length
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function applyWrap(action, selection) {
|
|
56
|
-
if (action.block) return wrapBlock(action, selection);
|
|
57
|
-
return stripWrap(action, selection) ?? wrapInline(action, selection);
|
|
58
|
-
}
|
|
59
|
-
function toggleLinePrefix(action, line) {
|
|
60
|
-
if (!action.family) return action.linePrefix + line;
|
|
61
|
-
const existing = action.family.exec(line)?.[0] ?? "";
|
|
62
|
-
const stripped = line.slice(existing.length);
|
|
63
|
-
if (existing === action.linePrefix && action.toggle !== false) return stripped;
|
|
64
|
-
return action.linePrefix + stripped;
|
|
65
|
-
}
|
|
66
|
-
function applyLinePrefix(action, { value, selectionStart, selectionEnd }) {
|
|
67
|
-
const lineStart = selectionStart === 0 ? 0 : value.lastIndexOf("\n", selectionStart - 1) + 1;
|
|
68
|
-
const nextNewline = value.indexOf("\n", selectionEnd);
|
|
69
|
-
const lineEnd = nextNewline === -1 ? value.length : nextNewline;
|
|
70
|
-
const prefixed = value.slice(lineStart, lineEnd).split("\n").map((line) => toggleLinePrefix(action, line)).join("\n");
|
|
71
|
-
return {
|
|
72
|
-
value: value.slice(0, lineStart) + prefixed + value.slice(lineEnd),
|
|
73
|
-
selectionStart: lineStart,
|
|
74
|
-
selectionEnd: lineStart + prefixed.length
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function applyInsert(action, { value, selectionStart, selectionEnd }) {
|
|
78
|
-
const value_ = value.slice(0, selectionStart) + action.snippet + value.slice(selectionEnd);
|
|
79
|
-
const caret = selectionStart + action.snippet.length;
|
|
80
|
-
return {
|
|
81
|
-
value: value_,
|
|
82
|
-
selectionStart: caret,
|
|
83
|
-
selectionEnd: caret
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Pure transform: applies a toolbar `action` to the given selection and returns the next
|
|
88
|
-
* source plus the selection to restore around the inserted markdown. No DOM access.
|
|
89
|
-
*/
|
|
90
|
-
function applyAction(action, selection) {
|
|
91
|
-
switch (action.kind) {
|
|
92
|
-
case "wrap": return applyWrap(action, selection);
|
|
93
|
-
case "linePrefix": return applyLinePrefix(action, selection);
|
|
94
|
-
case "insert": return applyInsert(action, selection);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//#endregion
|
|
98
|
-
Object.defineProperty(exports, "applyAction", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: function() {
|
|
101
|
-
return applyAction;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Theme } from "@emotion/react";
|
|
2
|
-
//#region src/utils/createTheme.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Recursive partial of a theme shape. Plain objects recurse; arrays and
|
|
5
|
-
* functions are replaced wholesale by `createTheme`, so they stay intact here.
|
|
6
|
-
*/
|
|
7
|
-
type DeepPartial<T> = { [K in keyof T]?: T[K] extends readonly unknown[] ? T[K] : T[K] extends ((...args: never[]) => unknown) ? T[K] : T[K] extends object ? DeepPartial<T[K]> : T[K]; };
|
|
8
|
-
/** Sparse theme patch accepted by `createTheme` and `ThemeProvider`'s `themes` prop. */
|
|
9
|
-
type ThemeOverride = DeepPartial<Theme>;
|
|
10
|
-
/**
|
|
11
|
-
* Builds a theme by deep-merging sparse `overrides` onto `base`.
|
|
12
|
-
*
|
|
13
|
-
* - Recurses only where both sides are plain objects; arrays (`shadows`,
|
|
14
|
-
* `fontSizes`) and functions replace wholesale.
|
|
15
|
-
* - `undefined` override values are ignored — a key can be added or replaced,
|
|
16
|
-
* never removed.
|
|
17
|
-
* - Neither argument is mutated; untouched branches keep referential identity.
|
|
18
|
-
*/
|
|
19
|
-
declare const createTheme: (base: Theme, overrides: ThemeOverride) => Theme;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { ThemeOverride as n, createTheme as r, DeepPartial as t };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Theme } from "@emotion/react";
|
|
2
|
-
//#region src/utils/createTheme.d.ts
|
|
3
|
-
/**
|
|
4
|
-
* Recursive partial of a theme shape. Plain objects recurse; arrays and
|
|
5
|
-
* functions are replaced wholesale by `createTheme`, so they stay intact here.
|
|
6
|
-
*/
|
|
7
|
-
type DeepPartial<T> = { [K in keyof T]?: T[K] extends readonly unknown[] ? T[K] : T[K] extends ((...args: never[]) => unknown) ? T[K] : T[K] extends object ? DeepPartial<T[K]> : T[K]; };
|
|
8
|
-
/** Sparse theme patch accepted by `createTheme` and `ThemeProvider`'s `themes` prop. */
|
|
9
|
-
type ThemeOverride = DeepPartial<Theme>;
|
|
10
|
-
/**
|
|
11
|
-
* Builds a theme by deep-merging sparse `overrides` onto `base`.
|
|
12
|
-
*
|
|
13
|
-
* - Recurses only where both sides are plain objects; arrays (`shadows`,
|
|
14
|
-
* `fontSizes`) and functions replace wholesale.
|
|
15
|
-
* - `undefined` override values are ignored — a key can be added or replaced,
|
|
16
|
-
* never removed.
|
|
17
|
-
* - Neither argument is mutated; untouched branches keep referential identity.
|
|
18
|
-
*/
|
|
19
|
-
declare const createTheme: (base: Theme, overrides: ThemeOverride) => Theme;
|
|
20
|
-
//#endregion
|
|
21
|
-
export { ThemeOverride as n, createTheme as r, DeepPartial as t };
|