@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,327 @@
|
|
|
1
|
+
import { a as createShouldForwardProp, d as styled } from "./src-DcNT2aIK.mjs";
|
|
2
|
+
import { View } from "./View.mjs";
|
|
3
|
+
import { Backdrop } from "./Backdrop.mjs";
|
|
4
|
+
import { Portal } from "./Portal.mjs";
|
|
5
|
+
import { FocusTrap } from "./FocusTrap.mjs";
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/utils/ownerDocument.ts
|
|
9
|
+
/**
|
|
10
|
+
* Returns the `Document` that owns the given node, falling back to the global
|
|
11
|
+
* `document`. Lets the modal logic work across iframes / portaled containers.
|
|
12
|
+
*/
|
|
13
|
+
function ownerDocument(node) {
|
|
14
|
+
return node?.ownerDocument ?? document;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/utils/ownerWindow.ts
|
|
18
|
+
/**
|
|
19
|
+
* Returns the `Window` that owns the given node, falling back to the global
|
|
20
|
+
* `window`. Used to read viewport metrics for scroll-lock calculations.
|
|
21
|
+
*/
|
|
22
|
+
function ownerWindow(node) {
|
|
23
|
+
return ownerDocument(node).defaultView ?? window;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/Modal/utils/getScrollbarSize.ts
|
|
27
|
+
/**
|
|
28
|
+
* Width of the vertical scrollbar for the given window, in pixels. Equal to the
|
|
29
|
+
* gap between the inner window width and the document's client width. Used to
|
|
30
|
+
* pad the container when scroll-lock hides the scrollbar, preventing layout jump.
|
|
31
|
+
*/
|
|
32
|
+
function getScrollbarSize(win) {
|
|
33
|
+
const documentWidth = win.document.documentElement.clientWidth;
|
|
34
|
+
return Math.abs(win.innerWidth - documentWidth);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/Modal/ModalManager.ts
|
|
38
|
+
const ARIA_HIDDEN_FORBIDDEN_TAGS = /* @__PURE__ */ new Set([
|
|
39
|
+
"TEMPLATE",
|
|
40
|
+
"SCRIPT",
|
|
41
|
+
"STYLE",
|
|
42
|
+
"LINK",
|
|
43
|
+
"MAP",
|
|
44
|
+
"META",
|
|
45
|
+
"NOSCRIPT",
|
|
46
|
+
"PICTURE",
|
|
47
|
+
"COL",
|
|
48
|
+
"COLGROUP",
|
|
49
|
+
"PARAM",
|
|
50
|
+
"SLOT",
|
|
51
|
+
"SOURCE",
|
|
52
|
+
"TRACK"
|
|
53
|
+
]);
|
|
54
|
+
function ariaHidden(element, hide) {
|
|
55
|
+
if (hide) element.setAttribute("aria-hidden", "true");
|
|
56
|
+
else element.removeAttribute("aria-hidden");
|
|
57
|
+
}
|
|
58
|
+
function isAriaHiddenForbidden(element) {
|
|
59
|
+
if (ARIA_HIDDEN_FORBIDDEN_TAGS.has(element.tagName)) return true;
|
|
60
|
+
return element.tagName === "INPUT" && element.getAttribute("type") === "hidden";
|
|
61
|
+
}
|
|
62
|
+
function ariaHiddenSiblings(container, mountElement, currentElement, hiddenSiblings, hide) {
|
|
63
|
+
const exclude = /* @__PURE__ */ new Set([
|
|
64
|
+
mountElement,
|
|
65
|
+
currentElement,
|
|
66
|
+
...hiddenSiblings
|
|
67
|
+
]);
|
|
68
|
+
Array.from(container.children).forEach((element) => {
|
|
69
|
+
if (!exclude.has(element) && !isAriaHiddenForbidden(element)) ariaHidden(element, hide);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function getHiddenSiblings(container) {
|
|
73
|
+
return Array.from(container.children).filter((element) => element.getAttribute("aria-hidden") === "true");
|
|
74
|
+
}
|
|
75
|
+
function isOverflowing(container) {
|
|
76
|
+
const doc = ownerDocument(container);
|
|
77
|
+
if (container === doc.body) return ownerWindow(container).innerWidth > doc.documentElement.clientWidth;
|
|
78
|
+
return container.scrollHeight > container.clientHeight;
|
|
79
|
+
}
|
|
80
|
+
function getPaddingRight(element) {
|
|
81
|
+
return Number.parseFloat(ownerWindow(element).getComputedStyle(element).paddingRight) || 0;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Locks scrolling on the container, padding it by the scrollbar width so hiding
|
|
85
|
+
* the scrollbar causes no horizontal layout shift. Returns a function that
|
|
86
|
+
* restores the exact prior inline styles.
|
|
87
|
+
*/
|
|
88
|
+
function lockScroll(container) {
|
|
89
|
+
const restores = [];
|
|
90
|
+
const setStyle = (property, value) => {
|
|
91
|
+
const previous = container.style.getPropertyValue(property);
|
|
92
|
+
restores.push(() => {
|
|
93
|
+
if (previous) container.style.setProperty(property, previous);
|
|
94
|
+
else container.style.removeProperty(property);
|
|
95
|
+
});
|
|
96
|
+
container.style.setProperty(property, value);
|
|
97
|
+
};
|
|
98
|
+
if (isOverflowing(container)) {
|
|
99
|
+
const scrollbarSize = container === ownerDocument(container).body ? getScrollbarSize(ownerWindow(container)) : container.offsetWidth - container.clientWidth;
|
|
100
|
+
setStyle("padding-right", `${getPaddingRight(container) + scrollbarSize}px`);
|
|
101
|
+
}
|
|
102
|
+
setStyle("overflow", "hidden");
|
|
103
|
+
return () => restores.forEach((restore) => restore());
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Tracks every open modal and the containers they live in. A single shared
|
|
107
|
+
* instance coordinates stacking (`isTopModal`), scroll-lock, and `aria-hidden`
|
|
108
|
+
* on background siblings so assistive tech only sees the active modal.
|
|
109
|
+
*/
|
|
110
|
+
var ModalManager = class {
|
|
111
|
+
modals = [];
|
|
112
|
+
containers = [];
|
|
113
|
+
add(modal, container, disableAriaHidden = false) {
|
|
114
|
+
const existingIndex = this.modals.indexOf(modal);
|
|
115
|
+
if (existingIndex !== -1) return existingIndex;
|
|
116
|
+
const modalIndex = this.modals.length;
|
|
117
|
+
this.modals.push(modal);
|
|
118
|
+
ariaHidden(modal.modalRef, false);
|
|
119
|
+
const hiddenSiblings = getHiddenSiblings(container);
|
|
120
|
+
if (!disableAriaHidden) ariaHiddenSiblings(container, modal.mount, modal.modalRef, hiddenSiblings, true);
|
|
121
|
+
const containerState = this.containers.find((item) => item.container === container);
|
|
122
|
+
if (containerState) {
|
|
123
|
+
containerState.modals.push(modal);
|
|
124
|
+
if (!disableAriaHidden) containerState.ariaHiddenApplied = true;
|
|
125
|
+
return modalIndex;
|
|
126
|
+
}
|
|
127
|
+
this.containers.push({
|
|
128
|
+
container,
|
|
129
|
+
modals: [modal],
|
|
130
|
+
restore: null,
|
|
131
|
+
hiddenSiblings,
|
|
132
|
+
ariaHiddenApplied: !disableAriaHidden
|
|
133
|
+
});
|
|
134
|
+
return modalIndex;
|
|
135
|
+
}
|
|
136
|
+
mount(modal, props) {
|
|
137
|
+
const containerState = this.containers.find((item) => item.modals.includes(modal));
|
|
138
|
+
containerState.restore ??= props.disableScrollLock ? () => {} : lockScroll(containerState.container);
|
|
139
|
+
}
|
|
140
|
+
remove(modal, ariaHiddenState = true) {
|
|
141
|
+
const modalIndex = this.modals.indexOf(modal);
|
|
142
|
+
if (modalIndex === -1) return modalIndex;
|
|
143
|
+
const containerState = this.containers.find((item) => item.modals.includes(modal));
|
|
144
|
+
containerState.modals.splice(containerState.modals.indexOf(modal), 1);
|
|
145
|
+
this.modals.splice(modalIndex, 1);
|
|
146
|
+
if (containerState.modals.length === 0) {
|
|
147
|
+
if (containerState.restore) containerState.restore();
|
|
148
|
+
ariaHidden(modal.modalRef, ariaHiddenState);
|
|
149
|
+
if (containerState.ariaHiddenApplied) ariaHiddenSiblings(containerState.container, modal.mount, modal.modalRef, containerState.hiddenSiblings, false);
|
|
150
|
+
this.containers.splice(this.containers.indexOf(containerState), 1);
|
|
151
|
+
} else {
|
|
152
|
+
const nextTop = containerState.modals.at(-1);
|
|
153
|
+
ariaHidden(modal.modalRef, ariaHiddenState);
|
|
154
|
+
ariaHidden(nextTop.modalRef, false);
|
|
155
|
+
}
|
|
156
|
+
return modalIndex;
|
|
157
|
+
}
|
|
158
|
+
isTopModal(modal) {
|
|
159
|
+
return this.modals.at(-1) === modal;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/Modal/hooks/useEventCallback.ts
|
|
164
|
+
/**
|
|
165
|
+
* Returns a stable function identity that always calls the latest `fn`. Lets
|
|
166
|
+
* effects depend on the callback without re-running when the handler changes.
|
|
167
|
+
*
|
|
168
|
+
* Syncs the ref in `useEffect` (not `useLayoutEffect`) so it stays SSR-safe —
|
|
169
|
+
* the timing difference is irrelevant for the user-triggered handlers it wraps.
|
|
170
|
+
*/
|
|
171
|
+
function useEventCallback(fn) {
|
|
172
|
+
const ref = useRef(fn);
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
ref.current = fn;
|
|
175
|
+
});
|
|
176
|
+
return useCallback((...args) => ref.current(...args), []);
|
|
177
|
+
}
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/Modal/hooks/useMergedRefs.ts
|
|
180
|
+
function assignRef(ref, value) {
|
|
181
|
+
if (typeof ref === "function") ref(value);
|
|
182
|
+
else if (ref) ref.current = value;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Merges two refs into a single stable ref callback so one DOM node can be
|
|
186
|
+
* tracked by both an internal ref and a forwarded `ref`. Returns `null` when
|
|
187
|
+
* both refs are absent, so React skips attaching a callback ref entirely.
|
|
188
|
+
*/
|
|
189
|
+
function useMergedRefs(refA, refB) {
|
|
190
|
+
return useMemo(() => {
|
|
191
|
+
if (refA == null && refB == null) return null;
|
|
192
|
+
return (value) => {
|
|
193
|
+
assignRef(refA, value);
|
|
194
|
+
assignRef(refB, value);
|
|
195
|
+
};
|
|
196
|
+
}, [refA, refB]);
|
|
197
|
+
}
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/Modal/useModal.ts
|
|
200
|
+
const modalManager = new ModalManager();
|
|
201
|
+
function getContainer(container) {
|
|
202
|
+
return typeof container === "function" ? container() : container ?? null;
|
|
203
|
+
}
|
|
204
|
+
function useModal(parameters) {
|
|
205
|
+
const { isOpen, onClose, container, disableScrollLock = false, disableAriaHidden = false, rootRef } = parameters;
|
|
206
|
+
const modal = useRef({});
|
|
207
|
+
const mountNodeRef = useRef(null);
|
|
208
|
+
const modalRef = useRef(null);
|
|
209
|
+
const handleRef = useMergedRefs(modalRef, rootRef);
|
|
210
|
+
const getModal = () => {
|
|
211
|
+
modal.current.modalRef = modalRef.current;
|
|
212
|
+
modal.current.mount = mountNodeRef.current;
|
|
213
|
+
return modal.current;
|
|
214
|
+
};
|
|
215
|
+
const handleOpen = useEventCallback(() => {
|
|
216
|
+
const resolvedContainer = getContainer(container) ?? ownerDocument(mountNodeRef.current).body;
|
|
217
|
+
modalManager.add(getModal(), resolvedContainer, disableAriaHidden);
|
|
218
|
+
modalManager.mount(getModal(), { disableScrollLock });
|
|
219
|
+
});
|
|
220
|
+
const isTopModal = useEventCallback(() => modalManager.isTopModal(getModal()));
|
|
221
|
+
const handlePortalRef = useEventCallback((node) => {
|
|
222
|
+
mountNodeRef.current = node;
|
|
223
|
+
});
|
|
224
|
+
const handleClose = useEventCallback(() => {
|
|
225
|
+
modalManager.remove(modal.current);
|
|
226
|
+
});
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (!isOpen) return;
|
|
229
|
+
handleOpen();
|
|
230
|
+
return () => handleClose();
|
|
231
|
+
}, [
|
|
232
|
+
isOpen,
|
|
233
|
+
container,
|
|
234
|
+
disableScrollLock,
|
|
235
|
+
handleOpen,
|
|
236
|
+
handleClose
|
|
237
|
+
]);
|
|
238
|
+
const createHandleKeyDown = (otherHandlers) => (event) => {
|
|
239
|
+
otherHandlers.onKeyDown?.(event);
|
|
240
|
+
if (event.key !== "Escape" || event.which === 229 || !isTopModal()) return;
|
|
241
|
+
event.stopPropagation();
|
|
242
|
+
onClose?.(event, "escapeKey");
|
|
243
|
+
};
|
|
244
|
+
const createHandleRootClick = (otherHandlers) => (event) => {
|
|
245
|
+
otherHandlers.onClick?.(event);
|
|
246
|
+
if (event.target !== event.currentTarget) return;
|
|
247
|
+
onClose?.(event, "backdropClick");
|
|
248
|
+
};
|
|
249
|
+
const getRootProps = (otherHandlers = {}) => {
|
|
250
|
+
return {
|
|
251
|
+
role: "presentation",
|
|
252
|
+
...otherHandlers,
|
|
253
|
+
onKeyDown: createHandleKeyDown(otherHandlers),
|
|
254
|
+
onClick: createHandleRootClick(otherHandlers),
|
|
255
|
+
ref: handleRef
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
const getBackdropProps = (otherHandlers = {}) => {
|
|
259
|
+
return {
|
|
260
|
+
"aria-hidden": true,
|
|
261
|
+
...otherHandlers,
|
|
262
|
+
open: isOpen
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
return {
|
|
266
|
+
getRootProps,
|
|
267
|
+
getBackdropProps,
|
|
268
|
+
rootRef: handleRef,
|
|
269
|
+
portalRef: handlePortalRef,
|
|
270
|
+
isTopModal
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
//#endregion
|
|
274
|
+
//#region src/Modal/Modal.tsx
|
|
275
|
+
const ModalRoot = styled(View, {
|
|
276
|
+
name: "Modal",
|
|
277
|
+
label: "Modal",
|
|
278
|
+
shouldForwardProp: createShouldForwardProp(["scroll", "layer"])
|
|
279
|
+
})(({ theme, scroll, layer }) => ({
|
|
280
|
+
position: "fixed",
|
|
281
|
+
inset: 0,
|
|
282
|
+
zIndex: theme.zOrder[layer],
|
|
283
|
+
display: "flex",
|
|
284
|
+
...scroll === "paper" ? {
|
|
285
|
+
alignItems: "center",
|
|
286
|
+
justifyContent: "center"
|
|
287
|
+
} : {
|
|
288
|
+
flexDirection: "column",
|
|
289
|
+
overflowY: "auto",
|
|
290
|
+
"& > :not([aria-hidden=\"true\"])": { margin: "auto" }
|
|
291
|
+
}
|
|
292
|
+
}));
|
|
293
|
+
/**
|
|
294
|
+
* @description Accessible overlay primitive: portals its content, dims the page,
|
|
295
|
+
* traps focus, locks scroll, and closes on Escape or backdrop click. The base for
|
|
296
|
+
* higher-level overlays such as Drawer.
|
|
297
|
+
*/
|
|
298
|
+
function Modal({ isOpen, children, onClose, hasBackdrop = true, shouldKeepMounted = false, shouldUsePortal = true, portalContainer, shouldLockScroll = true, disableAriaHidden = false, shouldAutoFocus = true, shouldTrapFocus = true, shouldEnforceFocus = true, shouldRestoreFocus = true, scroll = "paper", layer = "modal" }) {
|
|
299
|
+
const { getRootProps, getBackdropProps } = useModal({
|
|
300
|
+
isOpen,
|
|
301
|
+
onClose,
|
|
302
|
+
container: portalContainer,
|
|
303
|
+
disableScrollLock: !shouldLockScroll,
|
|
304
|
+
disableAriaHidden
|
|
305
|
+
});
|
|
306
|
+
if (!shouldKeepMounted && !isOpen) return null;
|
|
307
|
+
const { open: _open, ...backdropProps } = getBackdropProps();
|
|
308
|
+
const content = /* @__PURE__ */ jsxs(ModalRoot, {
|
|
309
|
+
scroll,
|
|
310
|
+
layer,
|
|
311
|
+
...getRootProps(),
|
|
312
|
+
children: [hasBackdrop ? /* @__PURE__ */ jsx(Backdrop, { ...backdropProps }) : null, /* @__PURE__ */ jsx(FocusTrap, {
|
|
313
|
+
isEnabled: isOpen,
|
|
314
|
+
shouldAutoFocus,
|
|
315
|
+
shouldTrapFocus,
|
|
316
|
+
shouldEnforceFocus,
|
|
317
|
+
shouldRestoreFocus,
|
|
318
|
+
children
|
|
319
|
+
})]
|
|
320
|
+
});
|
|
321
|
+
return shouldUsePortal ? /* @__PURE__ */ jsx(Portal, {
|
|
322
|
+
container: portalContainer,
|
|
323
|
+
children: content
|
|
324
|
+
}) : content;
|
|
325
|
+
}
|
|
326
|
+
//#endregion
|
|
327
|
+
export { ariaHidden as i, useModal as n, ModalManager as r, Modal as t };
|
package/dist/Modal.cjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_Modal = require("./Modal-BDMPTSXv.cjs");
|
|
3
|
+
exports.Modal = require_Modal.Modal;
|
|
4
|
+
exports.ModalManager = require_Modal.ModalManager;
|
|
5
|
+
exports.ariaHidden = require_Modal.ariaHidden;
|
|
6
|
+
exports.useModal = require_Modal.useModal;
|
package/dist/Modal.d.cts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as Modal, c as ModalCloseReason, d as useModal, i as ariaHidden, l as UseModalParameters, n as ManagedModalProps, o as ModalProps, r as ModalManager, s as ModalScroll, t as ManagedModal, u as UseModalReturnValue } from "./index-BX5-NfbX.cjs";
|
|
2
|
+
export { ManagedModal, ManagedModalProps, Modal, ModalCloseReason, ModalManager, ModalProps, ModalScroll, UseModalParameters, UseModalReturnValue, ariaHidden, useModal };
|
package/dist/Modal.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as Modal, c as ModalCloseReason, d as useModal, i as ariaHidden, l as UseModalParameters, n as ManagedModalProps, o as ModalProps, r as ModalManager, s as ModalScroll, t as ManagedModal, u as UseModalReturnValue } from "./index-Dy03o__A.mjs";
|
|
2
|
+
export { ManagedModal, ManagedModalProps, Modal, ModalCloseReason, ModalManager, ModalProps, ModalScroll, UseModalParameters, UseModalReturnValue, ariaHidden, useModal };
|
package/dist/Modal.mjs
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_src = require("./src-BiocWFSR.cjs");
|
|
3
|
+
const require_themeDefault = require("./themeDefault-B-QjpGEO.cjs");
|
|
4
|
+
const require_Icon = require("./Icon-1YtNCUKo.cjs");
|
|
5
|
+
const require_FormControl = require("./FormControl.cjs");
|
|
6
|
+
const require_inputVariantStyles = require("./inputVariantStyles-BBkkYQtE.cjs");
|
|
7
|
+
require("react");
|
|
8
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
+
let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
|
|
10
|
+
let _emotion_react = require("@emotion/react");
|
|
11
|
+
//#region src/NativeSelect/NativeSelect.tsx
|
|
12
|
+
const shouldForwardProp = (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([
|
|
13
|
+
..._soroush_tech_styled_system_should_forward_prop.props,
|
|
14
|
+
"color",
|
|
15
|
+
"textColor",
|
|
16
|
+
"variant",
|
|
17
|
+
"error",
|
|
18
|
+
"disabled",
|
|
19
|
+
"fullWidth"
|
|
20
|
+
]);
|
|
21
|
+
const baseStyle = {
|
|
22
|
+
position: "relative",
|
|
23
|
+
display: "inline-flex",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
transition: "border-color 0.15s ease"
|
|
26
|
+
};
|
|
27
|
+
const backgroundStyle = ({ theme, textColor = require_themeDefault.themeDefault(theme, "accentTextColor", "primary"), bg = require_themeDefault.themeDefault(theme, "inputBg", "terminal") }) => {
|
|
28
|
+
return {
|
|
29
|
+
backgroundColor: (0, require_src.src_exports.get)(theme, `background.${bg}`),
|
|
30
|
+
color: (0, require_src.src_exports.get)(theme, `text.${textColor}`),
|
|
31
|
+
fontFamily: (0, require_src.src_exports.get)(theme, "fonts.body"),
|
|
32
|
+
fontSize: (0, require_src.src_exports.get)(theme, "fontSizes.1"),
|
|
33
|
+
lineHeight: (0, require_src.src_exports.get)(theme, "lineHeights.base")
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const colorBorder = ({ theme, color = require_themeDefault.themeDefault(theme, "color", "primary"), error }) => {
|
|
37
|
+
return { borderColor: error ? (0, require_src.src_exports.get)(theme, "palette.error.main") : (0, require_src.src_exports.get)(theme, `palette.${color}.light`) };
|
|
38
|
+
};
|
|
39
|
+
const focusWithinColor = ({ theme, color = require_themeDefault.themeDefault(theme, "color", "primary"), error }) => {
|
|
40
|
+
return { "&:focus-within": { borderColor: error ? (0, require_src.src_exports.get)(theme, "palette.error.main") : (0, require_src.src_exports.get)(theme, `palette.${color}.main`) } };
|
|
41
|
+
};
|
|
42
|
+
const focusVisibleRing = ({ theme, color = require_themeDefault.themeDefault(theme, "color", "primary"), error }) => {
|
|
43
|
+
return { "&:has(:focus-visible)": {
|
|
44
|
+
outline: `2px solid ${error ? (0, require_src.src_exports.get)(theme, "palette.error.main") : (0, require_src.src_exports.get)(theme, `palette.${color}.main`)}`,
|
|
45
|
+
outlineOffset: "2px"
|
|
46
|
+
} };
|
|
47
|
+
};
|
|
48
|
+
const borderRadiusStyle = ({ variant: v = "default", borderRadius, theme }) => {
|
|
49
|
+
if (v === "underline" || v === "text" || !borderRadius) return {};
|
|
50
|
+
return { borderRadius: (0, require_src.src_exports.get)(theme, `radii.${borderRadius}`) };
|
|
51
|
+
};
|
|
52
|
+
const layoutStyles = ({ fullWidth, disabled }) => ({
|
|
53
|
+
...fullWidth ? {
|
|
54
|
+
display: "flex",
|
|
55
|
+
width: "100%"
|
|
56
|
+
} : {},
|
|
57
|
+
...disabled ? {
|
|
58
|
+
opacity: .5,
|
|
59
|
+
cursor: "not-allowed",
|
|
60
|
+
pointerEvents: "none"
|
|
61
|
+
} : {}
|
|
62
|
+
});
|
|
63
|
+
const NativeSelectRoot = require_src.styled("div", {
|
|
64
|
+
name: "NativeSelect",
|
|
65
|
+
label: "NativeSelect",
|
|
66
|
+
shouldForwardProp,
|
|
67
|
+
systemProps: [require_src.src_exports.space, (0, require_src.src_exports.system)({
|
|
68
|
+
width: true,
|
|
69
|
+
minWidth: true,
|
|
70
|
+
maxWidth: true
|
|
71
|
+
})]
|
|
72
|
+
})(baseStyle, require_inputVariantStyles.inputVariantStyles, borderRadiusStyle, colorBorder, focusWithinColor, focusVisibleRing, backgroundStyle, layoutStyles);
|
|
73
|
+
const shouldForwardNativeSelectProps = (prop) => prop !== "sizeToken" && prop !== "bg" && prop !== "textColor";
|
|
74
|
+
const sizeVariants = ({ theme, sizeToken }) => {
|
|
75
|
+
const s = theme.sizes[sizeToken];
|
|
76
|
+
return {
|
|
77
|
+
paddingTop: theme.space[s.paddingTop],
|
|
78
|
+
paddingBottom: theme.space[s.paddingBottom],
|
|
79
|
+
paddingLeft: theme.space[s.paddingLeft],
|
|
80
|
+
paddingRight: `calc(${theme.space[s.paddingRight]} + 1.5rem)`,
|
|
81
|
+
fontSize: theme.fontSizes[s.fontSize]
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
const selectSurface = ({ theme, bg = require_themeDefault.themeDefault(theme, "inputBg", "terminal"), textColor }) => {
|
|
85
|
+
const backgroundColor = (0, require_src.src_exports.get)(theme, `background.${bg}`);
|
|
86
|
+
const color = (0, require_src.src_exports.get)(theme, `text.${textColor}`);
|
|
87
|
+
return {
|
|
88
|
+
backgroundColor,
|
|
89
|
+
color,
|
|
90
|
+
"& option": {
|
|
91
|
+
backgroundColor,
|
|
92
|
+
color
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
const StyledNativeSelect = require_src.styled("select", {
|
|
97
|
+
name: "NativeSelect",
|
|
98
|
+
slot: "select",
|
|
99
|
+
label: "NativeSelectSelect",
|
|
100
|
+
shouldForwardProp: shouldForwardNativeSelectProps
|
|
101
|
+
})({
|
|
102
|
+
appearance: "none",
|
|
103
|
+
flex: 1,
|
|
104
|
+
minWidth: 0,
|
|
105
|
+
width: "100%",
|
|
106
|
+
border: "none",
|
|
107
|
+
borderRadius: "inherit",
|
|
108
|
+
outline: "none",
|
|
109
|
+
fontFamily: "inherit",
|
|
110
|
+
lineHeight: "inherit",
|
|
111
|
+
cursor: "pointer",
|
|
112
|
+
"&:disabled": { cursor: "not-allowed" }
|
|
113
|
+
}, sizeVariants, selectSurface);
|
|
114
|
+
const DropdownIcon = require_src.styled(require_Icon.Icon, {
|
|
115
|
+
name: "NativeSelect",
|
|
116
|
+
slot: "icon",
|
|
117
|
+
label: "NativeSelectIcon"
|
|
118
|
+
})({
|
|
119
|
+
position: "absolute",
|
|
120
|
+
right: "0.375rem",
|
|
121
|
+
top: "50%",
|
|
122
|
+
transform: "translateY(-50%)",
|
|
123
|
+
pointerEvents: "none"
|
|
124
|
+
});
|
|
125
|
+
function NativeSelect({ options, value, defaultValue, onChange, placeholder, borderRadius, color: colorProp, textColor: textColorProp, bg, disabled: disabledProp, error: errorProp, fullWidth: fullWidthProp, iconName = "expand_more", iconProps, selectProps, id: idProp, name, required: requiredProp, size: sizeProp, variant: variantProp, className, "data-testid": dataTestid, ...spaceProps }) {
|
|
126
|
+
const fc = require_FormControl.useFormControl({
|
|
127
|
+
id: idProp,
|
|
128
|
+
error: errorProp,
|
|
129
|
+
disabled: disabledProp,
|
|
130
|
+
required: requiredProp,
|
|
131
|
+
size: sizeProp,
|
|
132
|
+
fullWidth: fullWidthProp,
|
|
133
|
+
color: colorProp,
|
|
134
|
+
textColor: textColorProp
|
|
135
|
+
});
|
|
136
|
+
const { id, error, disabled, required, size, fullWidth } = fc;
|
|
137
|
+
const theme = (0, _emotion_react.useTheme)();
|
|
138
|
+
const color = fc.color ?? require_themeDefault.themeDefault(theme, "color", "primary");
|
|
139
|
+
const textColor = fc.textColor ?? require_themeDefault.themeDefault(theme, "accentTextColor", "primary");
|
|
140
|
+
const variant = variantProp ?? require_themeDefault.themeDefault(theme, "inputVariant", "default");
|
|
141
|
+
const handleChange = (event) => {
|
|
142
|
+
const match = options.find((option) => String(option.value) === event.target.value);
|
|
143
|
+
onChange?.(match ? match.value : event.target.value);
|
|
144
|
+
};
|
|
145
|
+
const uncontrolledDefault = value === void 0 ? defaultValue ?? (placeholder !== void 0 ? "" : void 0) : void 0;
|
|
146
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(NativeSelectRoot, {
|
|
147
|
+
color,
|
|
148
|
+
textColor,
|
|
149
|
+
bg,
|
|
150
|
+
variant,
|
|
151
|
+
error,
|
|
152
|
+
disabled,
|
|
153
|
+
fullWidth,
|
|
154
|
+
borderRadius,
|
|
155
|
+
className,
|
|
156
|
+
"data-testid": dataTestid,
|
|
157
|
+
...spaceProps,
|
|
158
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledNativeSelect, {
|
|
159
|
+
...selectProps,
|
|
160
|
+
id,
|
|
161
|
+
name,
|
|
162
|
+
disabled,
|
|
163
|
+
required,
|
|
164
|
+
sizeToken: size,
|
|
165
|
+
bg,
|
|
166
|
+
textColor,
|
|
167
|
+
value,
|
|
168
|
+
defaultValue: uncontrolledDefault,
|
|
169
|
+
onChange: handleChange,
|
|
170
|
+
"aria-describedby": selectProps?.["aria-describedby"] ?? fc["aria-describedby"],
|
|
171
|
+
children: [placeholder !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
172
|
+
value: "",
|
|
173
|
+
disabled: true,
|
|
174
|
+
hidden: true,
|
|
175
|
+
children: placeholder
|
|
176
|
+
}), options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
177
|
+
value: String(option.value),
|
|
178
|
+
children: option.label
|
|
179
|
+
}, String(option.value)))]
|
|
180
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownIcon, {
|
|
181
|
+
name: iconName,
|
|
182
|
+
size: "1.25rem",
|
|
183
|
+
color: "secondary",
|
|
184
|
+
...iconProps
|
|
185
|
+
})]
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
//#endregion
|
|
189
|
+
exports.NativeSelect = NativeSelect;
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { SelectHTMLAttributes } from "react";
|
|
4
|
+
//#region src/NativeSelect/NativeSelect.d.ts
|
|
5
|
+
type NativeSelectColor = keyof Theme['palette'];
|
|
6
|
+
type NativeSelectTextColor = keyof Theme['text'];
|
|
7
|
+
type NativeSelectBackgroundToken = keyof Theme['background'];
|
|
8
|
+
type NativeSelectVariant = 'default' | 'outlined' | 'text' | 'underline';
|
|
9
|
+
type NativeSelectSize = keyof Theme['sizes'];
|
|
10
|
+
interface NativeSelectOption {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string | number;
|
|
13
|
+
}
|
|
14
|
+
interface NativeSelectProps extends index_d_exports.SpaceProps<Theme>, Pick<index_d_exports.LayoutProps<Theme>, 'width' | 'minWidth' | 'maxWidth'> {
|
|
15
|
+
/** The options to populate the select with. */
|
|
16
|
+
options: NativeSelectOption[];
|
|
17
|
+
/** Controlled value — matches an option's `value`. */
|
|
18
|
+
value?: string | number;
|
|
19
|
+
/** Uncontrolled initial value. */
|
|
20
|
+
defaultValue?: string | number;
|
|
21
|
+
/** Fired with the selected option's original `value` (number values stay numbers). */
|
|
22
|
+
onChange?: (value: string | number) => void;
|
|
23
|
+
/** Empty-state label rendered as a disabled first option, shown while nothing is selected. */
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
/** Corner radius — applies only to `default` and `outlined` variants. Resolves against `theme.radii`. */
|
|
26
|
+
borderRadius?: keyof Theme['radii'];
|
|
27
|
+
/** Focus/active border color — resolves to `theme.palette[color].main`. Default: 'primary', overridable via `theme.defaults.color`. */
|
|
28
|
+
color?: NativeSelectColor;
|
|
29
|
+
/** Text color of the selected value — resolves against `theme.text`. Default: 'primary', overridable via `theme.defaults.accentTextColor`. */
|
|
30
|
+
textColor?: NativeSelectTextColor;
|
|
31
|
+
/** Background color — resolves against `theme.background`. Default: `'terminal'`. */
|
|
32
|
+
bg?: NativeSelectBackgroundToken;
|
|
33
|
+
/** Disables the select. */
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/** Marks the field as invalid — applies error border color. */
|
|
36
|
+
error?: boolean;
|
|
37
|
+
/** Stretches the root to fill its container. */
|
|
38
|
+
fullWidth?: boolean;
|
|
39
|
+
/** Dropdown affordance icon. Default: `'expand_more'`. */
|
|
40
|
+
iconName?: IconName;
|
|
41
|
+
/** Extra props for the dropdown icon. */
|
|
42
|
+
iconProps?: Omit<IconProps, 'name'>;
|
|
43
|
+
/** Extra attributes spread onto the native `<select>`. Explicit top-level props take priority. */
|
|
44
|
+
selectProps?: SelectHTMLAttributes<HTMLSelectElement>;
|
|
45
|
+
id?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
required?: boolean;
|
|
48
|
+
/** Controls padding and font size. Default: 'md', overridable via `theme.defaults.size`. */
|
|
49
|
+
size?: NativeSelectSize;
|
|
50
|
+
/**
|
|
51
|
+
* Visual style of the select.
|
|
52
|
+
* - `outlined` / `default` — full border box (default)
|
|
53
|
+
* - `underline` — border on bottom only
|
|
54
|
+
* - `text` — no border, transparent background
|
|
55
|
+
*/
|
|
56
|
+
variant?: NativeSelectVariant;
|
|
57
|
+
className?: string;
|
|
58
|
+
'data-testid'?: string;
|
|
59
|
+
}
|
|
60
|
+
declare function NativeSelect({ options, value, defaultValue, onChange, placeholder, borderRadius, color: colorProp, textColor: textColorProp, bg, disabled: disabledProp, error: errorProp, fullWidth: fullWidthProp, iconName, iconProps, selectProps, id: idProp, name, required: requiredProp, size: sizeProp, variant: variantProp, className, 'data-testid': dataTestid, ...spaceProps }: Readonly<NativeSelectProps>): import("react").JSX.Element;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { NativeSelect, NativeSelectBackgroundToken, NativeSelectColor, NativeSelectOption, NativeSelectProps, NativeSelectSize, NativeSelectTextColor, NativeSelectVariant };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { l as index_d_exports, o as Theme } from "./index-Dm9HfgV6.mjs";
|
|
2
|
+
import { n as IconProps, r as IconName } from "./index-BLfFycfJ.mjs";
|
|
3
|
+
import { SelectHTMLAttributes } from "react";
|
|
4
|
+
//#region src/NativeSelect/NativeSelect.d.ts
|
|
5
|
+
type NativeSelectColor = keyof Theme['palette'];
|
|
6
|
+
type NativeSelectTextColor = keyof Theme['text'];
|
|
7
|
+
type NativeSelectBackgroundToken = keyof Theme['background'];
|
|
8
|
+
type NativeSelectVariant = 'default' | 'outlined' | 'text' | 'underline';
|
|
9
|
+
type NativeSelectSize = keyof Theme['sizes'];
|
|
10
|
+
interface NativeSelectOption {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string | number;
|
|
13
|
+
}
|
|
14
|
+
interface NativeSelectProps extends index_d_exports.SpaceProps<Theme>, Pick<index_d_exports.LayoutProps<Theme>, 'width' | 'minWidth' | 'maxWidth'> {
|
|
15
|
+
/** The options to populate the select with. */
|
|
16
|
+
options: NativeSelectOption[];
|
|
17
|
+
/** Controlled value — matches an option's `value`. */
|
|
18
|
+
value?: string | number;
|
|
19
|
+
/** Uncontrolled initial value. */
|
|
20
|
+
defaultValue?: string | number;
|
|
21
|
+
/** Fired with the selected option's original `value` (number values stay numbers). */
|
|
22
|
+
onChange?: (value: string | number) => void;
|
|
23
|
+
/** Empty-state label rendered as a disabled first option, shown while nothing is selected. */
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
/** Corner radius — applies only to `default` and `outlined` variants. Resolves against `theme.radii`. */
|
|
26
|
+
borderRadius?: keyof Theme['radii'];
|
|
27
|
+
/** Focus/active border color — resolves to `theme.palette[color].main`. Default: 'primary', overridable via `theme.defaults.color`. */
|
|
28
|
+
color?: NativeSelectColor;
|
|
29
|
+
/** Text color of the selected value — resolves against `theme.text`. Default: 'primary', overridable via `theme.defaults.accentTextColor`. */
|
|
30
|
+
textColor?: NativeSelectTextColor;
|
|
31
|
+
/** Background color — resolves against `theme.background`. Default: `'terminal'`. */
|
|
32
|
+
bg?: NativeSelectBackgroundToken;
|
|
33
|
+
/** Disables the select. */
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
/** Marks the field as invalid — applies error border color. */
|
|
36
|
+
error?: boolean;
|
|
37
|
+
/** Stretches the root to fill its container. */
|
|
38
|
+
fullWidth?: boolean;
|
|
39
|
+
/** Dropdown affordance icon. Default: `'expand_more'`. */
|
|
40
|
+
iconName?: IconName;
|
|
41
|
+
/** Extra props for the dropdown icon. */
|
|
42
|
+
iconProps?: Omit<IconProps, 'name'>;
|
|
43
|
+
/** Extra attributes spread onto the native `<select>`. Explicit top-level props take priority. */
|
|
44
|
+
selectProps?: SelectHTMLAttributes<HTMLSelectElement>;
|
|
45
|
+
id?: string;
|
|
46
|
+
name?: string;
|
|
47
|
+
required?: boolean;
|
|
48
|
+
/** Controls padding and font size. Default: 'md', overridable via `theme.defaults.size`. */
|
|
49
|
+
size?: NativeSelectSize;
|
|
50
|
+
/**
|
|
51
|
+
* Visual style of the select.
|
|
52
|
+
* - `outlined` / `default` — full border box (default)
|
|
53
|
+
* - `underline` — border on bottom only
|
|
54
|
+
* - `text` — no border, transparent background
|
|
55
|
+
*/
|
|
56
|
+
variant?: NativeSelectVariant;
|
|
57
|
+
className?: string;
|
|
58
|
+
'data-testid'?: string;
|
|
59
|
+
}
|
|
60
|
+
declare function NativeSelect({ options, value, defaultValue, onChange, placeholder, borderRadius, color: colorProp, textColor: textColorProp, bg, disabled: disabledProp, error: errorProp, fullWidth: fullWidthProp, iconName, iconProps, selectProps, id: idProp, name, required: requiredProp, size: sizeProp, variant: variantProp, className, 'data-testid': dataTestid, ...spaceProps }: Readonly<NativeSelectProps>): import("react").JSX.Element;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { NativeSelect, NativeSelectBackgroundToken, NativeSelectColor, NativeSelectOption, NativeSelectProps, NativeSelectSize, NativeSelectTextColor, NativeSelectVariant };
|