@soroush.tech/design-system 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +278 -0
- package/dist/AppBar.cjs +71 -0
- package/dist/AppBar.d.cts +23 -0
- package/dist/AppBar.d.mts +23 -0
- package/dist/AppBar.mjs +69 -0
- package/dist/Avatar.cjs +106 -0
- package/dist/Avatar.d.cts +28 -0
- package/dist/Avatar.d.mts +28 -0
- package/dist/Avatar.mjs +103 -0
- package/dist/Backdrop.cjs +26 -0
- package/dist/Backdrop.d.cts +10 -0
- package/dist/Backdrop.d.mts +10 -0
- package/dist/Backdrop.mjs +25 -0
- package/dist/Button.cjs +178 -0
- package/dist/Button.d.cts +2 -0
- package/dist/Button.d.mts +2 -0
- package/dist/Button.mjs +175 -0
- package/dist/ButtonGroup.cjs +110 -0
- package/dist/ButtonGroup.d.cts +2 -0
- package/dist/ButtonGroup.d.mts +2 -0
- package/dist/ButtonGroup.mjs +107 -0
- package/dist/ButtonGroupContext-DS-kl9lG.mjs +5 -0
- package/dist/ButtonGroupContext-NtkVeDVE.cjs +9 -0
- package/dist/Card.cjs +95 -0
- package/dist/Card.d.cts +18 -0
- package/dist/Card.d.mts +18 -0
- package/dist/Card.mjs +93 -0
- package/dist/Checkbox.cjs +192 -0
- package/dist/Checkbox.d.cts +2 -0
- package/dist/Checkbox.d.mts +2 -0
- package/dist/Checkbox.mjs +190 -0
- package/dist/CircularProgress.cjs +136 -0
- package/dist/CircularProgress.d.cts +34 -0
- package/dist/CircularProgress.d.mts +34 -0
- package/dist/CircularProgress.mjs +133 -0
- package/dist/CodeBlock.cjs +101 -0
- package/dist/CodeBlock.d.cts +2 -0
- package/dist/CodeBlock.d.mts +2 -0
- package/dist/CodeBlock.mjs +100 -0
- package/dist/Drawer.cjs +69 -0
- package/dist/Drawer.d.cts +22 -0
- package/dist/Drawer.d.mts +22 -0
- package/dist/Drawer.mjs +66 -0
- package/dist/Field.cjs +59 -0
- package/dist/Field.d.cts +36 -0
- package/dist/Field.d.mts +36 -0
- package/dist/Field.mjs +58 -0
- package/dist/Flex.cjs +21 -0
- package/dist/Flex.d.cts +2 -0
- package/dist/Flex.d.mts +2 -0
- package/dist/Flex.mjs +19 -0
- package/dist/FocusTrap.cjs +82 -0
- package/dist/FocusTrap.d.cts +24 -0
- package/dist/FocusTrap.d.mts +24 -0
- package/dist/FocusTrap.mjs +81 -0
- package/dist/Form.cjs +44 -0
- package/dist/Form.d.cts +41 -0
- package/dist/Form.d.mts +41 -0
- package/dist/Form.mjs +42 -0
- package/dist/FormContext-CRmRgDgu.cjs +10 -0
- package/dist/FormContext-_G3sxJyQ.mjs +6 -0
- package/dist/FormControl.cjs +84 -0
- package/dist/FormControl.d.cts +78 -0
- package/dist/FormControl.d.mts +78 -0
- package/dist/FormControl.mjs +81 -0
- package/dist/FormControlContext-CyxdOxdN.mjs +6 -0
- package/dist/FormControlContext-aeKTjRKY.cjs +10 -0
- package/dist/FormHelperText.cjs +40 -0
- package/dist/FormHelperText.d.cts +16 -0
- package/dist/FormHelperText.d.mts +16 -0
- package/dist/FormHelperText.mjs +39 -0
- package/dist/FormLabel.cjs +34 -0
- package/dist/FormLabel.d.cts +2 -0
- package/dist/FormLabel.d.mts +2 -0
- package/dist/FormLabel.mjs +33 -0
- package/dist/Grid.cjs +37 -0
- package/dist/Grid.d.cts +21 -0
- package/dist/Grid.d.mts +21 -0
- package/dist/Grid.mjs +32 -0
- package/dist/Icon-1YtNCUKo.cjs +755 -0
- package/dist/Icon-CAKRmFz3.mjs +742 -0
- package/dist/Icon.cjs +4 -0
- package/dist/Icon.d.cts +2 -0
- package/dist/Icon.d.mts +2 -0
- package/dist/Icon.mjs +2 -0
- package/dist/Image.cjs +82 -0
- package/dist/Image.d.cts +2 -0
- package/dist/Image.d.mts +2 -0
- package/dist/Image.mjs +80 -0
- package/dist/LinearProgress.cjs +217 -0
- package/dist/LinearProgress.d.cts +36 -0
- package/dist/LinearProgress.d.mts +36 -0
- package/dist/LinearProgress.mjs +214 -0
- package/dist/Link.cjs +64 -0
- package/dist/Link.d.cts +2 -0
- package/dist/Link.d.mts +2 -0
- package/dist/Link.mjs +62 -0
- package/dist/Markdown/Control.cjs +61 -0
- package/dist/Markdown/Control.d.cts +18 -0
- package/dist/Markdown/Control.d.mts +18 -0
- package/dist/Markdown/Control.mjs +60 -0
- package/dist/Markdown/Editor.cjs +130 -0
- package/dist/Markdown/Editor.d.cts +40 -0
- package/dist/Markdown/Editor.d.mts +40 -0
- package/dist/Markdown/Editor.mjs +128 -0
- package/dist/Markdown/Preview.cjs +241 -0
- package/dist/Markdown/Preview.d.cts +55 -0
- package/dist/Markdown/Preview.d.mts +55 -0
- package/dist/Markdown/Preview.mjs +236 -0
- package/dist/Markdown/Toolbar.cjs +4 -0
- package/dist/Markdown/Toolbar.d.cts +13 -0
- package/dist/Markdown/Toolbar.d.mts +13 -0
- package/dist/Markdown/Toolbar.mjs +2 -0
- package/dist/Markdown.cjs +13 -0
- package/dist/Markdown.d.cts +80 -0
- package/dist/Markdown.d.mts +80 -0
- package/dist/Markdown.mjs +6 -0
- package/dist/MarkdownContext-BN8A3W-J.mjs +11 -0
- package/dist/MarkdownContext-DSwjzpH8.cjs +22 -0
- package/dist/MenuItem.cjs +150 -0
- package/dist/MenuItem.d.cts +51 -0
- package/dist/MenuItem.d.mts +51 -0
- package/dist/MenuItem.mjs +147 -0
- package/dist/Modal-BDMPTSXv.cjs +351 -0
- package/dist/Modal-DR60peRg.mjs +327 -0
- package/dist/Modal.cjs +6 -0
- package/dist/Modal.d.cts +2 -0
- package/dist/Modal.d.mts +2 -0
- package/dist/Modal.mjs +2 -0
- package/dist/NativeSelect.cjs +189 -0
- package/dist/NativeSelect.d.cts +62 -0
- package/dist/NativeSelect.d.mts +62 -0
- package/dist/NativeSelect.mjs +186 -0
- package/dist/Pagination/PaginationItem.cjs +116 -0
- package/dist/Pagination/PaginationItem.d.cts +2 -0
- package/dist/Pagination/PaginationItem.d.mts +2 -0
- package/dist/Pagination/PaginationItem.mjs +114 -0
- package/dist/Pagination.cjs +134 -0
- package/dist/Pagination.d.cts +23 -0
- package/dist/Pagination.d.mts +23 -0
- package/dist/Pagination.mjs +130 -0
- package/dist/Paper.cjs +51 -0
- package/dist/Paper.d.cts +2 -0
- package/dist/Paper.d.mts +2 -0
- package/dist/Paper.mjs +48 -0
- package/dist/Popover-B61J7C79.mjs +252 -0
- package/dist/Popover-CRDLmywF.cjs +259 -0
- package/dist/Popover.cjs +3 -0
- package/dist/Popover.d.cts +84 -0
- package/dist/Popover.d.mts +84 -0
- package/dist/Popover.mjs +2 -0
- package/dist/Portal.cjs +20 -0
- package/dist/Portal.d.cts +18 -0
- package/dist/Portal.d.mts +18 -0
- package/dist/Portal.mjs +19 -0
- package/dist/Quote.cjs +11 -0
- package/dist/Quote.d.cts +2 -0
- package/dist/Quote.d.mts +2 -0
- package/dist/Quote.mjs +10 -0
- package/dist/Radio.cjs +143 -0
- package/dist/Radio.d.cts +38 -0
- package/dist/Radio.d.mts +38 -0
- package/dist/Radio.mjs +141 -0
- package/dist/Select.cjs +528 -0
- package/dist/Select.d.cts +68 -0
- package/dist/Select.d.mts +68 -0
- package/dist/Select.mjs +525 -0
- package/dist/Skeleton.cjs +82 -0
- package/dist/Skeleton.d.cts +21 -0
- package/dist/Skeleton.d.mts +21 -0
- package/dist/Skeleton.mjs +79 -0
- package/dist/Switch.cjs +332 -0
- package/dist/Switch.d.cts +40 -0
- package/dist/Switch.d.mts +40 -0
- package/dist/Switch.mjs +329 -0
- package/dist/Table/Table.cjs +65 -0
- package/dist/Table/Table.d.cts +2 -0
- package/dist/Table/Table.d.mts +2 -0
- package/dist/Table/Table.mjs +63 -0
- package/dist/Table/TableBody.cjs +42 -0
- package/dist/Table/TableBody.d.cts +2 -0
- package/dist/Table/TableBody.d.mts +2 -0
- package/dist/Table/TableBody.mjs +40 -0
- package/dist/Table/TableCell.cjs +93 -0
- package/dist/Table/TableCell.d.cts +2 -0
- package/dist/Table/TableCell.d.mts +2 -0
- package/dist/Table/TableCell.mjs +91 -0
- package/dist/Table/TableContainer.cjs +15 -0
- package/dist/Table/TableContainer.d.cts +2 -0
- package/dist/Table/TableContainer.d.mts +2 -0
- package/dist/Table/TableContainer.mjs +14 -0
- package/dist/Table/TableControl.cjs +42 -0
- package/dist/Table/TableControl.d.cts +2 -0
- package/dist/Table/TableControl.d.mts +2 -0
- package/dist/Table/TableControl.mjs +41 -0
- package/dist/Table/TableFooter.cjs +42 -0
- package/dist/Table/TableFooter.d.cts +2 -0
- package/dist/Table/TableFooter.d.mts +2 -0
- package/dist/Table/TableFooter.mjs +40 -0
- package/dist/Table/TableHead.cjs +42 -0
- package/dist/Table/TableHead.d.cts +2 -0
- package/dist/Table/TableHead.d.mts +2 -0
- package/dist/Table/TableHead.mjs +40 -0
- package/dist/Table/TablePagination.cjs +89 -0
- package/dist/Table/TablePagination.d.cts +2 -0
- package/dist/Table/TablePagination.d.mts +2 -0
- package/dist/Table/TablePagination.mjs +88 -0
- package/dist/Table/TablePaginationActions.cjs +65 -0
- package/dist/Table/TablePaginationActions.d.cts +2 -0
- package/dist/Table/TablePaginationActions.d.mts +2 -0
- package/dist/Table/TablePaginationActions.mjs +63 -0
- package/dist/Table/TableRow.cjs +56 -0
- package/dist/Table/TableRow.d.cts +2 -0
- package/dist/Table/TableRow.d.mts +2 -0
- package/dist/Table/TableRow.mjs +54 -0
- package/dist/Table/TableSortLabel.cjs +62 -0
- package/dist/Table/TableSortLabel.d.cts +2 -0
- package/dist/Table/TableSortLabel.d.mts +2 -0
- package/dist/Table/TableSortLabel.mjs +60 -0
- package/dist/Table/hooks.cjs +112 -0
- package/dist/Table/hooks.d.cts +3 -0
- package/dist/Table/hooks.d.mts +3 -0
- package/dist/Table/hooks.mjs +109 -0
- package/dist/Table.cjs +31 -0
- package/dist/Table.d.cts +16 -0
- package/dist/Table.d.mts +16 -0
- package/dist/Table.mjs +15 -0
- package/dist/TableContext-2qH7XYJB.d.cts +19 -0
- package/dist/TableContext-2qH7XYJB.d.mts +19 -0
- package/dist/TableContext-BRWPghAI.mjs +6 -0
- package/dist/TableContext-qqp35o8z.cjs +10 -0
- package/dist/TableSectionContext-meIG4lFZ.mjs +5 -0
- package/dist/TableSectionContext-pYlJ-duI.cjs +9 -0
- package/dist/TextInput-6o37Zddp.cjs +231 -0
- package/dist/TextInput-D_lHYJlL.mjs +224 -0
- package/dist/TextInput.cjs +3 -0
- package/dist/TextInput.d.cts +2 -0
- package/dist/TextInput.d.mts +2 -0
- package/dist/TextInput.mjs +2 -0
- package/dist/ThemeProvider.cjs +15 -0
- package/dist/ThemeProvider.d.cts +20 -0
- package/dist/ThemeProvider.d.mts +20 -0
- package/dist/ThemeProvider.mjs +14 -0
- package/dist/ToggleButton/ToggleButton.cjs +58 -0
- package/dist/ToggleButton/ToggleButton.d.cts +14 -0
- package/dist/ToggleButton/ToggleButton.d.mts +14 -0
- package/dist/ToggleButton/ToggleButton.mjs +56 -0
- package/dist/ToggleButton/ToggleButtonGroup.cjs +54 -0
- package/dist/ToggleButton/ToggleButtonGroup.d.cts +23 -0
- package/dist/ToggleButton/ToggleButtonGroup.d.mts +23 -0
- package/dist/ToggleButton/ToggleButtonGroup.mjs +52 -0
- package/dist/ToggleButton.cjs +7 -0
- package/dist/ToggleButton.d.cts +4 -0
- package/dist/ToggleButton.d.mts +4 -0
- package/dist/ToggleButton.mjs +4 -0
- package/dist/ToggleButtonGroupContext-CqD-Afho.d.cts +15 -0
- package/dist/ToggleButtonGroupContext-CqD-Afho.d.mts +15 -0
- package/dist/ToggleButtonGroupContext-DxIyy8ze.mjs +5 -0
- package/dist/ToggleButtonGroupContext-Ewc5Ixas.cjs +9 -0
- package/dist/Toolbar-B-W22Sk4.cjs +459 -0
- package/dist/Toolbar-KbR97iJS.mjs +448 -0
- package/dist/Typography.cjs +64 -0
- package/dist/Typography.d.cts +3 -0
- package/dist/Typography.d.mts +3 -0
- package/dist/Typography.mjs +61 -0
- package/dist/View.cjs +40 -0
- package/dist/View.d.cts +2 -0
- package/dist/View.d.mts +2 -0
- package/dist/View.mjs +38 -0
- package/dist/applyAction-B2B-hnP3.mjs +98 -0
- package/dist/applyAction-B2uVHxOE.cjs +103 -0
- package/dist/createTheme-Dts2F4R_.d.cts +21 -0
- package/dist/createTheme-Dts2F4R_.d.mts +21 -0
- package/dist/hooks/useCopyToClipboard.cjs +33 -0
- package/dist/hooks/useCopyToClipboard.d.cts +16 -0
- package/dist/hooks/useCopyToClipboard.d.mts +16 -0
- package/dist/hooks/useCopyToClipboard.mjs +31 -0
- package/dist/hooks.cjs +52 -0
- package/dist/hooks.d.cts +40 -0
- package/dist/hooks.d.mts +40 -0
- package/dist/hooks.mjs +41 -0
- package/dist/index-4rC2j7fR.d.cts +46 -0
- package/dist/index-8dzWTpFp.d.cts +24 -0
- package/dist/index-B1rCD6Oo.d.cts +17 -0
- package/dist/index-BH8jQOdF.d.mts +46 -0
- package/dist/index-BLRMuO_x.d.mts +24 -0
- package/dist/index-BLfFycfJ.d.mts +72 -0
- package/dist/index-BPrjvi7B.d.cts +13 -0
- package/dist/index-BX5-NfbX.d.cts +94 -0
- package/dist/index-Bihpwn75.d.cts +64 -0
- package/dist/index-BlfIbAMs.d.cts +45 -0
- package/dist/index-BnzUumAC2.d.mts +30 -0
- package/dist/index-BoqlPb3Z.d.mts +13 -0
- package/dist/index-BqVgv2B_.d.mts +42 -0
- package/dist/index-Bwi4kRpf.d.mts +79 -0
- package/dist/index-Bx24ZnOV.d.mts +43 -0
- package/dist/index-C-P_hipv.d.mts +21 -0
- package/dist/index-C0xMvDjL.d.mts +49 -0
- package/dist/index-C5_ciaeo.d.cts +79 -0
- package/dist/index-CDVnvjIE.d.cts +27 -0
- package/dist/index-CDcGTGR4.d.cts +21 -0
- package/dist/index-CEOZI-6L.d.mts +48 -0
- package/dist/index-CLU39rUS2.d.mts +30 -0
- package/dist/index-CM_KCTee.d.cts +48 -0
- package/dist/index-CT9uGKrs.d.cts +30 -0
- package/dist/index-CcYSvIJi.d.cts +21 -0
- package/dist/index-CdF_4ckE.d.mts +11 -0
- package/dist/index-CeYkEXU2.d.cts +68 -0
- package/dist/index-Cl_yBpzW2.d.mts +13 -0
- package/dist/index-Cv_UOfYx.d.mts +18 -0
- package/dist/index-CxSNNzBT2.d.mts +68 -0
- package/dist/index-CyZYXDn0.d.cts +42 -0
- package/dist/index-DASvoACZ.d.cts +49 -0
- package/dist/index-DBGE6yKw.d.mts +16 -0
- package/dist/index-DCQ2fsDu.d.mts +40 -0
- package/dist/index-DD2AVtiR.d.cts +16 -0
- package/dist/index-DE5PtzPn.d.mts +27 -0
- package/dist/index-DOPXpr2J.d.cts +43 -0
- package/dist/index-DSCMXFTn.d.cts +30 -0
- package/dist/index-DTkQSXQD.d.cts +11 -0
- package/dist/index-DeJWkpf9.d.cts +16 -0
- package/dist/index-DeiZHSwA.d.cts +12 -0
- package/dist/index-Des8BisQ.d.mts +12 -0
- package/dist/index-Dg8-CPOO.d.cts +18 -0
- package/dist/index-DgRS5Aqv.d.mts +16 -0
- package/dist/index-Dm9HfgV6.d.mts +63 -0
- package/dist/index-DmJIuQJj.d.mts +24 -0
- package/dist/index-Dp81rWM1.d.cts +72 -0
- package/dist/index-Dtzj8X58.d.cts +40 -0
- package/dist/index-DvW2eETV.d.mts +21 -0
- package/dist/index-Dy03o__A.d.mts +94 -0
- package/dist/index-FwTocqhP.d.cts +34 -0
- package/dist/index-GVsFY00r.d.cts +21 -0
- package/dist/index-Nqco3fsM.d.cts +13 -0
- package/dist/index-g-9DZ_KQ.d.cts +28 -0
- package/dist/index-g9EThkSg.d.mts +21 -0
- package/dist/index-kpk9e3xM2.d.mts +45 -0
- package/dist/index-pX7tBQdJ.d.mts +34 -0
- package/dist/index-u57CbuAU2.d.mts +28 -0
- package/dist/index-x80UG39F.d.cts +24 -0
- package/dist/index-z35LEYG8.d.mts +17 -0
- package/dist/index.cjs +68 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +3 -0
- package/dist/inputVariantStyles-BBkkYQtE.cjs +32 -0
- package/dist/inputVariantStyles-CcqpGfuP.mjs +28 -0
- package/dist/rolldown-runtime-BBjsoOtd.mjs +27 -0
- package/dist/rolldown-runtime-DDXJien1.cjs +50 -0
- package/dist/src-BiocWFSR.cjs +60 -0
- package/dist/src-DcNT2aIK.mjs +49 -0
- package/dist/themeDefault-B-QjpGEO.cjs +16 -0
- package/dist/themeDefault-CjXaY3ok.mjs +11 -0
- package/dist/themes-D1SAp3SL.d.mts +500 -0
- package/dist/themes-D81JYbqm.d.cts +500 -0
- package/dist/themes.cjs +318 -0
- package/dist/themes.d.cts +3 -0
- package/dist/themes.d.mts +3 -0
- package/dist/themes.mjs +303 -0
- package/dist/useDefaultProps-Cb-5FNok.cjs +19 -0
- package/dist/useDefaultProps-CoApb4KT.mjs +14 -0
- package/dist/useTableSort--XMWjujs.d.cts +51 -0
- package/dist/useTableSort-CpDs4cGq.d.mts +51 -0
- package/dist/utils/styleCache.cjs +7 -0
- package/dist/utils/styleCache.d.cts +3 -0
- package/dist/utils/styleCache.d.mts +4 -0
- package/dist/utils/styleCache.mjs +5 -0
- package/dist/utils.cjs +65 -0
- package/dist/utils.d.cts +39 -0
- package/dist/utils.d.mts +39 -0
- package/dist/utils.mjs +58 -0
- package/package.json +125 -0
|
@@ -0,0 +1,98 @@
|
|
|
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 };
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
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 };
|
|
@@ -0,0 +1,21 @@
|
|
|
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 };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let react = require("react");
|
|
3
|
+
//#region src/hooks/useCopyToClipboard.ts
|
|
4
|
+
/** How long the "copied" confirmation stays true before reverting, in ms. */
|
|
5
|
+
const COPIED_RESET_MS = 2e3;
|
|
6
|
+
/**
|
|
7
|
+
* Copy-to-clipboard with a transient `copied` flag. Guards the unavailable
|
|
8
|
+
* clipboard API and rejected writes so the caller never throws or gets stuck.
|
|
9
|
+
*/
|
|
10
|
+
function useCopyToClipboard(resetMs = COPIED_RESET_MS) {
|
|
11
|
+
const [copied, setCopied] = (0, react.useState)(false);
|
|
12
|
+
const timerRef = (0, react.useRef)(null);
|
|
13
|
+
(0, react.useEffect)(() => () => {
|
|
14
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
15
|
+
}, []);
|
|
16
|
+
return {
|
|
17
|
+
copied,
|
|
18
|
+
copy: (0, react.useCallback)((text) => {
|
|
19
|
+
if (!navigator.clipboard?.writeText) return;
|
|
20
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
21
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
22
|
+
setCopied(true);
|
|
23
|
+
timerRef.current = setTimeout(() => {
|
|
24
|
+
setCopied(false);
|
|
25
|
+
timerRef.current = null;
|
|
26
|
+
}, resetMs);
|
|
27
|
+
}).catch(() => {});
|
|
28
|
+
}, [resetMs])
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.COPIED_RESET_MS = COPIED_RESET_MS;
|
|
33
|
+
exports.useCopyToClipboard = useCopyToClipboard;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/hooks/useCopyToClipboard.d.ts
|
|
2
|
+
/** How long the "copied" confirmation stays true before reverting, in ms. */
|
|
3
|
+
declare const COPIED_RESET_MS = 2000;
|
|
4
|
+
interface UseCopyToClipboardResult {
|
|
5
|
+
/** `true` for `resetMs` after a successful copy, then back to `false`. */
|
|
6
|
+
copied: boolean;
|
|
7
|
+
/** Copy `text` to the clipboard; a no-op in insecure/unsupported contexts. */
|
|
8
|
+
copy: (text: string) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Copy-to-clipboard with a transient `copied` flag. Guards the unavailable
|
|
12
|
+
* clipboard API and rejected writes so the caller never throws or gets stuck.
|
|
13
|
+
*/
|
|
14
|
+
declare function useCopyToClipboard(resetMs?: number): UseCopyToClipboardResult;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { COPIED_RESET_MS, UseCopyToClipboardResult, useCopyToClipboard };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/hooks/useCopyToClipboard.d.ts
|
|
2
|
+
/** How long the "copied" confirmation stays true before reverting, in ms. */
|
|
3
|
+
declare const COPIED_RESET_MS = 2000;
|
|
4
|
+
interface UseCopyToClipboardResult {
|
|
5
|
+
/** `true` for `resetMs` after a successful copy, then back to `false`. */
|
|
6
|
+
copied: boolean;
|
|
7
|
+
/** Copy `text` to the clipboard; a no-op in insecure/unsupported contexts. */
|
|
8
|
+
copy: (text: string) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Copy-to-clipboard with a transient `copied` flag. Guards the unavailable
|
|
12
|
+
* clipboard API and rejected writes so the caller never throws or gets stuck.
|
|
13
|
+
*/
|
|
14
|
+
declare function useCopyToClipboard(resetMs?: number): UseCopyToClipboardResult;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { COPIED_RESET_MS, UseCopyToClipboardResult, useCopyToClipboard };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
//#region src/hooks/useCopyToClipboard.ts
|
|
3
|
+
/** How long the "copied" confirmation stays true before reverting, in ms. */
|
|
4
|
+
const COPIED_RESET_MS = 2e3;
|
|
5
|
+
/**
|
|
6
|
+
* Copy-to-clipboard with a transient `copied` flag. Guards the unavailable
|
|
7
|
+
* clipboard API and rejected writes so the caller never throws or gets stuck.
|
|
8
|
+
*/
|
|
9
|
+
function useCopyToClipboard(resetMs = COPIED_RESET_MS) {
|
|
10
|
+
const [copied, setCopied] = useState(false);
|
|
11
|
+
const timerRef = useRef(null);
|
|
12
|
+
useEffect(() => () => {
|
|
13
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
14
|
+
}, []);
|
|
15
|
+
return {
|
|
16
|
+
copied,
|
|
17
|
+
copy: useCallback((text) => {
|
|
18
|
+
if (!navigator.clipboard?.writeText) return;
|
|
19
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
20
|
+
if (timerRef.current) clearTimeout(timerRef.current);
|
|
21
|
+
setCopied(true);
|
|
22
|
+
timerRef.current = setTimeout(() => {
|
|
23
|
+
setCopied(false);
|
|
24
|
+
timerRef.current = null;
|
|
25
|
+
}, resetMs);
|
|
26
|
+
}).catch(() => {});
|
|
27
|
+
}, [resetMs])
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { COPIED_RESET_MS, useCopyToClipboard };
|
package/dist/hooks.cjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_useDefaultProps = require("./useDefaultProps-Cb-5FNok.cjs");
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
let _emotion_react = require("@emotion/react");
|
|
5
|
+
//#region src/hooks/useStyle.ts
|
|
6
|
+
function useStyle(style) {
|
|
7
|
+
const theme = (0, _emotion_react.useTheme)();
|
|
8
|
+
return typeof style.getStyles === "function" ? style.getStyles(theme) : style;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/hooks/StylesConsumer.tsx
|
|
12
|
+
function StylesConsumer({ style, children }) {
|
|
13
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_emotion_react.ThemeContext.Consumer, { children: (theme) => children(style.getStyles(theme)) });
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/hooks/withStyles.tsx
|
|
17
|
+
function withStyles(style) {
|
|
18
|
+
return (WrappedComponent) => function WithStyles(props) {
|
|
19
|
+
return typeof style.getStyles === "function" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StylesConsumer, {
|
|
20
|
+
style,
|
|
21
|
+
children: (styles) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrappedComponent, {
|
|
22
|
+
...props,
|
|
23
|
+
styles
|
|
24
|
+
})
|
|
25
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrappedComponent, {
|
|
26
|
+
...props,
|
|
27
|
+
styles: style
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/hooks/withTheme.tsx
|
|
33
|
+
function withTheme(WrappedComponent) {
|
|
34
|
+
return function WithTheme(props) {
|
|
35
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_emotion_react.ThemeContext.Consumer, { children: (theme) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WrappedComponent, {
|
|
36
|
+
...props,
|
|
37
|
+
theme
|
|
38
|
+
}) });
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.StylesConsumer = StylesConsumer;
|
|
43
|
+
exports.useDefaultProps = require_useDefaultProps.useDefaultProps;
|
|
44
|
+
exports.useStyle = useStyle;
|
|
45
|
+
Object.defineProperty(exports, "useTheme", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
get: function() {
|
|
48
|
+
return _emotion_react.useTheme;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
exports.withStyles = withStyles;
|
|
52
|
+
exports.withTheme = withTheme;
|
package/dist/hooks.d.cts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { f as useTheme, t as CSSObject$1 } from "./index-Bihpwn75.cjs";
|
|
2
|
+
import { f as Theme$1 } from "./themes-D81JYbqm.cjs";
|
|
3
|
+
import { ThemeComponents } from "@emotion/react";
|
|
4
|
+
import { ComponentType, ReactNode } from "react";
|
|
5
|
+
//#region src/hooks/useDefaultProps.d.ts
|
|
6
|
+
type DefaultPropsOf<N extends keyof ThemeComponents> = NonNullable<NonNullable<ThemeComponents[N]>['defaultProps']>;
|
|
7
|
+
/**
|
|
8
|
+
* The theme-contributed default prop values for a component
|
|
9
|
+
* (`theme.components[name].defaultProps`), or an empty object.
|
|
10
|
+
*
|
|
11
|
+
* Components apply it as one step of the default-resolution chain:
|
|
12
|
+
* explicit prop → group context → `useDefaultProps` → `theme.defaults.*` → literal fallback.
|
|
13
|
+
*/
|
|
14
|
+
declare function useDefaultProps<N extends keyof ThemeComponents>(name: N): DefaultPropsOf<N>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/hooks/useStyle.d.ts
|
|
17
|
+
type StyleFactory = {
|
|
18
|
+
getStyles: (theme: Theme$1) => CSSObject$1;
|
|
19
|
+
};
|
|
20
|
+
type StyleInput = CSSObject$1 | StyleFactory;
|
|
21
|
+
declare function useStyle(style: StyleInput): CSSObject$1;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/hooks/StylesConsumer.d.ts
|
|
24
|
+
type StylesConsumerProps = {
|
|
25
|
+
style: StyleFactory;
|
|
26
|
+
children: (styles: CSSObject$1) => ReactNode;
|
|
27
|
+
};
|
|
28
|
+
declare function StylesConsumer({ style, children }: Readonly<StylesConsumerProps>): import("react").JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/hooks/withStyles.d.ts
|
|
31
|
+
declare function withStyles<P extends object>(style: StyleInput): (WrappedComponent: ComponentType<P & {
|
|
32
|
+
styles: CSSObject$1;
|
|
33
|
+
}>) => (props: P) => import("react").JSX.Element;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/hooks/withTheme.d.ts
|
|
36
|
+
declare function withTheme<P extends object>(WrappedComponent: ComponentType<P & {
|
|
37
|
+
theme: Theme$1;
|
|
38
|
+
}>): (props: P) => import("react").JSX.Element;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { StyleFactory, StyleInput, StylesConsumer, useDefaultProps, useStyle, useTheme, withStyles, withTheme };
|
package/dist/hooks.d.mts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { f as useTheme, t as CSSObject$1 } from "./index-Dm9HfgV6.mjs";
|
|
2
|
+
import { f as Theme$1 } from "./themes-D1SAp3SL.mjs";
|
|
3
|
+
import { ThemeComponents } from "@emotion/react";
|
|
4
|
+
import { ComponentType, ReactNode } from "react";
|
|
5
|
+
//#region src/hooks/useDefaultProps.d.ts
|
|
6
|
+
type DefaultPropsOf<N extends keyof ThemeComponents> = NonNullable<NonNullable<ThemeComponents[N]>['defaultProps']>;
|
|
7
|
+
/**
|
|
8
|
+
* The theme-contributed default prop values for a component
|
|
9
|
+
* (`theme.components[name].defaultProps`), or an empty object.
|
|
10
|
+
*
|
|
11
|
+
* Components apply it as one step of the default-resolution chain:
|
|
12
|
+
* explicit prop → group context → `useDefaultProps` → `theme.defaults.*` → literal fallback.
|
|
13
|
+
*/
|
|
14
|
+
declare function useDefaultProps<N extends keyof ThemeComponents>(name: N): DefaultPropsOf<N>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/hooks/useStyle.d.ts
|
|
17
|
+
type StyleFactory = {
|
|
18
|
+
getStyles: (theme: Theme$1) => CSSObject$1;
|
|
19
|
+
};
|
|
20
|
+
type StyleInput = CSSObject$1 | StyleFactory;
|
|
21
|
+
declare function useStyle(style: StyleInput): CSSObject$1;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/hooks/StylesConsumer.d.ts
|
|
24
|
+
type StylesConsumerProps = {
|
|
25
|
+
style: StyleFactory;
|
|
26
|
+
children: (styles: CSSObject$1) => ReactNode;
|
|
27
|
+
};
|
|
28
|
+
declare function StylesConsumer({ style, children }: Readonly<StylesConsumerProps>): import("react").JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/hooks/withStyles.d.ts
|
|
31
|
+
declare function withStyles<P extends object>(style: StyleInput): (WrappedComponent: ComponentType<P & {
|
|
32
|
+
styles: CSSObject$1;
|
|
33
|
+
}>) => (props: P) => import("react").JSX.Element;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/hooks/withTheme.d.ts
|
|
36
|
+
declare function withTheme<P extends object>(WrappedComponent: ComponentType<P & {
|
|
37
|
+
theme: Theme$1;
|
|
38
|
+
}>): (props: P) => import("react").JSX.Element;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { StyleFactory, StyleInput, StylesConsumer, useDefaultProps, useStyle, useTheme, withStyles, withTheme };
|
package/dist/hooks.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { n as EmotionThemeContext, u as useTheme } from "./src-DcNT2aIK.mjs";
|
|
2
|
+
import { t as useDefaultProps } from "./useDefaultProps-CoApb4KT.mjs";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/hooks/useStyle.ts
|
|
5
|
+
function useStyle(style) {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
return typeof style.getStyles === "function" ? style.getStyles(theme) : style;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/hooks/StylesConsumer.tsx
|
|
11
|
+
function StylesConsumer({ style, children }) {
|
|
12
|
+
return /* @__PURE__ */ jsx(EmotionThemeContext.Consumer, { children: (theme) => children(style.getStyles(theme)) });
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/hooks/withStyles.tsx
|
|
16
|
+
function withStyles(style) {
|
|
17
|
+
return (WrappedComponent) => function WithStyles(props) {
|
|
18
|
+
return typeof style.getStyles === "function" ? /* @__PURE__ */ jsx(StylesConsumer, {
|
|
19
|
+
style,
|
|
20
|
+
children: (styles) => /* @__PURE__ */ jsx(WrappedComponent, {
|
|
21
|
+
...props,
|
|
22
|
+
styles
|
|
23
|
+
})
|
|
24
|
+
}) : /* @__PURE__ */ jsx(WrappedComponent, {
|
|
25
|
+
...props,
|
|
26
|
+
styles: style
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/hooks/withTheme.tsx
|
|
32
|
+
function withTheme(WrappedComponent) {
|
|
33
|
+
return function WithTheme(props) {
|
|
34
|
+
return /* @__PURE__ */ jsx(EmotionThemeContext.Consumer, { children: (theme) => /* @__PURE__ */ jsx(WrappedComponent, {
|
|
35
|
+
...props,
|
|
36
|
+
theme
|
|
37
|
+
}) });
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { StylesConsumer, useDefaultProps, useStyle, useTheme, withStyles, withTheme };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { l as index_d_exports, o as Theme } from "./index-Bihpwn75.cjs";
|
|
2
|
+
import { t as TableCellPadding } from "./TableContext-2qH7XYJB.cjs";
|
|
3
|
+
import { ElementType, ThHTMLAttributes } from "react";
|
|
4
|
+
//#region src/Table/TableSectionContext.d.ts
|
|
5
|
+
/** The table section a cell lives in — drives `TableCell`'s th/td element resolution. */
|
|
6
|
+
type TableSection = 'head' | 'body' | 'footer';
|
|
7
|
+
declare const TableSectionContext: import("react").Context<TableSection | undefined>;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/Table/TableCell/TableCell.d.ts
|
|
10
|
+
/** Cell type — inherited from the enclosing section, overridable per cell. */
|
|
11
|
+
type TableCellVariant = TableSection;
|
|
12
|
+
type TableCellAlign = 'left' | 'right' | 'center' | 'justify' | 'inherit';
|
|
13
|
+
type TableCellSortDirection = 'asc' | 'desc';
|
|
14
|
+
/** Valid values for the color prop — derived from theme.text keys. */
|
|
15
|
+
type TableCellColorToken = keyof Theme['text'];
|
|
16
|
+
/** Valid values for the bg prop — derived from theme.background keys. */
|
|
17
|
+
type TableCellBackgroundToken = keyof Theme['background'];
|
|
18
|
+
/** Valid values for the borderColor prop — derived from theme.border keys. */
|
|
19
|
+
type TableCellBorderColorToken = keyof Theme['border'];
|
|
20
|
+
interface TableCellProps extends Omit<ThHTMLAttributes<HTMLTableCellElement>, 'color' | 'align'>, index_d_exports.SpaceProps<Theme>, index_d_exports.TypographyProps<Theme>, Omit<index_d_exports.BorderProps<Theme>, 'borderColor' | 'borderRadius'> {
|
|
21
|
+
/** Resolves against theme.text */
|
|
22
|
+
color?: TableCellColorToken;
|
|
23
|
+
/** Resolves against theme.background */
|
|
24
|
+
bg?: TableCellBackgroundToken;
|
|
25
|
+
/** Resolves against theme.border — light · primary · dark */
|
|
26
|
+
borderColor?: TableCellBorderColorToken;
|
|
27
|
+
/** Cell type — overrides the enclosing `TableHead`/`TableBody`/`TableFooter` section. */
|
|
28
|
+
variant?: TableCellVariant;
|
|
29
|
+
/** Text alignment of the cell content. Numbers should be right-aligned. Default: `'inherit'`. */
|
|
30
|
+
align?: TableCellAlign;
|
|
31
|
+
/** Cell density — overrides the `Table`'s `size`. Resolves against `theme.sizes`. */
|
|
32
|
+
size?: keyof Theme['sizes'];
|
|
33
|
+
/** Cell padding mode — overrides the `Table`'s `cellPadding`. `'none'` zeroes padding. */
|
|
34
|
+
cellPadding?: TableCellPadding;
|
|
35
|
+
/** Sets `aria-sort` on the cell — a11y only, pair with `TableSortLabel` for the control. */
|
|
36
|
+
sortDirection?: TableCellSortDirection;
|
|
37
|
+
/**
|
|
38
|
+
* Truncates overflowing text with an ellipsis — inherits the `Table`'s
|
|
39
|
+
* `hasEllipsis`. Needs a constrained width (e.g. `maxWidth`) to kick in.
|
|
40
|
+
*/
|
|
41
|
+
hasEllipsis?: boolean;
|
|
42
|
+
as?: ElementType;
|
|
43
|
+
}
|
|
44
|
+
declare function TableCell({ variant, align, size, cellPadding, sortDirection, hasEllipsis, scope, as, children, ...rest }: Readonly<TableCellProps>): import("react").JSX.Element;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { TableCellColorToken as a, TableCellVariant as c, TableCellBorderColorToken as i, TableSection as l, TableCellAlign as n, TableCellProps as o, TableCellBackgroundToken as r, TableCellSortDirection as s, TableCell as t, TableSectionContext as u };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { l as index_d_exports, o as Theme } from "./index-Bihpwn75.cjs";
|
|
2
|
+
import { n as IconProps, r as IconName } from "./index-Dp81rWM1.cjs";
|
|
3
|
+
import { ButtonHTMLAttributes } from "react";
|
|
4
|
+
//#region src/Table/TableSortLabel/TableSortLabel.d.ts
|
|
5
|
+
type TableSortLabelDirection = 'asc' | 'desc';
|
|
6
|
+
interface TableSortLabelProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color'>, index_d_exports.SpaceProps<Theme> {
|
|
7
|
+
/** Marks the currently-sorted column — shows the icon fully opaque. Default: `false`. */
|
|
8
|
+
isActive?: boolean;
|
|
9
|
+
/** Current sort direction — rotates the arrow. Default: `'asc'`. */
|
|
10
|
+
direction?: TableSortLabelDirection;
|
|
11
|
+
/**
|
|
12
|
+
* Hides the inactive sort icon, revealing it on hover/focus. Set `false` to
|
|
13
|
+
* keep it always visible (dimmed while inactive). Inherited from the
|
|
14
|
+
* enclosing `Table`'s `shouldHideSortIcon` via `TableContext`. Default: `true`.
|
|
15
|
+
*/
|
|
16
|
+
shouldHideSortIcon?: boolean;
|
|
17
|
+
/** Sort arrow icon. Default: `'arrow_upward'`. */
|
|
18
|
+
iconName?: IconName;
|
|
19
|
+
/** Extra props for the sort arrow icon. */
|
|
20
|
+
iconProps?: Omit<IconProps, 'name'>;
|
|
21
|
+
}
|
|
22
|
+
declare function TableSortLabel({ isActive, direction, shouldHideSortIcon, iconName, iconProps, type, children, ...rest }: Readonly<TableSortLabelProps>): import("react").JSX.Element;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { TableSortLabelDirection as n, TableSortLabelProps as r, TableSortLabel as t };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { l as index_d_exports, o as Theme } from "./index-Bihpwn75.cjs";
|
|
2
|
+
import { s as ViewProps } from "./index-FwTocqhP.cjs";
|
|
3
|
+
//#region src/Flex/Flex.d.ts
|
|
4
|
+
/** Valid values for the gap prop — derived from theme.space keys. */
|
|
5
|
+
type GapToken = keyof Theme['space'];
|
|
6
|
+
interface FlexProps extends ViewProps, index_d_exports.FlexboxProps<Theme> {
|
|
7
|
+
/** Resolves against theme.space — maps to CSS gap. Accepts responsive arrays. */
|
|
8
|
+
gap?: index_d_exports.ResponsiveValue<GapToken>;
|
|
9
|
+
}
|
|
10
|
+
declare const Flex: import("@emotion/styled").StyledComponent<{
|
|
11
|
+
theme?: Theme;
|
|
12
|
+
as?: React.ElementType;
|
|
13
|
+
} & ViewProps & import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
14
|
+
theme?: Theme;
|
|
15
|
+
} & FlexProps, {}, {}>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { FlexProps as n, GapToken as r, Flex as t };
|