@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
package/dist/Select.mjs
ADDED
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import { a as createShouldForwardProp, c as props, d as styled, l as src_exports, u as useTheme } from "./src-DcNT2aIK.mjs";
|
|
2
|
+
import { t as themeDefault } from "./themeDefault-CjXaY3ok.mjs";
|
|
3
|
+
import { t as Icon } from "./Icon-CAKRmFz3.mjs";
|
|
4
|
+
import { useFormControl } from "./FormControl.mjs";
|
|
5
|
+
import { NativeSelect } from "./NativeSelect.mjs";
|
|
6
|
+
import { t as Popover } from "./Popover-B61J7C79.mjs";
|
|
7
|
+
import { Children, cloneElement, isValidElement, useCallback, useId, useState } from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
//#region src/Select/hooks/useSelectPopover.ts
|
|
10
|
+
/**
|
|
11
|
+
* Owns `Select`'s open state (controlled or uncontrolled) and fires the open/close
|
|
12
|
+
* callbacks. Positioning is delegated to `Popover`.
|
|
13
|
+
*/
|
|
14
|
+
function useSelectPopover({ open: openProp, defaultOpen = false, onOpen, onClose }) {
|
|
15
|
+
const isControlled = openProp !== void 0;
|
|
16
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
17
|
+
return {
|
|
18
|
+
open: isControlled ? openProp : uncontrolledOpen,
|
|
19
|
+
openMenu: useCallback(() => {
|
|
20
|
+
if (!isControlled) setUncontrolledOpen(true);
|
|
21
|
+
onOpen?.();
|
|
22
|
+
}, [isControlled, onOpen]),
|
|
23
|
+
closeMenu: useCallback(() => {
|
|
24
|
+
if (!isControlled) setUncontrolledOpen(false);
|
|
25
|
+
onClose?.();
|
|
26
|
+
}, [isControlled, onClose])
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/Select/utils/getOptionsFromChildren.ts
|
|
31
|
+
/**
|
|
32
|
+
* Flattens `Select`'s `MenuItem` children into a plain option list. Any child that
|
|
33
|
+
* is not a valid element carrying a `value` prop (e.g. whitespace, `null`) is skipped,
|
|
34
|
+
* so the returned indices line up with the rendered, selectable rows.
|
|
35
|
+
*/
|
|
36
|
+
function getOptionsFromChildren(children) {
|
|
37
|
+
return Children.toArray(children).flatMap((child) => {
|
|
38
|
+
if (!isValidElement(child)) return [];
|
|
39
|
+
const props = child.props;
|
|
40
|
+
if (props.value === void 0) return [];
|
|
41
|
+
return [{
|
|
42
|
+
value: props.value,
|
|
43
|
+
label: props.children,
|
|
44
|
+
disabled: props.disabled ?? false
|
|
45
|
+
}];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/Select/utils/getNextEnabledIndex.ts
|
|
50
|
+
/**
|
|
51
|
+
* Walks `options` from `from` by `step` (+1 / -1), skipping disabled rows, and
|
|
52
|
+
* returns the first enabled index reached. Stops at the edges (no wrap-around);
|
|
53
|
+
* returns `from` when no enabled option lies in that direction.
|
|
54
|
+
*/
|
|
55
|
+
function getNextEnabledIndex(options, from, step) {
|
|
56
|
+
for (let next = from + step; next >= 0 && next < options.length; next += step) if (!options[next].disabled) return next;
|
|
57
|
+
return from;
|
|
58
|
+
}
|
|
59
|
+
/** First (`'first'`) or last (`'last'`) enabled index, or `-1` when every option is disabled. */
|
|
60
|
+
function getEdgeEnabledIndex(options, edge) {
|
|
61
|
+
if (edge === "first") return options.findIndex((option) => !option.disabled);
|
|
62
|
+
for (let index = options.length - 1; index >= 0; index -= 1) if (!options[index].disabled) return index;
|
|
63
|
+
return -1;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/Select/utils/isOptionSelected.ts
|
|
67
|
+
/** True when `optionValue` is the current single value, or is contained in the multiple-mode array. */
|
|
68
|
+
function isOptionSelected(value, optionValue) {
|
|
69
|
+
return Array.isArray(value) ? value.includes(optionValue) : value === optionValue;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/Select/utils/computeNextValue.ts
|
|
73
|
+
/**
|
|
74
|
+
* The value that results from choosing `optionValue`.
|
|
75
|
+
* - Multiple mode: toggles `optionValue` in/out of the array, preserving order.
|
|
76
|
+
* - Single mode: replaces the value outright.
|
|
77
|
+
*/
|
|
78
|
+
function computeNextValue(value, optionValue) {
|
|
79
|
+
if (!Array.isArray(value)) return optionValue;
|
|
80
|
+
return value.includes(optionValue) ? value.filter((item) => item !== optionValue) : [...value, optionValue];
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/Select/utils/resolveDisplayLabel.ts
|
|
84
|
+
/**
|
|
85
|
+
* The label(s) to show in the trigger for the current `value`, or `null` when nothing
|
|
86
|
+
* is selected (the caller then falls back to the placeholder). Multiple-mode selections
|
|
87
|
+
* are joined in option order with `, `.
|
|
88
|
+
*/
|
|
89
|
+
function resolveDisplayLabel(options, value) {
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
const selected = options.filter((option) => value.includes(option.value));
|
|
92
|
+
if (selected.length === 0) return null;
|
|
93
|
+
return selected.map((option) => option.label).reduce((acc, label, index) => {
|
|
94
|
+
if (index > 0) acc.push(", ");
|
|
95
|
+
acc.push(label);
|
|
96
|
+
return acc;
|
|
97
|
+
}, []);
|
|
98
|
+
}
|
|
99
|
+
const match = options.find((option) => option.value === value);
|
|
100
|
+
return match ? match.label : null;
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/Select/Select.tsx
|
|
104
|
+
const shouldForwardProp = createShouldForwardProp([
|
|
105
|
+
...props,
|
|
106
|
+
"variant",
|
|
107
|
+
"sizeToken",
|
|
108
|
+
"color",
|
|
109
|
+
"textColor",
|
|
110
|
+
"bg",
|
|
111
|
+
"error",
|
|
112
|
+
"disabled",
|
|
113
|
+
"fullWidth",
|
|
114
|
+
"borderRadius",
|
|
115
|
+
"open"
|
|
116
|
+
]);
|
|
117
|
+
const baseStyle = ({ theme }) => ({
|
|
118
|
+
position: "relative",
|
|
119
|
+
boxSizing: "border-box",
|
|
120
|
+
display: "inline-flex",
|
|
121
|
+
alignItems: "center",
|
|
122
|
+
justifyContent: "space-between",
|
|
123
|
+
gap: theme.space[1],
|
|
124
|
+
cursor: "pointer",
|
|
125
|
+
outline: "none",
|
|
126
|
+
textAlign: "left",
|
|
127
|
+
transition: "border-color 0.15s ease"
|
|
128
|
+
});
|
|
129
|
+
const variantStyles = (0, src_exports.variant)({
|
|
130
|
+
prop: "variant",
|
|
131
|
+
variants: {
|
|
132
|
+
outlined: {
|
|
133
|
+
borderRadius: "sq",
|
|
134
|
+
borderWidth: "thin",
|
|
135
|
+
borderStyle: "solid"
|
|
136
|
+
},
|
|
137
|
+
default: {
|
|
138
|
+
borderRadius: "sq",
|
|
139
|
+
borderStyle: "none"
|
|
140
|
+
},
|
|
141
|
+
underline: {
|
|
142
|
+
borderRadius: "sq",
|
|
143
|
+
borderStyle: "none",
|
|
144
|
+
borderBottomWidth: "thin",
|
|
145
|
+
borderBottomStyle: "solid"
|
|
146
|
+
},
|
|
147
|
+
text: {
|
|
148
|
+
borderRadius: "sq",
|
|
149
|
+
borderStyle: "none"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
const borderRadiusStyle = ({ variant: v, borderRadius, theme }) => {
|
|
154
|
+
if (v === "underline" || v === "text" || !borderRadius) return {};
|
|
155
|
+
return { borderRadius: (0, src_exports.get)(theme, `radii.${borderRadius}`) };
|
|
156
|
+
};
|
|
157
|
+
const colorBorder = ({ color, error, theme }) => ({ borderColor: error ? (0, src_exports.get)(theme, "palette.error.main") : (0, src_exports.get)(theme, `palette.${color}.light`) });
|
|
158
|
+
const activeBorder = ({ color, error, open, theme }) => {
|
|
159
|
+
const activeColor = error ? (0, src_exports.get)(theme, "palette.error.main") : (0, src_exports.get)(theme, `palette.${color}.main`);
|
|
160
|
+
return {
|
|
161
|
+
...open ? { borderColor: activeColor } : {},
|
|
162
|
+
"&:focus": { borderColor: activeColor },
|
|
163
|
+
"&:focus-visible": {
|
|
164
|
+
outline: `2px solid ${(0, src_exports.get)(theme, `palette.${themeDefault(theme, "color", "primary")}.main`)}`,
|
|
165
|
+
outlineOffset: "2px"
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
const backgroundStyle = ({ color, textColor, bg, variant: v, theme }) => ({
|
|
170
|
+
backgroundColor: v === "text" ? "transparent" : (0, src_exports.get)(theme, `background.${bg}`),
|
|
171
|
+
color: textColor ? (0, src_exports.get)(theme, `text.${textColor}`) : (0, src_exports.get)(theme, `palette.${color}.main`),
|
|
172
|
+
fontFamily: (0, src_exports.get)(theme, "fonts.body"),
|
|
173
|
+
fontSize: (0, src_exports.get)(theme, "fontSizes.1"),
|
|
174
|
+
lineHeight: (0, src_exports.get)(theme, "lineHeights.base")
|
|
175
|
+
});
|
|
176
|
+
const sizeVariants = ({ theme, sizeToken }) => {
|
|
177
|
+
const s = theme.sizes[sizeToken];
|
|
178
|
+
return {
|
|
179
|
+
paddingTop: theme.space[s.paddingTop],
|
|
180
|
+
paddingBottom: theme.space[s.paddingBottom],
|
|
181
|
+
paddingLeft: theme.space[s.paddingLeft],
|
|
182
|
+
paddingRight: theme.space[s.paddingRight],
|
|
183
|
+
fontSize: theme.fontSizes[s.fontSize]
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
const layoutStyles = ({ fullWidth, disabled }) => ({
|
|
187
|
+
...fullWidth ? {
|
|
188
|
+
display: "flex",
|
|
189
|
+
width: "100%"
|
|
190
|
+
} : { alignSelf: "flex-start" },
|
|
191
|
+
...disabled ? {
|
|
192
|
+
opacity: .5,
|
|
193
|
+
cursor: "not-allowed"
|
|
194
|
+
} : {}
|
|
195
|
+
});
|
|
196
|
+
const Trigger = styled("div", {
|
|
197
|
+
name: "Select",
|
|
198
|
+
label: "Select",
|
|
199
|
+
shouldForwardProp,
|
|
200
|
+
systemProps: [src_exports.space, (0, src_exports.system)({
|
|
201
|
+
width: true,
|
|
202
|
+
minWidth: true,
|
|
203
|
+
maxWidth: true
|
|
204
|
+
})]
|
|
205
|
+
})(baseStyle, variantStyles, borderRadiusStyle, colorBorder, activeBorder, backgroundStyle, sizeVariants, layoutStyles);
|
|
206
|
+
const ValueArea = styled("span", {
|
|
207
|
+
name: "Select",
|
|
208
|
+
slot: "valueArea",
|
|
209
|
+
label: "SelectValueArea",
|
|
210
|
+
shouldForwardProp: (prop) => prop !== "autoWidth"
|
|
211
|
+
})(({ autoWidth }) => ({
|
|
212
|
+
flex: 1,
|
|
213
|
+
minWidth: 0,
|
|
214
|
+
display: autoWidth ? "block" : "inline-grid",
|
|
215
|
+
"& > *": { gridArea: "1 / 1" }
|
|
216
|
+
}));
|
|
217
|
+
const ValueGhost = styled("span", {
|
|
218
|
+
name: "Select",
|
|
219
|
+
slot: "valueGhost",
|
|
220
|
+
label: "SelectValueGhost"
|
|
221
|
+
})({
|
|
222
|
+
height: 0,
|
|
223
|
+
overflow: "hidden",
|
|
224
|
+
visibility: "hidden",
|
|
225
|
+
display: "flex",
|
|
226
|
+
flexDirection: "column",
|
|
227
|
+
"& > span": { whiteSpace: "nowrap" }
|
|
228
|
+
});
|
|
229
|
+
const TriggerValue = styled("span", {
|
|
230
|
+
name: "Select",
|
|
231
|
+
slot: "value",
|
|
232
|
+
label: "SelectValue"
|
|
233
|
+
})({
|
|
234
|
+
minWidth: 0,
|
|
235
|
+
overflow: "hidden",
|
|
236
|
+
textOverflow: "ellipsis",
|
|
237
|
+
whiteSpace: "nowrap"
|
|
238
|
+
});
|
|
239
|
+
const ListBox = styled("ul", {
|
|
240
|
+
name: "Select",
|
|
241
|
+
slot: "listbox",
|
|
242
|
+
label: "SelectListbox"
|
|
243
|
+
})(({ theme }) => ({
|
|
244
|
+
margin: 0,
|
|
245
|
+
padding: `${theme.space[1]} 0`,
|
|
246
|
+
width: "100%",
|
|
247
|
+
maxHeight: "16rem",
|
|
248
|
+
overflowY: "auto",
|
|
249
|
+
listStyle: "none"
|
|
250
|
+
}));
|
|
251
|
+
function Select({ children, native = false, multiple = false, autoWidth = false, value: valueProp, defaultValue, onChange, open: openProp, defaultOpen, onOpen, onClose, placeholder, renderValue, borderRadius, color: colorProp, textColor: textColorProp, bg: bgProp, disabled: disabledProp, error: errorProp, fullWidth: fullWidthProp, required: requiredProp, size: sizeProp, variant: variantProp, iconName, iconProps, id: idProp, name, labelId, "aria-label": ariaLabel, className, "data-testid": dataTestid, ...spaceProps }) {
|
|
252
|
+
const fc = useFormControl({
|
|
253
|
+
id: idProp,
|
|
254
|
+
error: errorProp,
|
|
255
|
+
disabled: disabledProp,
|
|
256
|
+
required: requiredProp,
|
|
257
|
+
size: sizeProp,
|
|
258
|
+
fullWidth: fullWidthProp,
|
|
259
|
+
color: colorProp,
|
|
260
|
+
textColor: textColorProp
|
|
261
|
+
});
|
|
262
|
+
const { id, error, disabled, required, size, fullWidth } = fc;
|
|
263
|
+
const theme = useTheme();
|
|
264
|
+
const color = fc.color ?? themeDefault(theme, "color", "primary");
|
|
265
|
+
const bg = bgProp ?? themeDefault(theme, "inputBg", "terminal");
|
|
266
|
+
const variant = variantProp ?? themeDefault(theme, "inputVariant", "default");
|
|
267
|
+
const textColor = fc.textColor;
|
|
268
|
+
const options = getOptionsFromChildren(children);
|
|
269
|
+
const isControlledValue = valueProp !== void 0;
|
|
270
|
+
const [internalValue, setInternalValue] = useState(defaultValue ?? (multiple ? [] : ""));
|
|
271
|
+
const rawValue = isControlledValue ? valueProp : internalValue;
|
|
272
|
+
const value = multiple ? Array.isArray(rawValue) ? rawValue : [] : Array.isArray(rawValue) ? "" : rawValue;
|
|
273
|
+
if (native) return /* @__PURE__ */ jsx(NativeSelect, {
|
|
274
|
+
options: options.map((option) => ({
|
|
275
|
+
value: option.value,
|
|
276
|
+
label: typeof option.label === "string" ? option.label : String(option.label)
|
|
277
|
+
})),
|
|
278
|
+
value: Array.isArray(valueProp) ? void 0 : valueProp,
|
|
279
|
+
defaultValue: Array.isArray(defaultValue) ? void 0 : defaultValue,
|
|
280
|
+
onChange,
|
|
281
|
+
placeholder,
|
|
282
|
+
borderRadius,
|
|
283
|
+
color: colorProp,
|
|
284
|
+
textColor: textColorProp,
|
|
285
|
+
bg,
|
|
286
|
+
disabled: disabledProp,
|
|
287
|
+
error: errorProp,
|
|
288
|
+
fullWidth: fullWidthProp,
|
|
289
|
+
required: requiredProp,
|
|
290
|
+
size: sizeProp,
|
|
291
|
+
variant,
|
|
292
|
+
iconName,
|
|
293
|
+
iconProps,
|
|
294
|
+
id: idProp,
|
|
295
|
+
name,
|
|
296
|
+
className,
|
|
297
|
+
"data-testid": dataTestid,
|
|
298
|
+
...spaceProps
|
|
299
|
+
});
|
|
300
|
+
return /* @__PURE__ */ jsx(NonNativeSelect, {
|
|
301
|
+
options,
|
|
302
|
+
value,
|
|
303
|
+
onChangeValue: (next) => {
|
|
304
|
+
if (!isControlledValue) setInternalValue(next);
|
|
305
|
+
onChange?.(next);
|
|
306
|
+
},
|
|
307
|
+
multiple,
|
|
308
|
+
autoWidth,
|
|
309
|
+
openProp,
|
|
310
|
+
defaultOpen,
|
|
311
|
+
onOpen,
|
|
312
|
+
onClose,
|
|
313
|
+
placeholder,
|
|
314
|
+
renderValue,
|
|
315
|
+
borderRadius,
|
|
316
|
+
color,
|
|
317
|
+
textColor,
|
|
318
|
+
bg,
|
|
319
|
+
error,
|
|
320
|
+
disabled,
|
|
321
|
+
required,
|
|
322
|
+
fullWidth,
|
|
323
|
+
size,
|
|
324
|
+
variant,
|
|
325
|
+
iconName,
|
|
326
|
+
iconProps,
|
|
327
|
+
id,
|
|
328
|
+
name,
|
|
329
|
+
labelId,
|
|
330
|
+
ariaLabel,
|
|
331
|
+
ariaDescribedby: fc["aria-describedby"],
|
|
332
|
+
className,
|
|
333
|
+
dataTestid,
|
|
334
|
+
spaceProps,
|
|
335
|
+
children
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function NonNativeSelect({ children, options, value, autoWidth, onChangeValue, multiple, openProp, defaultOpen, onOpen, onClose, placeholder, renderValue, borderRadius, color, textColor, bg, error, disabled, required, fullWidth, size, variant: variantProp, iconName, iconProps, id, name, labelId, ariaLabel, ariaDescribedby, className, dataTestid, spaceProps }) {
|
|
339
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
340
|
+
const listboxId = `${useId()}-listbox`;
|
|
341
|
+
const { open, openMenu, closeMenu } = useSelectPopover({
|
|
342
|
+
open: openProp,
|
|
343
|
+
defaultOpen,
|
|
344
|
+
onOpen,
|
|
345
|
+
onClose
|
|
346
|
+
});
|
|
347
|
+
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
348
|
+
const getInitialHighlight = () => {
|
|
349
|
+
if (!Array.isArray(value)) {
|
|
350
|
+
const current = options.findIndex((option) => option.value === value && !option.disabled);
|
|
351
|
+
if (current !== -1) return current;
|
|
352
|
+
}
|
|
353
|
+
return getEdgeEnabledIndex(options, "first");
|
|
354
|
+
};
|
|
355
|
+
const openWithHighlight = () => {
|
|
356
|
+
setHighlightedIndex(getInitialHighlight());
|
|
357
|
+
openMenu();
|
|
358
|
+
};
|
|
359
|
+
const selectValue = (optionValue) => {
|
|
360
|
+
onChangeValue(computeNextValue(value, optionValue));
|
|
361
|
+
setHighlightedIndex(options.findIndex((option) => option.value === optionValue));
|
|
362
|
+
if (!multiple) closeMenu();
|
|
363
|
+
};
|
|
364
|
+
const selectHighlighted = () => {
|
|
365
|
+
const option = options[highlightedIndex];
|
|
366
|
+
if (option && !option.disabled) selectValue(option.value);
|
|
367
|
+
};
|
|
368
|
+
const moveHighlight = (step) => {
|
|
369
|
+
if (open) setHighlightedIndex((index) => getNextEnabledIndex(options, index, step));
|
|
370
|
+
else openWithHighlight();
|
|
371
|
+
};
|
|
372
|
+
const handleKeyDown = (event) => {
|
|
373
|
+
if (disabled) return;
|
|
374
|
+
switch (event.key) {
|
|
375
|
+
case "ArrowDown":
|
|
376
|
+
event.preventDefault();
|
|
377
|
+
moveHighlight(1);
|
|
378
|
+
break;
|
|
379
|
+
case "ArrowUp":
|
|
380
|
+
event.preventDefault();
|
|
381
|
+
moveHighlight(-1);
|
|
382
|
+
break;
|
|
383
|
+
case "Home":
|
|
384
|
+
if (open) {
|
|
385
|
+
event.preventDefault();
|
|
386
|
+
setHighlightedIndex(getEdgeEnabledIndex(options, "first"));
|
|
387
|
+
}
|
|
388
|
+
break;
|
|
389
|
+
case "End":
|
|
390
|
+
if (open) {
|
|
391
|
+
event.preventDefault();
|
|
392
|
+
setHighlightedIndex(getEdgeEnabledIndex(options, "last"));
|
|
393
|
+
}
|
|
394
|
+
break;
|
|
395
|
+
case "Enter":
|
|
396
|
+
case " ":
|
|
397
|
+
event.preventDefault();
|
|
398
|
+
if (open) selectHighlighted();
|
|
399
|
+
else openWithHighlight();
|
|
400
|
+
break;
|
|
401
|
+
case "Escape":
|
|
402
|
+
if (open) {
|
|
403
|
+
event.preventDefault();
|
|
404
|
+
closeMenu();
|
|
405
|
+
}
|
|
406
|
+
break;
|
|
407
|
+
default: break;
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
const handleTriggerClick = () => {
|
|
411
|
+
if (disabled) return;
|
|
412
|
+
if (open) closeMenu();
|
|
413
|
+
else openWithHighlight();
|
|
414
|
+
};
|
|
415
|
+
const handleBlur = () => {
|
|
416
|
+
if (open) closeMenu();
|
|
417
|
+
};
|
|
418
|
+
const display = renderValue ? renderValue(value) : resolveDisplayLabel(options, value);
|
|
419
|
+
const showPlaceholder = !renderValue && resolveDisplayLabel(options, value) === null;
|
|
420
|
+
const activeDescendant = open && highlightedIndex >= 0 ? `${listboxId}-option-${highlightedIndex}` : void 0;
|
|
421
|
+
const childArray = Children.toArray(children);
|
|
422
|
+
const isOptionChild = (child) => isValidElement(child) && child.props.value !== void 0;
|
|
423
|
+
const renderedItems = childArray.map((child, position) => {
|
|
424
|
+
if (!isOptionChild(child)) return child;
|
|
425
|
+
const index = childArray.slice(0, position).filter(isOptionChild).length;
|
|
426
|
+
const option = options[index];
|
|
427
|
+
const childProps = child.props;
|
|
428
|
+
return cloneElement(child, {
|
|
429
|
+
id: `${listboxId}-option-${index}`,
|
|
430
|
+
selected: isOptionSelected(value, option.value),
|
|
431
|
+
highlighted: index === highlightedIndex,
|
|
432
|
+
multiple,
|
|
433
|
+
size,
|
|
434
|
+
color: childProps.color ?? color,
|
|
435
|
+
textColor: childProps.textColor ?? textColor,
|
|
436
|
+
onSelect: selectValue
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
440
|
+
/* @__PURE__ */ jsxs(Trigger, {
|
|
441
|
+
ref: setAnchorEl,
|
|
442
|
+
role: "combobox",
|
|
443
|
+
tabIndex: disabled ? -1 : 0,
|
|
444
|
+
"aria-haspopup": "listbox",
|
|
445
|
+
"aria-expanded": open,
|
|
446
|
+
"aria-controls": open ? listboxId : void 0,
|
|
447
|
+
"aria-activedescendant": activeDescendant,
|
|
448
|
+
"aria-labelledby": labelId,
|
|
449
|
+
"aria-label": ariaLabel,
|
|
450
|
+
"aria-describedby": ariaDescribedby,
|
|
451
|
+
"aria-invalid": error || void 0,
|
|
452
|
+
"aria-required": required || void 0,
|
|
453
|
+
"aria-disabled": disabled || void 0,
|
|
454
|
+
variant: variantProp,
|
|
455
|
+
sizeToken: size,
|
|
456
|
+
color,
|
|
457
|
+
textColor,
|
|
458
|
+
bg,
|
|
459
|
+
error,
|
|
460
|
+
disabled,
|
|
461
|
+
fullWidth,
|
|
462
|
+
borderRadius,
|
|
463
|
+
open,
|
|
464
|
+
id,
|
|
465
|
+
className,
|
|
466
|
+
"data-testid": dataTestid,
|
|
467
|
+
onClick: handleTriggerClick,
|
|
468
|
+
onKeyDown: handleKeyDown,
|
|
469
|
+
onBlur: handleBlur,
|
|
470
|
+
...spaceProps,
|
|
471
|
+
children: [/* @__PURE__ */ jsxs(ValueArea, {
|
|
472
|
+
autoWidth,
|
|
473
|
+
children: [!autoWidth && /* @__PURE__ */ jsxs(ValueGhost, {
|
|
474
|
+
"aria-hidden": true,
|
|
475
|
+
children: [options.map((option) => /* @__PURE__ */ jsx("span", { children: option.label }, String(option.value))), placeholder !== void 0 && /* @__PURE__ */ jsx("span", { children: placeholder })]
|
|
476
|
+
}), /* @__PURE__ */ jsx(TriggerValue, { children: showPlaceholder ? placeholder ?? "" : display })]
|
|
477
|
+
}), /* @__PURE__ */ jsx(Icon, {
|
|
478
|
+
name: iconName ?? (open ? "expand_less" : "expand_more"),
|
|
479
|
+
size: "1.25rem",
|
|
480
|
+
color: "secondary",
|
|
481
|
+
...iconProps
|
|
482
|
+
})]
|
|
483
|
+
}),
|
|
484
|
+
name !== void 0 && /* @__PURE__ */ jsx("input", {
|
|
485
|
+
type: "hidden",
|
|
486
|
+
name,
|
|
487
|
+
value: Array.isArray(value) ? value.join(",") : String(value)
|
|
488
|
+
}),
|
|
489
|
+
/* @__PURE__ */ jsx(Popover, {
|
|
490
|
+
open,
|
|
491
|
+
anchorEl,
|
|
492
|
+
anchorOrigin: {
|
|
493
|
+
vertical: "bottom",
|
|
494
|
+
horizontal: "left"
|
|
495
|
+
},
|
|
496
|
+
transformOrigin: {
|
|
497
|
+
vertical: "top",
|
|
498
|
+
horizontal: "left"
|
|
499
|
+
},
|
|
500
|
+
onClose: closeMenu,
|
|
501
|
+
disableScrollLock: true,
|
|
502
|
+
disableAriaHidden: true,
|
|
503
|
+
shouldAutoFocus: false,
|
|
504
|
+
shouldTrapFocus: false,
|
|
505
|
+
shouldEnforceFocus: false,
|
|
506
|
+
shouldRestoreFocus: false,
|
|
507
|
+
slotProps: { paper: {
|
|
508
|
+
p: 0,
|
|
509
|
+
bg,
|
|
510
|
+
borderRadius,
|
|
511
|
+
style: { minWidth: anchorEl?.offsetWidth }
|
|
512
|
+
} },
|
|
513
|
+
children: /* @__PURE__ */ jsx(ListBox, {
|
|
514
|
+
role: "listbox",
|
|
515
|
+
id: listboxId,
|
|
516
|
+
"aria-multiselectable": multiple || void 0,
|
|
517
|
+
"aria-labelledby": labelId,
|
|
518
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
519
|
+
children: renderedItems
|
|
520
|
+
})
|
|
521
|
+
})
|
|
522
|
+
] });
|
|
523
|
+
}
|
|
524
|
+
//#endregion
|
|
525
|
+
export { Select };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_src = require("./src-BiocWFSR.cjs");
|
|
3
|
+
require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
|
|
6
|
+
let _emotion_react = require("@emotion/react");
|
|
7
|
+
//#region src/Skeleton/Skeleton.tsx
|
|
8
|
+
const shouldForwardProp = (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([
|
|
9
|
+
..._soroush_tech_styled_system_should_forward_prop.props,
|
|
10
|
+
"variant",
|
|
11
|
+
"animation",
|
|
12
|
+
"width",
|
|
13
|
+
"height"
|
|
14
|
+
]);
|
|
15
|
+
const pulse = (0, _emotion_react.keyframes)({
|
|
16
|
+
"0%": { opacity: 1 },
|
|
17
|
+
"50%": { opacity: .4 },
|
|
18
|
+
"100%": { opacity: 1 }
|
|
19
|
+
});
|
|
20
|
+
const wave = (0, _emotion_react.keyframes)({
|
|
21
|
+
from: { backgroundPositionX: "100vw" },
|
|
22
|
+
to: { backgroundPositionX: "-100vw" }
|
|
23
|
+
});
|
|
24
|
+
const shapeVariants = (0, require_src.src_exports.variant)({
|
|
25
|
+
prop: "variant",
|
|
26
|
+
variants: {
|
|
27
|
+
text: { borderRadius: "sm" },
|
|
28
|
+
rectangular: { borderRadius: "sq" }
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const radiusSystem = (0, require_src.src_exports.system)({ borderRadius: {
|
|
32
|
+
property: "borderRadius",
|
|
33
|
+
scale: "radii"
|
|
34
|
+
} });
|
|
35
|
+
const circularStyle = ({ variant }) => variant === "circular" ? { borderRadius: "50%" } : {};
|
|
36
|
+
const baseStyle = ({ theme }) => ({
|
|
37
|
+
display: "block",
|
|
38
|
+
backgroundColor: theme.background.default
|
|
39
|
+
});
|
|
40
|
+
const dimensionStyle = ({ width, height, variant }) => ({
|
|
41
|
+
width,
|
|
42
|
+
height: height ?? (variant === "text" ? "auto" : void 0),
|
|
43
|
+
...variant === "text" && height === void 0 ? { "&:empty::before": { content: String.raw`"\00a0"` } } : {}
|
|
44
|
+
});
|
|
45
|
+
const animationStyle = ({ animation, theme }) => {
|
|
46
|
+
if (animation === "pulse") return { animation: `${pulse} 2s ease-in-out infinite` };
|
|
47
|
+
if (animation === "wave") return {
|
|
48
|
+
backgroundImage: `linear-gradient(90deg, transparent, ${theme.skeleton.highlight}, transparent)`,
|
|
49
|
+
backgroundRepeat: "no-repeat",
|
|
50
|
+
backgroundSize: "50vw 100%",
|
|
51
|
+
backgroundAttachment: "fixed",
|
|
52
|
+
animation: `${wave} 1.6s linear infinite`
|
|
53
|
+
};
|
|
54
|
+
return {};
|
|
55
|
+
};
|
|
56
|
+
const SkeletonRoot = require_src.styled("span", {
|
|
57
|
+
name: "Skeleton",
|
|
58
|
+
label: "skeleton",
|
|
59
|
+
shouldForwardProp,
|
|
60
|
+
systemProps: [require_src.src_exports.space]
|
|
61
|
+
})(baseStyle, shapeVariants, radiusSystem, circularStyle, animationStyle, dimensionStyle, { "@media (prefers-reduced-motion: reduce)": { animation: "none" } });
|
|
62
|
+
const HiddenContent = require_src.styled("span", {
|
|
63
|
+
name: "Skeleton",
|
|
64
|
+
slot: "content",
|
|
65
|
+
label: "SkeletonContent"
|
|
66
|
+
})({
|
|
67
|
+
visibility: "hidden",
|
|
68
|
+
display: "block"
|
|
69
|
+
});
|
|
70
|
+
function Skeleton({ variant = "text", animation = "pulse", width, height, children, ...rest }) {
|
|
71
|
+
const hasChildren = children != null && children !== "";
|
|
72
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SkeletonRoot, {
|
|
73
|
+
variant,
|
|
74
|
+
animation,
|
|
75
|
+
width: width ?? (hasChildren ? "fit-content" : void 0),
|
|
76
|
+
height,
|
|
77
|
+
...rest,
|
|
78
|
+
children: hasChildren ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HiddenContent, { children }) : null
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
exports.Skeleton = Skeleton;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { l as index_d_exports, o as Theme } from "./index-Bihpwn75.cjs";
|
|
2
|
+
import { HTMLAttributes } from "react";
|
|
3
|
+
//#region src/Skeleton/Skeleton.d.ts
|
|
4
|
+
type SkeletonVariant = 'text' | 'circular' | 'rectangular';
|
|
5
|
+
type SkeletonAnimation = 'pulse' | 'wave' | false;
|
|
6
|
+
type SkeletonRadius = keyof Theme['radii'];
|
|
7
|
+
interface SkeletonProps extends HTMLAttributes<HTMLSpanElement>, Omit<index_d_exports.SpaceProps<Theme>, keyof index_d_exports.PaddingProps> {
|
|
8
|
+
/** Shape of the placeholder. Default: `'text'`. */
|
|
9
|
+
variant?: SkeletonVariant;
|
|
10
|
+
/** Corner radius — resolves against `theme.radii` (sq · sm · md · lg). Overrides the variant default. */
|
|
11
|
+
borderRadius?: SkeletonRadius;
|
|
12
|
+
/** Loading animation. `false` disables it. Default: `'pulse'`. */
|
|
13
|
+
animation?: SkeletonAnimation;
|
|
14
|
+
/** Width. Number → px; string → raw CSS unit (e.g. `'10rem'`). Inferred from children when omitted. */
|
|
15
|
+
width?: number | string;
|
|
16
|
+
/** Height. Number → px; string → raw CSS unit. */
|
|
17
|
+
height?: number | string;
|
|
18
|
+
}
|
|
19
|
+
declare function Skeleton({ variant, animation, width, height, children, ...rest }: Readonly<SkeletonProps>): import("react").JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Skeleton, SkeletonAnimation, SkeletonProps, SkeletonRadius, SkeletonVariant };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { l as index_d_exports, o as Theme } from "./index-Dm9HfgV6.mjs";
|
|
2
|
+
import { HTMLAttributes } from "react";
|
|
3
|
+
//#region src/Skeleton/Skeleton.d.ts
|
|
4
|
+
type SkeletonVariant = 'text' | 'circular' | 'rectangular';
|
|
5
|
+
type SkeletonAnimation = 'pulse' | 'wave' | false;
|
|
6
|
+
type SkeletonRadius = keyof Theme['radii'];
|
|
7
|
+
interface SkeletonProps extends HTMLAttributes<HTMLSpanElement>, Omit<index_d_exports.SpaceProps<Theme>, keyof index_d_exports.PaddingProps> {
|
|
8
|
+
/** Shape of the placeholder. Default: `'text'`. */
|
|
9
|
+
variant?: SkeletonVariant;
|
|
10
|
+
/** Corner radius — resolves against `theme.radii` (sq · sm · md · lg). Overrides the variant default. */
|
|
11
|
+
borderRadius?: SkeletonRadius;
|
|
12
|
+
/** Loading animation. `false` disables it. Default: `'pulse'`. */
|
|
13
|
+
animation?: SkeletonAnimation;
|
|
14
|
+
/** Width. Number → px; string → raw CSS unit (e.g. `'10rem'`). Inferred from children when omitted. */
|
|
15
|
+
width?: number | string;
|
|
16
|
+
/** Height. Number → px; string → raw CSS unit. */
|
|
17
|
+
height?: number | string;
|
|
18
|
+
}
|
|
19
|
+
declare function Skeleton({ variant, animation, width, height, children, ...rest }: Readonly<SkeletonProps>): import("react").JSX.Element;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Skeleton, SkeletonAnimation, SkeletonProps, SkeletonRadius, SkeletonVariant };
|