@gild-ui/react 0.0.0 → 0.1.0-alpha.1
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 +399 -1
- package/dist/Accordion.cjs +338 -0
- package/dist/Accordion.d.cts +110 -0
- package/dist/Accordion.d.mts +110 -0
- package/dist/Accordion.mjs +334 -0
- package/dist/Accordion.types-DxvwAfZc.d.mts +1299 -0
- package/dist/Alert.cjs +187 -0
- package/dist/Alert.d.cts +51 -0
- package/dist/Alert.d.mts +51 -0
- package/dist/Alert.mjs +186 -0
- package/dist/AppBar.cjs +76 -0
- package/dist/AppBar.d.cts +22 -0
- package/dist/AppBar.d.mts +22 -0
- package/dist/AppBar.mjs +76 -0
- package/dist/Autocomplete.cjs +685 -0
- package/dist/Autocomplete.d.cts +97 -0
- package/dist/Autocomplete.d.mts +97 -0
- package/dist/Autocomplete.mjs +685 -0
- package/dist/Avatar.cjs +113 -0
- package/dist/Avatar.d.cts +27 -0
- package/dist/Avatar.d.mts +27 -0
- package/dist/Avatar.mjs +113 -0
- package/dist/Backdrop.cjs +30 -0
- package/dist/Backdrop.d.cts +11 -0
- package/dist/Backdrop.d.mts +11 -0
- package/dist/Backdrop.mjs +29 -0
- package/dist/Badge.cjs +136 -0
- package/dist/Badge.d.cts +47 -0
- package/dist/Badge.d.mts +47 -0
- package/dist/Badge.mjs +136 -0
- package/dist/Breadcrumbs.cjs +150 -0
- package/dist/Breadcrumbs.d.cts +33 -0
- package/dist/Breadcrumbs.d.mts +33 -0
- package/dist/Breadcrumbs.mjs +149 -0
- package/dist/Button.cjs +194 -0
- package/dist/Button.d.cts +3 -0
- package/dist/Button.d.mts +3 -0
- package/dist/Button.mjs +194 -0
- package/dist/ButtonGroup.cjs +116 -0
- package/dist/ButtonGroup.d.cts +43 -0
- package/dist/ButtonGroup.d.mts +3 -0
- package/dist/ButtonGroup.mjs +115 -0
- package/dist/ButtonGroupContext-D5Fg5Slq.mjs +5 -0
- package/dist/ButtonGroupContext-W4VkHwoR.cjs +9 -0
- package/dist/CacheProvider.cjs +9 -0
- package/dist/CacheProvider.d.cts +4 -0
- package/dist/CacheProvider.d.mts +4 -0
- package/dist/CacheProvider.mjs +9 -0
- package/dist/Card.cjs +105 -0
- package/dist/Card.d.cts +19 -0
- package/dist/Card.d.mts +19 -0
- package/dist/Card.mjs +105 -0
- package/dist/Checkbox.cjs +210 -0
- package/dist/Checkbox.d.cts +48 -0
- package/dist/Checkbox.d.mts +48 -0
- package/dist/Checkbox.mjs +210 -0
- package/dist/Chip.cjs +210 -0
- package/dist/Chip.d.cts +51 -0
- package/dist/Chip.d.mts +51 -0
- package/dist/Chip.mjs +210 -0
- package/dist/CircularProgress.cjs +151 -0
- package/dist/CircularProgress.d.cts +37 -0
- package/dist/CircularProgress.d.mts +37 -0
- package/dist/CircularProgress.mjs +151 -0
- package/dist/Collapse.cjs +133 -0
- package/dist/Collapse.d.cts +38 -0
- package/dist/Collapse.d.mts +3 -0
- package/dist/Collapse.mjs +133 -0
- package/dist/Drawer.cjs +168 -0
- package/dist/Drawer.d.cts +60 -0
- package/dist/Drawer.d.mts +60 -0
- package/dist/Drawer.mjs +166 -0
- package/dist/Fab.cjs +123 -0
- package/dist/Fab.d.cts +33 -0
- package/dist/Fab.d.mts +3 -0
- package/dist/Fab.mjs +122 -0
- package/dist/FabMenu.cjs +312 -0
- package/dist/FabMenu.d.cts +70 -0
- package/dist/FabMenu.d.mts +70 -0
- package/dist/FabMenu.mjs +311 -0
- package/dist/Fade.cjs +17 -0
- package/dist/Fade.d.cts +8 -0
- package/dist/Fade.d.mts +8 -0
- package/dist/Fade.mjs +16 -0
- package/dist/Flex.cjs +18 -0
- package/dist/Flex.d.cts +2 -0
- package/dist/Flex.d.mts +2 -0
- package/dist/Flex.mjs +17 -0
- package/dist/FocusTrap.cjs +87 -0
- package/dist/FocusTrap.d.cts +28 -0
- package/dist/FocusTrap.d.mts +28 -0
- package/dist/FocusTrap.mjs +86 -0
- package/dist/Form.cjs +47 -0
- package/dist/Form.d.cts +41 -0
- package/dist/Form.d.mts +41 -0
- package/dist/Form.mjs +46 -0
- package/dist/FormContext-DfpxiqRO.cjs +9 -0
- package/dist/FormContext-fZHQHKUU.mjs +6 -0
- package/dist/FormControl.cjs +98 -0
- package/dist/FormControl.d.cts +81 -0
- package/dist/FormControl.d.mts +81 -0
- package/dist/FormControl.mjs +96 -0
- package/dist/FormControlContext-Btvm04Sj.cjs +9 -0
- package/dist/FormControlContext-CaQLS_sK.mjs +6 -0
- package/dist/FormHelperText.cjs +40 -0
- package/dist/FormHelperText.d.cts +15 -0
- package/dist/FormHelperText.d.mts +15 -0
- package/dist/FormHelperText.mjs +39 -0
- package/dist/FormLabel.cjs +45 -0
- package/dist/FormLabel.d.cts +17 -0
- package/dist/FormLabel.d.mts +17 -0
- package/dist/FormLabel.mjs +44 -0
- package/dist/Global.cjs +8 -0
- package/dist/Global.d.cts +2 -0
- package/dist/Global.d.mts +2 -0
- package/dist/Global.mjs +1 -0
- package/dist/Grid.cjs +20 -0
- package/dist/Grid.d.cts +25 -0
- package/dist/Grid.d.mts +25 -0
- package/dist/Grid.mjs +20 -0
- package/dist/Grow.cjs +21 -0
- package/dist/Grow.d.cts +8 -0
- package/dist/Grow.d.mts +8 -0
- package/dist/Grow.mjs +20 -0
- package/dist/Icon-DBgqmUb3.mjs +916 -0
- package/dist/Icon-DPIqGixm.cjs +927 -0
- package/dist/Icon.cjs +4 -0
- package/dist/Icon.d.cts +3 -0
- package/dist/Icon.d.mts +3 -0
- package/dist/Icon.mjs +1 -0
- package/dist/Image.cjs +89 -0
- package/dist/Image.d.cts +19 -0
- package/dist/Image.d.mts +19 -0
- package/dist/Image.mjs +89 -0
- package/dist/LayoutProvider-DFwC1-h0.d.cts +19 -0
- package/dist/LayoutProvider-DFwC1-h0.d.mts +19 -0
- package/dist/LayoutProvider-Eb5Vp2BZ.mjs +36 -0
- package/dist/LayoutProvider-nB0hiaCR.cjs +41 -0
- package/dist/LayoutProvider.cjs +3 -0
- package/dist/LayoutProvider.d.cts +2 -0
- package/dist/LayoutProvider.d.mts +2 -0
- package/dist/LayoutProvider.mjs +1 -0
- package/dist/LinearProgress.cjs +232 -0
- package/dist/LinearProgress.d.cts +39 -0
- package/dist/LinearProgress.d.mts +39 -0
- package/dist/LinearProgress.mjs +232 -0
- package/dist/Link.cjs +59 -0
- package/dist/Link.d.cts +9 -0
- package/dist/Link.d.mts +9 -0
- package/dist/Link.mjs +59 -0
- package/dist/Menu-Ca7aUnLg.mjs +229 -0
- package/dist/Menu-DlPDdIAu.cjs +245 -0
- package/dist/Menu.cjs +174 -0
- package/dist/Menu.d.cts +209 -0
- package/dist/Menu.d.mts +209 -0
- package/dist/Menu.mjs +168 -0
- package/dist/MenuItem-2UwOFsM6.cjs +859 -0
- package/dist/MenuItem-w7D1-AYW.mjs +807 -0
- package/dist/MenuItem.cjs +4 -0
- package/dist/MenuItem.d.cts +3 -0
- package/dist/MenuItem.d.mts +3 -0
- package/dist/MenuItem.mjs +2 -0
- package/dist/Modal-B6_1ugIW.cjs +328 -0
- package/dist/Modal-Ouz9KdOG.mjs +300 -0
- package/dist/Modal.cjs +8 -0
- package/dist/Modal.d.cts +57 -0
- package/dist/Modal.d.mts +3 -0
- package/dist/Modal.mjs +2 -0
- package/dist/NativeSelect.cjs +197 -0
- package/dist/NativeSelect.d.cts +65 -0
- package/dist/NativeSelect.d.mts +65 -0
- package/dist/NativeSelect.mjs +197 -0
- package/dist/NavTree.cjs +225 -0
- package/dist/NavTree.d.cts +65 -0
- package/dist/NavTree.d.mts +65 -0
- package/dist/NavTree.mjs +223 -0
- package/dist/NumberInput.cjs +513 -0
- package/dist/NumberInput.d.cts +96 -0
- package/dist/NumberInput.d.mts +96 -0
- package/dist/NumberInput.mjs +512 -0
- package/dist/Pagination.cjs +258 -0
- package/dist/Pagination.d.cts +90 -0
- package/dist/Pagination.d.mts +3 -0
- package/dist/Pagination.mjs +256 -0
- package/dist/Paper.cjs +54 -0
- package/dist/Paper.d.cts +2 -0
- package/dist/Paper.d.mts +3 -0
- package/dist/Paper.mjs +54 -0
- package/dist/Popover-ZsN1txGi.mjs +139 -0
- package/dist/Popover-d5fip8Fi.cjs +143 -0
- package/dist/Popover.cjs +4 -0
- package/dist/Popover.d.cts +67 -0
- package/dist/Popover.d.mts +67 -0
- package/dist/Popover.mjs +2 -0
- package/dist/Portal.cjs +22 -0
- package/dist/Portal.d.cts +15 -0
- package/dist/Portal.d.mts +2 -0
- package/dist/Portal.mjs +21 -0
- package/dist/Pressable.cjs +134 -0
- package/dist/Pressable.d.cts +52 -0
- package/dist/Pressable.d.mts +3 -0
- package/dist/Pressable.mjs +134 -0
- package/dist/Quote.cjs +11 -0
- package/dist/Quote.d.cts +15 -0
- package/dist/Quote.d.mts +15 -0
- package/dist/Quote.mjs +10 -0
- package/dist/Radio.cjs +161 -0
- package/dist/Radio.d.cts +43 -0
- package/dist/Radio.d.mts +43 -0
- package/dist/Radio.mjs +161 -0
- package/dist/RangeInput.cjs +705 -0
- package/dist/RangeInput.d.cts +77 -0
- package/dist/RangeInput.d.mts +77 -0
- package/dist/RangeInput.mjs +705 -0
- package/dist/Rating.cjs +390 -0
- package/dist/Rating.d.cts +59 -0
- package/dist/Rating.d.mts +59 -0
- package/dist/Rating.mjs +390 -0
- package/dist/ScrollArea.cjs +282 -0
- package/dist/ScrollArea.d.cts +40 -0
- package/dist/ScrollArea.d.mts +40 -0
- package/dist/ScrollArea.mjs +281 -0
- package/dist/Select.cjs +528 -0
- package/dist/Select.d.cts +69 -0
- package/dist/Select.d.mts +69 -0
- package/dist/Select.mjs +528 -0
- package/dist/Sidebar.cjs +332 -0
- package/dist/Sidebar.d.cts +156 -0
- package/dist/Sidebar.d.mts +156 -0
- package/dist/Sidebar.mjs +330 -0
- package/dist/Skeleton.cjs +90 -0
- package/dist/Skeleton.d.cts +24 -0
- package/dist/Skeleton.d.mts +24 -0
- package/dist/Skeleton.mjs +90 -0
- package/dist/Slide.cjs +57 -0
- package/dist/Slide.d.cts +14 -0
- package/dist/Slide.d.mts +14 -0
- package/dist/Slide.mjs +56 -0
- package/dist/Snackbar.cjs +216 -0
- package/dist/Snackbar.d.cts +81 -0
- package/dist/Snackbar.d.mts +81 -0
- package/dist/Snackbar.mjs +215 -0
- package/dist/StyleSheet.cjs +8 -0
- package/dist/StyleSheet.d.cts +2 -0
- package/dist/StyleSheet.d.mts +2 -0
- package/dist/StyleSheet.mjs +1 -0
- package/dist/Switch.cjs +355 -0
- package/dist/Switch.d.cts +45 -0
- package/dist/Switch.d.mts +45 -0
- package/dist/Switch.mjs +355 -0
- package/dist/Table.cjs +722 -0
- package/dist/Table.d.cts +404 -0
- package/dist/Table.d.mts +404 -0
- package/dist/Table.mjs +707 -0
- package/dist/Tabs.cjs +1227 -0
- package/dist/Tabs.d.cts +245 -0
- package/dist/Tabs.d.mts +245 -0
- package/dist/Tabs.mjs +1222 -0
- package/dist/TextInput.cjs +236 -0
- package/dist/TextInput.d.cts +3 -0
- package/dist/TextInput.d.mts +3 -0
- package/dist/TextInput.mjs +236 -0
- package/dist/ThemeProvider-DS6pBgE-.cjs +68 -0
- package/dist/ThemeProvider-DuhfCo2F.mjs +63 -0
- package/dist/ThemeProvider.cjs +4 -0
- package/dist/ThemeProvider.d.cts +2 -0
- package/dist/ThemeProvider.d.mts +2 -0
- package/dist/ThemeProvider.mjs +2 -0
- package/dist/ToggleButton.cjs +115 -0
- package/dist/ToggleButton.d.cts +51 -0
- package/dist/ToggleButton.d.mts +51 -0
- package/dist/ToggleButton.mjs +113 -0
- package/dist/Tooltip-Bt5lr52c.mjs +485 -0
- package/dist/Tooltip-CUpZpoC9.cjs +495 -0
- package/dist/Tooltip.cjs +5 -0
- package/dist/Tooltip.d.cts +122 -0
- package/dist/Tooltip.d.mts +122 -0
- package/dist/Tooltip.mjs +2 -0
- package/dist/TransferList.cjs +394 -0
- package/dist/TransferList.d.cts +69 -0
- package/dist/TransferList.d.mts +69 -0
- package/dist/TransferList.mjs +394 -0
- package/dist/Typography.cjs +69 -0
- package/dist/Typography.d.cts +3 -0
- package/dist/Typography.d.mts +3 -0
- package/dist/Typography.mjs +69 -0
- package/dist/View-DFnZ41Xe.cjs +77 -0
- package/dist/View-zuvgW6DP.mjs +66 -0
- package/dist/View.cjs +3 -0
- package/dist/View.d.cts +2 -0
- package/dist/View.d.mts +2 -0
- package/dist/View.mjs +1 -0
- package/dist/Zoom.cjs +16 -0
- package/dist/Zoom.d.cts +7 -0
- package/dist/Zoom.d.mts +7 -0
- package/dist/Zoom.mjs +15 -0
- package/dist/catalog.cjs +22 -0
- package/dist/catalog.d.cts +28 -0
- package/dist/catalog.d.mts +28 -0
- package/dist/catalog.mjs +21 -0
- package/dist/computePopoverPosition-C6qSQ1QD.cjs +126 -0
- package/dist/computePopoverPosition-DHV1wQgJ.mjs +121 -0
- package/dist/computePopoverPosition-JgOwCM7k.d.cts +12 -0
- package/dist/computePopoverPosition-JgOwCM7k.d.mts +12 -0
- package/dist/css.cjs +20 -0
- package/dist/css.d.cts +2 -0
- package/dist/css.d.mts +2 -0
- package/dist/css.mjs +1 -0
- package/dist/derivedTheme-B0cxTzAq.cjs +29 -0
- package/dist/derivedTheme-BB9VVZ08.mjs +24 -0
- package/dist/engine.cjs +146 -0
- package/dist/engine.d.cts +59 -0
- package/dist/engine.d.mts +59 -0
- package/dist/engine.mjs +101 -0
- package/dist/getElementRef-4m6-x2FS.cjs +18 -0
- package/dist/getElementRef-SBx9_7pp.mjs +13 -0
- package/dist/index-B3jHcw5h.d.cts +175 -0
- package/dist/index-Bf-ZHQLG.d.mts +33 -0
- package/dist/index-CAMwJg71.d.mts +92 -0
- package/dist/index-CLQt_mOa.d.mts +3 -0
- package/dist/index-Cqse4F32.d.mts +38 -0
- package/dist/index-CsYK-ukA.d.mts +3 -0
- package/dist/index-D9Gg2NWm.d.mts +90 -0
- package/dist/index-DPQxIeZF.d.cts +1299 -0
- package/dist/index-Dc7XiT_v.d.cts +92 -0
- package/dist/index-Djum1XiO.d.mts +52 -0
- package/dist/index-DtfH-dhY.d.mts +43 -0
- package/dist/index-IB1nBqEO.d.mts +175 -0
- package/dist/index-UloRwym_.d.mts +16 -0
- package/dist/index-phuw9VpI.d.mts +57 -0
- package/dist/index-yCzwpbBP.d.mts +1 -0
- package/dist/index.cjs +93 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +17 -0
- package/dist/inputVariantStyles-B-4lHxUZ.mjs +41 -0
- package/dist/inputVariantStyles-CqCQatKb.cjs +58 -0
- package/dist/isRtl-DN-EdUlg.mjs +6 -0
- package/dist/isRtl-Dl6QQWib.cjs +11 -0
- package/dist/keyframes.cjs +8 -0
- package/dist/keyframes.d.cts +2 -0
- package/dist/keyframes.d.mts +2 -0
- package/dist/keyframes.mjs +1 -0
- package/dist/next.cjs +8 -0
- package/dist/next.d.cts +2 -0
- package/dist/next.d.mts +2 -0
- package/dist/next.mjs +1 -0
- package/dist/overrides-DeXScOFK.cjs +21 -0
- package/dist/overrides-Ds6QZL5Q.mjs +16 -0
- package/dist/server.cjs +19 -0
- package/dist/server.d.cts +10 -0
- package/dist/server.d.mts +10 -0
- package/dist/server.mjs +18 -0
- package/dist/styleEngine-CLid4cmR.mjs +1 -0
- package/dist/styled-Dr3_OY1-.cjs +48 -0
- package/dist/styled-tLHNvicL.mjs +43 -0
- package/dist/styled.cjs +3 -0
- package/dist/styled.d.cts +2 -0
- package/dist/styled.d.mts +2 -0
- package/dist/styled.mjs +1 -0
- package/dist/testing.cjs +60 -0
- package/dist/testing.d.cts +6 -0
- package/dist/testing.d.mts +6 -0
- package/dist/testing.mjs +59 -0
- package/dist/themes-BtfQPcbo.mjs +8 -0
- package/dist/themes-k-PEE5O9.cjs +12 -0
- package/dist/useAnchoredPlacement-CSotv28V.cjs +116 -0
- package/dist/useAnchoredPlacement-VwHtXnAx.mjs +111 -0
- package/dist/useDefaultProps-BTQGhvfY.mjs +13 -0
- package/dist/useDefaultProps-DratGGIL.cjs +18 -0
- package/dist/useDefaultProps.cjs +3 -0
- package/dist/useDefaultProps.d.cts +2 -0
- package/dist/useDefaultProps.d.mts +2 -0
- package/dist/useDefaultProps.mjs +1 -0
- package/dist/useLiveValue-CN2SUG2B.cjs +20 -0
- package/dist/useLiveValue-CqiwCr56.mjs +15 -0
- package/dist/useMediaQuery-acJak9M3.mjs +2 -0
- package/dist/useMediaQuery.cjs +9 -0
- package/dist/useMediaQuery.d.cts +2 -0
- package/dist/useMediaQuery.d.mts +2 -0
- package/dist/useMediaQuery.mjs +2 -0
- package/dist/useStyle.cjs +14 -0
- package/dist/useStyle.d.cts +2 -0
- package/dist/useStyle.d.mts +2 -0
- package/dist/useStyle.mjs +1 -0
- package/dist/useTheme.cjs +8 -0
- package/dist/useTheme.d.cts +2 -0
- package/dist/useTheme.d.mts +2 -0
- package/dist/useTheme.mjs +1 -0
- package/dist/useTransition-BKBtk0Mb.mjs +78 -0
- package/dist/useTransition-BzwifRXe.d.mts +40 -0
- package/dist/useTransition-gHFCJwqF.cjs +83 -0
- package/dist/useTransition-lt8_WKk-.d.cts +40 -0
- package/dist/useTransitionChild-C18w474Q.mjs +52 -0
- package/dist/useTransitionChild-DD3f44AQ.cjs +57 -0
- package/dist/utils-ChXrUitU.mjs +1 -0
- package/dist/withStyle.cjs +8 -0
- package/dist/withStyle.d.cts +2 -0
- package/dist/withStyle.d.mts +2 -0
- package/dist/withStyle.mjs +1 -0
- package/dist/withTheme.cjs +8 -0
- package/dist/withTheme.d.cts +2 -0
- package/dist/withTheme.d.mts +2 -0
- package/dist/withTheme.mjs +1 -0
- package/package.json +911 -3
package/dist/Modal.d.cts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { $n as ModalCloseReason, er as ModalOwnerState, ir as ModalThemeConfig, nr as ModalScroll, rr as ModalSlot, tr as ModalProps } from "./index-DPQxIeZF.cjs";
|
|
2
|
+
import { KeyboardEvent, MouseEvent, Ref, RefCallback, SyntheticEvent } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* @description Accessible overlay primitive: portals its content, dims the page,
|
|
5
|
+
* traps focus, locks scroll, and closes on Escape or backdrop click. The base for
|
|
6
|
+
* higher-level overlays such as Drawer.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Modal({ isOpen, children, onClose, hasBackdrop, shouldKeepMounted, shouldUsePortal, portalContainer, shouldLockScroll, disableAriaHidden, shouldAutoFocus, shouldTrapFocus, shouldEnforceFocus, shouldRestoreFocus, scroll, layer, style, className, slotProps }: Readonly<ModalProps>): import("react").JSX.Element | null;
|
|
9
|
+
type EventHandlers = Record<string, ((event: SyntheticEvent) => void) | undefined>;
|
|
10
|
+
export interface UseModalParameters {
|
|
11
|
+
/** Whether the modal is shown. */
|
|
12
|
+
isOpen: boolean;
|
|
13
|
+
/** Fired on Escape (top modal only) or backdrop click. */
|
|
14
|
+
onClose?: (event: KeyboardEvent | MouseEvent, reason: ModalCloseReason) => void;
|
|
15
|
+
/** Portal container, or a function returning one. Defaults to the document body. */
|
|
16
|
+
container?: HTMLElement | (() => HTMLElement | null) | null;
|
|
17
|
+
/** Disable body scroll-lock while open. */
|
|
18
|
+
disableScrollLock?: boolean;
|
|
19
|
+
/** Skip `aria-hidden` on background siblings (for non-modal popovers). */
|
|
20
|
+
disableAriaHidden?: boolean;
|
|
21
|
+
/** Forwarded ref for the modal root element. */
|
|
22
|
+
rootRef?: Ref<Element>;
|
|
23
|
+
}
|
|
24
|
+
export interface UseModalReturnValue {
|
|
25
|
+
getRootProps: (otherHandlers?: EventHandlers) => Record<string, unknown>;
|
|
26
|
+
getBackdropProps: (otherHandlers?: EventHandlers) => Record<string, unknown>;
|
|
27
|
+
rootRef: RefCallback<Element> | null;
|
|
28
|
+
portalRef: (node: HTMLElement | null) => void;
|
|
29
|
+
isTopModal: () => boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare function useModal(parameters: UseModalParameters): UseModalReturnValue;
|
|
32
|
+
/** A modal tracked by the manager: its portal mount node and its root element. */
|
|
33
|
+
export interface ManagedModal {
|
|
34
|
+
mount: Element;
|
|
35
|
+
modalRef: Element;
|
|
36
|
+
}
|
|
37
|
+
export interface ManagedModalProps {
|
|
38
|
+
disableScrollLock?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Hides an element from assistive tech. */
|
|
41
|
+
export declare function hideFromAria(element: Element): void;
|
|
42
|
+
/** Reveals an element to assistive tech again. */
|
|
43
|
+
export declare function exposeToAria(element: Element): void;
|
|
44
|
+
/**
|
|
45
|
+
* Tracks every open modal and the containers they live in. A single shared
|
|
46
|
+
* instance coordinates stacking (`isTopModal`), scroll-lock, and `aria-hidden`
|
|
47
|
+
* on background siblings so assistive tech only sees the active modal.
|
|
48
|
+
*/
|
|
49
|
+
export declare class ModalManager {
|
|
50
|
+
private readonly modals;
|
|
51
|
+
private readonly containers;
|
|
52
|
+
add(modal: ManagedModal, container: HTMLElement, disableAriaHidden?: boolean): number;
|
|
53
|
+
mount(modal: ManagedModal, props: ManagedModalProps): void;
|
|
54
|
+
remove(modal: ManagedModal, ariaHiddenState?: boolean): number;
|
|
55
|
+
isTopModal(modal: ManagedModal): boolean;
|
|
56
|
+
}
|
|
57
|
+
export { ModalCloseReason, ModalOwnerState, ModalProps, ModalScroll, ModalSlot, ModalThemeConfig };
|
package/dist/Modal.d.mts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Fn as ModalProps, In as ModalScroll, Ln as ModalSlot, Nn as ModalCloseReason, Pn as ModalOwnerState, Rn as ModalThemeConfig } from "./Accordion.types-DxvwAfZc.mjs";
|
|
2
|
+
import { a as hideFromAria, c as useModal, i as exposeToAria, l as Modal, n as ManagedModalProps, o as UseModalParameters, r as ModalManager, s as UseModalReturnValue, t as ManagedModal } from "./index-phuw9VpI.mjs";
|
|
3
|
+
export { ManagedModal, ManagedModalProps, Modal, ModalCloseReason, ModalManager, ModalOwnerState, ModalProps, ModalScroll, ModalSlot, ModalThemeConfig, UseModalParameters, UseModalReturnValue, exposeToAria, hideFromAria, useModal };
|
package/dist/Modal.mjs
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_FormControl = require("./FormControl.cjs");
|
|
4
|
+
const require_Icon = require("./Icon-DPIqGixm.cjs");
|
|
5
|
+
const require_styled = require("./styled-Dr3_OY1-.cjs");
|
|
6
|
+
const require_overrides = require("./overrides-DeXScOFK.cjs");
|
|
7
|
+
const require_inputVariantStyles = require("./inputVariantStyles-CqCQatKb.cjs");
|
|
8
|
+
require("react");
|
|
9
|
+
let _gild_ui_core_theme = require("@gild-ui/core/theme");
|
|
10
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
|
+
let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
|
|
12
|
+
let _soroush_tech_styled_system = require("@soroush.tech/styled-system");
|
|
13
|
+
let _umber_style_react = require("@umber-style/react");
|
|
14
|
+
// src/NativeSelect/NativeSelect.tsx
|
|
15
|
+
const shouldForwardProp = (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([
|
|
16
|
+
..._soroush_tech_styled_system_should_forward_prop.props,
|
|
17
|
+
"color",
|
|
18
|
+
"textColor",
|
|
19
|
+
"variant",
|
|
20
|
+
"error",
|
|
21
|
+
"disabled",
|
|
22
|
+
"fullWidth"
|
|
23
|
+
]);
|
|
24
|
+
const baseStyle = {
|
|
25
|
+
position: "relative",
|
|
26
|
+
display: "inline-flex",
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
transition: "border-color 0.15s ease"
|
|
29
|
+
};
|
|
30
|
+
const backgroundStyle = ({ theme, textColor, color = (0, _gild_ui_core_theme.themeDefault)(theme, "color", "primary"), bg = (0, _gild_ui_core_theme.themeDefault)(theme, "inputBg", "terminal") }) => {
|
|
31
|
+
return {
|
|
32
|
+
backgroundColor: (0, _soroush_tech_styled_system.get)(theme, `background.${bg}`),
|
|
33
|
+
color: textColor ? (0, _soroush_tech_styled_system.get)(theme, `text.${textColor}`) : (0, _soroush_tech_styled_system.get)(theme, `palette.${color}.main`),
|
|
34
|
+
fontFamily: (0, _soroush_tech_styled_system.get)(theme, "fonts.body"),
|
|
35
|
+
fontSize: (0, _soroush_tech_styled_system.get)(theme, "fontSizes.1"),
|
|
36
|
+
lineHeight: (0, _soroush_tech_styled_system.get)(theme, "lineHeights.base")
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const colorBorder = ({ theme, color = (0, _gild_ui_core_theme.themeDefault)(theme, "color", "primary"), error }) => {
|
|
40
|
+
return { borderColor: error ? (0, _soroush_tech_styled_system.get)(theme, "palette.error.main") : (0, _soroush_tech_styled_system.get)(theme, `palette.${color}.light`) };
|
|
41
|
+
};
|
|
42
|
+
const focusWithinColor = ({ theme, color = (0, _gild_ui_core_theme.themeDefault)(theme, "color", "primary"), error }) => {
|
|
43
|
+
return { "&:focus-within": { borderColor: error ? (0, _soroush_tech_styled_system.get)(theme, "palette.error.main") : (0, _soroush_tech_styled_system.get)(theme, `palette.${color}.main`) } };
|
|
44
|
+
};
|
|
45
|
+
const focusVisibleRing = ({ theme, color = (0, _gild_ui_core_theme.themeDefault)(theme, "color", "primary"), error }) => ({ "&:has(:focus-visible)": require_inputVariantStyles.getFocusRing(theme, color, error) });
|
|
46
|
+
const borderRadiusStyle = ({ variant: v = "default", borderRadius, theme }) => {
|
|
47
|
+
if (v === "underline" || v === "text" || !borderRadius) return {};
|
|
48
|
+
return { borderRadius: (0, _soroush_tech_styled_system.get)(theme, `radii.${borderRadius}`) };
|
|
49
|
+
};
|
|
50
|
+
const layoutStyles = ({ theme, fullWidth, disabled }) => ({
|
|
51
|
+
minWidth: require_inputVariantStyles.getInputMinWidth(theme),
|
|
52
|
+
...fullWidth ? {
|
|
53
|
+
display: "flex",
|
|
54
|
+
width: "100%"
|
|
55
|
+
} : {},
|
|
56
|
+
...disabled ? {
|
|
57
|
+
opacity: .5,
|
|
58
|
+
cursor: "not-allowed",
|
|
59
|
+
pointerEvents: "none"
|
|
60
|
+
} : {}
|
|
61
|
+
});
|
|
62
|
+
const widthStyles = (0, _soroush_tech_styled_system.system)({
|
|
63
|
+
width: true,
|
|
64
|
+
minWidth: true,
|
|
65
|
+
maxWidth: true
|
|
66
|
+
});
|
|
67
|
+
const NativeSelectRoot = require_styled.styled("div", {
|
|
68
|
+
name: "NativeSelect",
|
|
69
|
+
label: "NativeSelect",
|
|
70
|
+
shouldForwardProp,
|
|
71
|
+
systemProps: [_soroush_tech_styled_system.space, widthStyles]
|
|
72
|
+
})(baseStyle, require_inputVariantStyles.inputVariantStyles, borderRadiusStyle, colorBorder, focusWithinColor, focusVisibleRing, backgroundStyle, layoutStyles);
|
|
73
|
+
const shouldForwardNativeSelectProps = (prop) => prop !== "sizeToken" && prop !== "bg" && prop !== "textColor" && prop !== "accent";
|
|
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 = (0, _gild_ui_core_theme.themeDefault)(theme, "inputBg", "terminal"), textColor, accent }) => {
|
|
85
|
+
const backgroundColor = (0, _soroush_tech_styled_system.get)(theme, `background.${bg}`);
|
|
86
|
+
const color = textColor ? (0, _soroush_tech_styled_system.get)(theme, `text.${textColor}`) : (0, _soroush_tech_styled_system.get)(theme, `palette.${accent}.main`);
|
|
87
|
+
return {
|
|
88
|
+
backgroundColor,
|
|
89
|
+
color,
|
|
90
|
+
"& option": {
|
|
91
|
+
backgroundColor,
|
|
92
|
+
color
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
const StyledNativeSelect = require_styled.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_styled.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, style, slotProps, "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, _umber_style_react.useTheme)();
|
|
138
|
+
const color = fc.color ?? (0, _gild_ui_core_theme.themeDefault)(theme, "color", "primary");
|
|
139
|
+
const textColor = fc.textColor;
|
|
140
|
+
const variant = variantProp ?? (0, _gild_ui_core_theme.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
|
+
...require_overrides.mergeOverrides(slotProps?.root, {
|
|
156
|
+
style,
|
|
157
|
+
className
|
|
158
|
+
}),
|
|
159
|
+
"data-testid": dataTestid,
|
|
160
|
+
...spaceProps,
|
|
161
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(StyledNativeSelect, {
|
|
162
|
+
...selectProps,
|
|
163
|
+
...require_overrides.mergeOverrides({ className: selectProps?.className }, slotProps?.select),
|
|
164
|
+
id,
|
|
165
|
+
name,
|
|
166
|
+
disabled,
|
|
167
|
+
required,
|
|
168
|
+
sizeToken: size,
|
|
169
|
+
bg,
|
|
170
|
+
textColor,
|
|
171
|
+
accent: color,
|
|
172
|
+
value,
|
|
173
|
+
defaultValue: uncontrolledDefault,
|
|
174
|
+
onChange: handleChange,
|
|
175
|
+
"aria-describedby": selectProps?.["aria-describedby"] ?? fc["aria-describedby"],
|
|
176
|
+
children: [placeholder !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
177
|
+
value: "",
|
|
178
|
+
disabled: true,
|
|
179
|
+
hidden: true,
|
|
180
|
+
children: placeholder
|
|
181
|
+
}), options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
182
|
+
value: String(option.value),
|
|
183
|
+
children: option.label
|
|
184
|
+
}, String(option.value)))]
|
|
185
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DropdownIcon, {
|
|
186
|
+
name: iconName,
|
|
187
|
+
size,
|
|
188
|
+
color: "inherit",
|
|
189
|
+
...iconProps,
|
|
190
|
+
...require_overrides.mergeOverrides({
|
|
191
|
+
className: iconProps?.className,
|
|
192
|
+
style: iconProps?.style
|
|
193
|
+
}, slotProps?.icon)
|
|
194
|
+
})]
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
exports.NativeSelect = NativeSelect;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { n as IconProps, r as IconName } from "./index-B3jHcw5h.cjs";
|
|
2
|
+
import { D as Theme, Qn as NativeSelectThemeConfig, Xn as NativeSelectOwnerState, Zn as NativeSelectSlot, ia as StyleOverride, na as SlotProps } from "./index-DPQxIeZF.cjs";
|
|
3
|
+
import { SelectHTMLAttributes } from "react";
|
|
4
|
+
import { LayoutProps, SpaceProps } from "@soroush.tech/styled-system";
|
|
5
|
+
export type NativeSelectColor = keyof Theme['palette'];
|
|
6
|
+
export type NativeSelectTextColor = keyof Theme['text'];
|
|
7
|
+
export type NativeSelectBackgroundToken = keyof Theme['background'];
|
|
8
|
+
export type NativeSelectVariant = 'default' | 'outlined' | 'text' | 'underline';
|
|
9
|
+
export type NativeSelectSize = keyof Theme['sizes'];
|
|
10
|
+
export interface NativeSelectOption {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string | number;
|
|
13
|
+
}
|
|
14
|
+
export interface NativeSelectProps extends SpaceProps, Pick<LayoutProps, '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: the accent `color`'s `main`. */
|
|
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?: Omit<SelectHTMLAttributes<HTMLSelectElement>, 'style'>;
|
|
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
|
+
/** Overrides the CSS of the root: an entry of `StyleSheet.create`, or a list of them. It wins over `slotProps.root.style`. */
|
|
59
|
+
style?: StyleOverride;
|
|
60
|
+
/** Overrides for the slots a theme can style: `style`, `className`, `data-*` and `aria-*`. */
|
|
61
|
+
slotProps?: SlotProps<NativeSelectSlot>;
|
|
62
|
+
'data-testid'?: string;
|
|
63
|
+
}
|
|
64
|
+
export 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, style, slotProps, 'data-testid': dataTestid, ...spaceProps }: Readonly<NativeSelectProps>): import("react").JSX.Element;
|
|
65
|
+
export { NativeSelectOwnerState, NativeSelectSlot, NativeSelectThemeConfig };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { n as IconProps, r as IconName } from "./index-IB1nBqEO.mjs";
|
|
2
|
+
import { An as NativeSelectOwnerState, Ha as SlotProps, Mn as NativeSelectThemeConfig, Wa as StyleOverride, jn as NativeSelectSlot, s as Theme } from "./Accordion.types-DxvwAfZc.mjs";
|
|
3
|
+
import { SelectHTMLAttributes } from "react";
|
|
4
|
+
import { LayoutProps, SpaceProps } from "@soroush.tech/styled-system";
|
|
5
|
+
export type NativeSelectColor = keyof Theme['palette'];
|
|
6
|
+
export type NativeSelectTextColor = keyof Theme['text'];
|
|
7
|
+
export type NativeSelectBackgroundToken = keyof Theme['background'];
|
|
8
|
+
export type NativeSelectVariant = 'default' | 'outlined' | 'text' | 'underline';
|
|
9
|
+
export type NativeSelectSize = keyof Theme['sizes'];
|
|
10
|
+
export interface NativeSelectOption {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string | number;
|
|
13
|
+
}
|
|
14
|
+
export interface NativeSelectProps extends SpaceProps, Pick<LayoutProps, '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: the accent `color`'s `main`. */
|
|
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?: Omit<SelectHTMLAttributes<HTMLSelectElement>, 'style'>;
|
|
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
|
+
/** Overrides the CSS of the root: an entry of `StyleSheet.create`, or a list of them. It wins over `slotProps.root.style`. */
|
|
59
|
+
style?: StyleOverride;
|
|
60
|
+
/** Overrides for the slots a theme can style: `style`, `className`, `data-*` and `aria-*`. */
|
|
61
|
+
slotProps?: SlotProps<NativeSelectSlot>;
|
|
62
|
+
'data-testid'?: string;
|
|
63
|
+
}
|
|
64
|
+
export 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, style, slotProps, 'data-testid': dataTestid, ...spaceProps }: Readonly<NativeSelectProps>): import("react").JSX.Element;
|
|
65
|
+
export { NativeSelectOwnerState, NativeSelectSlot, NativeSelectThemeConfig };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useFormControl } from "./FormControl.mjs";
|
|
3
|
+
import { t as Icon } from "./Icon-DBgqmUb3.mjs";
|
|
4
|
+
import { t as styled } from "./styled-tLHNvicL.mjs";
|
|
5
|
+
import { t as mergeOverrides } from "./overrides-Ds6QZL5Q.mjs";
|
|
6
|
+
import "./themes-BtfQPcbo.mjs";
|
|
7
|
+
import { _ as useTheme } from "./styleEngine-CLid4cmR.mjs";
|
|
8
|
+
import { n as getFocusRing, r as getInputMinWidth, t as inputVariantStyles } from "./inputVariantStyles-B-4lHxUZ.mjs";
|
|
9
|
+
import "react";
|
|
10
|
+
import { themeDefault } from "@gild-ui/core/theme";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { createShouldForwardProp, props } from "@soroush.tech/styled-system/should-forward-prop";
|
|
13
|
+
import { get, space, system } from "@soroush.tech/styled-system";
|
|
14
|
+
// src/NativeSelect/NativeSelect.tsx
|
|
15
|
+
const shouldForwardProp = createShouldForwardProp([
|
|
16
|
+
...props,
|
|
17
|
+
"color",
|
|
18
|
+
"textColor",
|
|
19
|
+
"variant",
|
|
20
|
+
"error",
|
|
21
|
+
"disabled",
|
|
22
|
+
"fullWidth"
|
|
23
|
+
]);
|
|
24
|
+
const baseStyle = {
|
|
25
|
+
position: "relative",
|
|
26
|
+
display: "inline-flex",
|
|
27
|
+
alignItems: "center",
|
|
28
|
+
transition: "border-color 0.15s ease"
|
|
29
|
+
};
|
|
30
|
+
const backgroundStyle = ({ theme, textColor, color = themeDefault(theme, "color", "primary"), bg = themeDefault(theme, "inputBg", "terminal") }) => {
|
|
31
|
+
return {
|
|
32
|
+
backgroundColor: get(theme, `background.${bg}`),
|
|
33
|
+
color: textColor ? get(theme, `text.${textColor}`) : get(theme, `palette.${color}.main`),
|
|
34
|
+
fontFamily: get(theme, "fonts.body"),
|
|
35
|
+
fontSize: get(theme, "fontSizes.1"),
|
|
36
|
+
lineHeight: get(theme, "lineHeights.base")
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const colorBorder = ({ theme, color = themeDefault(theme, "color", "primary"), error }) => {
|
|
40
|
+
return { borderColor: error ? get(theme, "palette.error.main") : get(theme, `palette.${color}.light`) };
|
|
41
|
+
};
|
|
42
|
+
const focusWithinColor = ({ theme, color = themeDefault(theme, "color", "primary"), error }) => {
|
|
43
|
+
return { "&:focus-within": { borderColor: error ? get(theme, "palette.error.main") : get(theme, `palette.${color}.main`) } };
|
|
44
|
+
};
|
|
45
|
+
const focusVisibleRing = ({ theme, color = themeDefault(theme, "color", "primary"), error }) => ({ "&:has(:focus-visible)": getFocusRing(theme, color, error) });
|
|
46
|
+
const borderRadiusStyle = ({ variant: v = "default", borderRadius, theme }) => {
|
|
47
|
+
if (v === "underline" || v === "text" || !borderRadius) return {};
|
|
48
|
+
return { borderRadius: get(theme, `radii.${borderRadius}`) };
|
|
49
|
+
};
|
|
50
|
+
const layoutStyles = ({ theme, fullWidth, disabled }) => ({
|
|
51
|
+
minWidth: getInputMinWidth(theme),
|
|
52
|
+
...fullWidth ? {
|
|
53
|
+
display: "flex",
|
|
54
|
+
width: "100%"
|
|
55
|
+
} : {},
|
|
56
|
+
...disabled ? {
|
|
57
|
+
opacity: .5,
|
|
58
|
+
cursor: "not-allowed",
|
|
59
|
+
pointerEvents: "none"
|
|
60
|
+
} : {}
|
|
61
|
+
});
|
|
62
|
+
const widthStyles = system({
|
|
63
|
+
width: true,
|
|
64
|
+
minWidth: true,
|
|
65
|
+
maxWidth: true
|
|
66
|
+
});
|
|
67
|
+
const NativeSelectRoot = styled("div", {
|
|
68
|
+
name: "NativeSelect",
|
|
69
|
+
label: "NativeSelect",
|
|
70
|
+
shouldForwardProp,
|
|
71
|
+
systemProps: [space, widthStyles]
|
|
72
|
+
})(baseStyle, inputVariantStyles, borderRadiusStyle, colorBorder, focusWithinColor, focusVisibleRing, backgroundStyle, layoutStyles);
|
|
73
|
+
const shouldForwardNativeSelectProps = (prop) => prop !== "sizeToken" && prop !== "bg" && prop !== "textColor" && prop !== "accent";
|
|
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 = themeDefault(theme, "inputBg", "terminal"), textColor, accent }) => {
|
|
85
|
+
const backgroundColor = get(theme, `background.${bg}`);
|
|
86
|
+
const color = textColor ? get(theme, `text.${textColor}`) : get(theme, `palette.${accent}.main`);
|
|
87
|
+
return {
|
|
88
|
+
backgroundColor,
|
|
89
|
+
color,
|
|
90
|
+
"& option": {
|
|
91
|
+
backgroundColor,
|
|
92
|
+
color
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
const StyledNativeSelect = 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 = styled(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, style, slotProps, "data-testid": dataTestid, ...spaceProps }) {
|
|
126
|
+
const fc = 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 = useTheme();
|
|
138
|
+
const color = fc.color ?? themeDefault(theme, "color", "primary");
|
|
139
|
+
const textColor = fc.textColor;
|
|
140
|
+
const variant = variantProp ?? 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__ */ jsxs(NativeSelectRoot, {
|
|
147
|
+
color,
|
|
148
|
+
textColor,
|
|
149
|
+
bg,
|
|
150
|
+
variant,
|
|
151
|
+
error,
|
|
152
|
+
disabled,
|
|
153
|
+
fullWidth,
|
|
154
|
+
borderRadius,
|
|
155
|
+
...mergeOverrides(slotProps?.root, {
|
|
156
|
+
style,
|
|
157
|
+
className
|
|
158
|
+
}),
|
|
159
|
+
"data-testid": dataTestid,
|
|
160
|
+
...spaceProps,
|
|
161
|
+
children: [/* @__PURE__ */ jsxs(StyledNativeSelect, {
|
|
162
|
+
...selectProps,
|
|
163
|
+
...mergeOverrides({ className: selectProps?.className }, slotProps?.select),
|
|
164
|
+
id,
|
|
165
|
+
name,
|
|
166
|
+
disabled,
|
|
167
|
+
required,
|
|
168
|
+
sizeToken: size,
|
|
169
|
+
bg,
|
|
170
|
+
textColor,
|
|
171
|
+
accent: color,
|
|
172
|
+
value,
|
|
173
|
+
defaultValue: uncontrolledDefault,
|
|
174
|
+
onChange: handleChange,
|
|
175
|
+
"aria-describedby": selectProps?.["aria-describedby"] ?? fc["aria-describedby"],
|
|
176
|
+
children: [placeholder !== void 0 && /* @__PURE__ */ jsx("option", {
|
|
177
|
+
value: "",
|
|
178
|
+
disabled: true,
|
|
179
|
+
hidden: true,
|
|
180
|
+
children: placeholder
|
|
181
|
+
}), options.map((option) => /* @__PURE__ */ jsx("option", {
|
|
182
|
+
value: String(option.value),
|
|
183
|
+
children: option.label
|
|
184
|
+
}, String(option.value)))]
|
|
185
|
+
}), /* @__PURE__ */ jsx(DropdownIcon, {
|
|
186
|
+
name: iconName,
|
|
187
|
+
size,
|
|
188
|
+
color: "inherit",
|
|
189
|
+
...iconProps,
|
|
190
|
+
...mergeOverrides({
|
|
191
|
+
className: iconProps?.className,
|
|
192
|
+
style: iconProps?.style
|
|
193
|
+
}, slotProps?.icon)
|
|
194
|
+
})]
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
export { NativeSelect };
|