@gild-ui/react 0.0.0-stage → 0.1.0-alpha.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 +400 -2
- 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-D06ViRMj.d.mts +1114 -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 +51 -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 +18 -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-CpmLCuWc.mjs +916 -0
- package/dist/Icon-D8CNaUwd.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-CEr2M5u0.mjs +229 -0
- package/dist/Menu-DA9QNBfE.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-D3lzWmIO.cjs +859 -0
- package/dist/MenuItem-DzHB9Es6.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-BphaFrcw.mjs +300 -0
- package/dist/Modal-C5OWwkvp.cjs +328 -0
- package/dist/Modal.cjs +8 -0
- package/dist/Modal.d.cts +96 -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-DY0ooIAM.cjs +143 -0
- package/dist/Popover-DsPTeEPx.mjs +139 -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 +51 -0
- package/dist/Slide.d.cts +14 -0
- package/dist/Slide.d.mts +14 -0
- package/dist/Slide.mjs +50 -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 +82 -0
- package/dist/TextInput.d.mts +82 -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-DQo2zZH0.mjs +485 -0
- package/dist/Tooltip-DaB6bJKM.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 +30 -0
- package/dist/Typography.d.mts +3 -0
- package/dist/Typography.mjs +69 -0
- package/dist/View-BmuIFO7p.mjs +75 -0
- package/dist/View-DkfIBlcy.cjs +85 -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-B7LR7Up3.d.mts +175 -0
- package/dist/index-Bgd6kxq_.d.mts +43 -0
- package/dist/index-Blc3XujV.d.mts +52 -0
- package/dist/index-C21GrYkd.d.mts +96 -0
- package/dist/index-CA5HTpT9.d.mts +90 -0
- package/dist/index-CD0xu_P6.d.mts +92 -0
- package/dist/index-CEtnJkY4.d.cts +92 -0
- package/dist/index-CKHGDpGJ.d.mts +33 -0
- package/dist/index-CT311xS9.d.cts +175 -0
- package/dist/index-CWOcMPWz.d.mts +51 -0
- package/dist/index-CmG1wW5D.d.mts +38 -0
- package/dist/index-DZFF1vMV.d.cts +1114 -0
- package/dist/index-MfIvwyA4.d.mts +1 -0
- package/dist/index-Tg9lQlVl.d.mts +30 -0
- package/dist/index-UloRwym_.d.mts +16 -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-DnzWP4pc.cjs +34 -0
- package/dist/styled-nr_qC_Yx.mjs +29 -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-B4KGUO9m.d.cts +40 -0
- package/dist/useTransition-BKBtk0Mb.mjs +78 -0
- package/dist/useTransition-BwpSHKSf.d.mts +40 -0
- package/dist/useTransition-gHFCJwqF.cjs +83 -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 +913 -3
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_styled = require("./styled-DnzWP4pc.cjs");
|
|
3
|
+
const require_overrides = require("./overrides-DeXScOFK.cjs");
|
|
4
|
+
const require_useLiveValue = require("./useLiveValue-CN2SUG2B.cjs");
|
|
5
|
+
const require_useDefaultProps = require("./useDefaultProps-DratGGIL.cjs");
|
|
6
|
+
const require_Portal = require("./Portal.cjs");
|
|
7
|
+
const require_getElementRef = require("./getElementRef-4m6-x2FS.cjs");
|
|
8
|
+
const require_useAnchoredPlacement = require("./useAnchoredPlacement-CSotv28V.cjs");
|
|
9
|
+
let react = require("react");
|
|
10
|
+
let _gild_ui_core_theme = require("@gild-ui/core/theme");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
let _gild_ui_core_utils = require("@gild-ui/core/utils");
|
|
13
|
+
let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
|
|
14
|
+
let _soroush_tech_styled_system = require("@soroush.tech/styled-system");
|
|
15
|
+
let _gild_ui_hooks_useControlled = require("@gild-ui/hooks/useControlled");
|
|
16
|
+
let _gild_ui_hooks_useMergedRefs = require("@gild-ui/hooks/useMergedRefs");
|
|
17
|
+
let _umber_style_react = require("@umber-style/react");
|
|
18
|
+
// src/Tooltip/TooltipGroupContext.ts
|
|
19
|
+
const TooltipGroupContext = (0, react.createContext)(null);
|
|
20
|
+
/** The state of a group whose window is `skipDelayDuration` milliseconds long. */
|
|
21
|
+
const createTooltipGroupState = (skipDelayDuration) => {
|
|
22
|
+
let active = null;
|
|
23
|
+
let closedAt = Number.NEGATIVE_INFINITY;
|
|
24
|
+
return {
|
|
25
|
+
shouldSkipDelay: () => active !== null || Date.now() - closedAt < skipDelayDuration,
|
|
26
|
+
open: (close) => {
|
|
27
|
+
active = close;
|
|
28
|
+
},
|
|
29
|
+
closeActive: (event) => active?.(event),
|
|
30
|
+
release: (close) => {
|
|
31
|
+
if (active !== close) return;
|
|
32
|
+
active = null;
|
|
33
|
+
closedAt = Date.now();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const themeGroups = /* @__PURE__ */ new WeakMap();
|
|
38
|
+
const getThemeTooltipGroup = (theme, skipDelayDuration) => {
|
|
39
|
+
const byDuration = themeGroups.get(theme) ?? /* @__PURE__ */ new Map();
|
|
40
|
+
themeGroups.set(theme, byDuration);
|
|
41
|
+
const group = byDuration.get(skipDelayDuration) ?? createTooltipGroupState(skipDelayDuration);
|
|
42
|
+
byDuration.set(skipDelayDuration, group);
|
|
43
|
+
return group;
|
|
44
|
+
};
|
|
45
|
+
// src/Tooltip/hooks/useTooltip.ts
|
|
46
|
+
const isKeyboardFocus = (event) => {
|
|
47
|
+
try {
|
|
48
|
+
return event.target.matches(":focus-visible");
|
|
49
|
+
} catch {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The state of a tooltip: whether it is open (its own, or its owner's), the timers that open and
|
|
55
|
+
* close it, and the handlers its child and the tooltip itself take. Opening and closing are
|
|
56
|
+
* delayed; moving from the child onto the tooltip does not close it, so its text can be read and
|
|
57
|
+
* selected (WCAG 1.4.13); Escape closes it at once.
|
|
58
|
+
*/
|
|
59
|
+
function useTooltip({ isOpen: isOpenProp, defaultOpen, isAtPoint = false, onOpen, onClose, enterDelay, leaveDelay, enterTouchDelay, leaveTouchDelay, shouldOpenOnHover, shouldOpenOnFocus, shouldOpenOnTouch, skipDelayDuration = 0 }) {
|
|
60
|
+
const [isOpen, setIsOpen] = (0, _gild_ui_hooks_useControlled.useControlled)({
|
|
61
|
+
controlled: isOpenProp,
|
|
62
|
+
default: defaultOpen
|
|
63
|
+
});
|
|
64
|
+
const timer = (0, react.useRef)(void 0);
|
|
65
|
+
const theme = (0, _umber_style_react.useTheme)();
|
|
66
|
+
const group = (0, react.useContext)(TooltipGroupContext) ?? (skipDelayDuration > 0 ? getThemeTooltipGroup(theme, skipDelayDuration) : null);
|
|
67
|
+
const latest = (0, react.useRef)({
|
|
68
|
+
isOpen,
|
|
69
|
+
isOpenProp,
|
|
70
|
+
isAtPoint,
|
|
71
|
+
onOpen,
|
|
72
|
+
onClose,
|
|
73
|
+
group
|
|
74
|
+
});
|
|
75
|
+
(0, react.useEffect)(() => {
|
|
76
|
+
latest.current = {
|
|
77
|
+
isOpen,
|
|
78
|
+
isOpenProp,
|
|
79
|
+
isAtPoint,
|
|
80
|
+
onOpen,
|
|
81
|
+
onClose,
|
|
82
|
+
group
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
const clear = (0, react.useCallback)(() => window.clearTimeout(timer.current), []);
|
|
86
|
+
const closeNow = (0, react.useCallback)((event) => {
|
|
87
|
+
clear();
|
|
88
|
+
const current = latest.current;
|
|
89
|
+
setIsOpen(false);
|
|
90
|
+
current.onClose?.(event);
|
|
91
|
+
}, [clear, setIsOpen]);
|
|
92
|
+
const isInGroup = group !== null && isOpenProp === void 0;
|
|
93
|
+
(0, react.useEffect)(() => {
|
|
94
|
+
if (!isInGroup || !isOpen) return void 0;
|
|
95
|
+
group.open(closeNow);
|
|
96
|
+
return () => group.release(closeNow);
|
|
97
|
+
}, [
|
|
98
|
+
group,
|
|
99
|
+
isInGroup,
|
|
100
|
+
isOpen,
|
|
101
|
+
closeNow
|
|
102
|
+
]);
|
|
103
|
+
const getEnterDelay = () => isInGroup && group.shouldSkipDelay() ? 0 : enterDelay;
|
|
104
|
+
const ask = (0, react.useCallback)((next, event, delay) => {
|
|
105
|
+
clear();
|
|
106
|
+
timer.current = window.setTimeout(() => {
|
|
107
|
+
const current = latest.current;
|
|
108
|
+
if (current.isOpen === next) return;
|
|
109
|
+
if (next && current.isAtPoint) return;
|
|
110
|
+
if (current.isOpenProp === void 0) {
|
|
111
|
+
if (next) current.group?.closeActive(event);
|
|
112
|
+
else current.group?.release(closeNow);
|
|
113
|
+
setIsOpen(next);
|
|
114
|
+
}
|
|
115
|
+
(next ? current.onOpen : current.onClose)?.(event);
|
|
116
|
+
}, delay);
|
|
117
|
+
}, [
|
|
118
|
+
clear,
|
|
119
|
+
setIsOpen,
|
|
120
|
+
closeNow
|
|
121
|
+
]);
|
|
122
|
+
(0, react.useEffect)(() => clear, [clear]);
|
|
123
|
+
(0, react.useEffect)(() => {
|
|
124
|
+
if (!isOpen) return void 0;
|
|
125
|
+
const handleKeyDown = (event) => {
|
|
126
|
+
if (event.key === "Escape") ask(false, event, 0);
|
|
127
|
+
};
|
|
128
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
129
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
130
|
+
}, [isOpen, ask]);
|
|
131
|
+
return {
|
|
132
|
+
isOpen,
|
|
133
|
+
childHandlers: {
|
|
134
|
+
onMouseEnter: (event) => {
|
|
135
|
+
if (shouldOpenOnHover) ask(true, event, getEnterDelay());
|
|
136
|
+
},
|
|
137
|
+
onMouseLeave: (event) => {
|
|
138
|
+
if (shouldOpenOnHover) ask(false, event, leaveDelay);
|
|
139
|
+
},
|
|
140
|
+
onFocus: (event) => {
|
|
141
|
+
if (shouldOpenOnFocus && isKeyboardFocus(event)) ask(true, event, getEnterDelay());
|
|
142
|
+
},
|
|
143
|
+
onBlur: (event) => {
|
|
144
|
+
if (shouldOpenOnFocus) ask(false, event, leaveDelay);
|
|
145
|
+
},
|
|
146
|
+
onTouchStart: (event) => {
|
|
147
|
+
if (shouldOpenOnTouch) ask(true, event, enterTouchDelay);
|
|
148
|
+
},
|
|
149
|
+
onTouchEnd: (event) => {
|
|
150
|
+
if (shouldOpenOnTouch) ask(false, event, leaveTouchDelay);
|
|
151
|
+
},
|
|
152
|
+
onTouchCancel: (event) => {
|
|
153
|
+
if (shouldOpenOnTouch) ask(false, event, leaveTouchDelay);
|
|
154
|
+
},
|
|
155
|
+
onPointerDown: (event) => {
|
|
156
|
+
if (event.pointerType !== "touch") ask(false, event, 0);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
surfaceHandlers: {
|
|
160
|
+
onMouseEnter: () => {
|
|
161
|
+
if (shouldOpenOnHover) clear();
|
|
162
|
+
},
|
|
163
|
+
onMouseLeave: (event) => {
|
|
164
|
+
if (shouldOpenOnHover) ask(false, event, leaveDelay);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
// src/Tooltip/utils/getTooltipOrigins.ts
|
|
170
|
+
const opposite = {
|
|
171
|
+
top: "bottom",
|
|
172
|
+
bottom: "top",
|
|
173
|
+
left: "right",
|
|
174
|
+
right: "left"
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* The origins `computePopoverPosition` places a tooltip with: its edge against the child's edge on
|
|
178
|
+
* its side, and - for `-start` and `-end` - the two lined up on the same end. `start` is logical:
|
|
179
|
+
* the right edge in a right-to-left page, and `left` and `right` swap there too. The placement
|
|
180
|
+
* flips to the other side on its own where the window has no room.
|
|
181
|
+
*/
|
|
182
|
+
function getTooltipOrigins(placement, isRtl) {
|
|
183
|
+
const [side, end] = placement.split("-");
|
|
184
|
+
if (side === "top" || side === "bottom") {
|
|
185
|
+
let edge = "center";
|
|
186
|
+
if (end !== void 0) edge = end === "start" !== isRtl ? "left" : "right";
|
|
187
|
+
return {
|
|
188
|
+
anchorOrigin: {
|
|
189
|
+
vertical: side,
|
|
190
|
+
horizontal: edge
|
|
191
|
+
},
|
|
192
|
+
transformOrigin: {
|
|
193
|
+
vertical: opposite[side],
|
|
194
|
+
horizontal: edge
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const toward = isRtl ? opposite[side] : side;
|
|
199
|
+
let edge = "center";
|
|
200
|
+
if (end !== void 0) edge = end === "start" ? "top" : "bottom";
|
|
201
|
+
return {
|
|
202
|
+
anchorOrigin: {
|
|
203
|
+
vertical: edge,
|
|
204
|
+
horizontal: toward
|
|
205
|
+
},
|
|
206
|
+
transformOrigin: {
|
|
207
|
+
vertical: edge,
|
|
208
|
+
horizontal: opposite[toward]
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
const AUTO_SIDES = [
|
|
213
|
+
"top",
|
|
214
|
+
"bottom",
|
|
215
|
+
"right",
|
|
216
|
+
"left"
|
|
217
|
+
];
|
|
218
|
+
/**
|
|
219
|
+
* The fixed placement a placement stands for. `auto` is the side of the child with the most room
|
|
220
|
+
* left once the tooltip is on it - above, below, then beside, on a tie - and `auto-start` and
|
|
221
|
+
* `auto-end` line it up with that end of the side. The window is measured, so a tooltip next to
|
|
222
|
+
* the window edge goes to the other side.
|
|
223
|
+
*/
|
|
224
|
+
function resolveTooltipPlacement(placement, { anchorRect, surfaceSize, viewport, isRtl }) {
|
|
225
|
+
if (!placement.startsWith("auto")) return placement;
|
|
226
|
+
const room = {
|
|
227
|
+
top: anchorRect.top - surfaceSize.height,
|
|
228
|
+
bottom: viewport.height - anchorRect.bottom - surfaceSize.height,
|
|
229
|
+
left: anchorRect.left - surfaceSize.width,
|
|
230
|
+
right: viewport.width - anchorRect.right - surfaceSize.width
|
|
231
|
+
};
|
|
232
|
+
const side = AUTO_SIDES.reduce((best, next) => room[next] > room[best] ? next : best, "top");
|
|
233
|
+
const logical = (side === "left" || side === "right") && isRtl ? opposite[side] : side;
|
|
234
|
+
const end = placement.split("-")[1];
|
|
235
|
+
return end ? `${logical}-${end}` : logical;
|
|
236
|
+
}
|
|
237
|
+
// src/Tooltip/Tooltip.tsx
|
|
238
|
+
const MARGIN = 8;
|
|
239
|
+
const GAP = 8;
|
|
240
|
+
const ARROW = 8;
|
|
241
|
+
const TooltipSurface = require_styled.styled("div", {
|
|
242
|
+
name: "Tooltip",
|
|
243
|
+
label: "Tooltip",
|
|
244
|
+
shouldForwardProp: (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([
|
|
245
|
+
"layer",
|
|
246
|
+
"isInteractive",
|
|
247
|
+
"borderRadius",
|
|
248
|
+
"bg",
|
|
249
|
+
"textColor"
|
|
250
|
+
])
|
|
251
|
+
})(({ theme, layer, isInteractive, borderRadius, bg, textColor }) => ({
|
|
252
|
+
position: "fixed",
|
|
253
|
+
...!isInteractive && { pointerEvents: "none" },
|
|
254
|
+
top: 0,
|
|
255
|
+
left: 0,
|
|
256
|
+
visibility: "hidden",
|
|
257
|
+
zIndex: theme.zOrder[layer],
|
|
258
|
+
boxSizing: "border-box",
|
|
259
|
+
maxWidth: "20rem",
|
|
260
|
+
padding: `${theme.space[.5]} ${theme.space[1]}`,
|
|
261
|
+
borderRadius: (0, _gild_ui_core_utils.getSurfaceRadius)(theme, borderRadius),
|
|
262
|
+
boxShadow: theme.shadows[4],
|
|
263
|
+
backgroundColor: (0, _soroush_tech_styled_system.get)(theme, `background.${bg ?? "modal"}`),
|
|
264
|
+
color: (0, _soroush_tech_styled_system.get)(theme, `text.${textColor ?? (0, _gild_ui_core_theme.themeDefault)(theme, "textColor", "initial")}`),
|
|
265
|
+
fontFamily: (0, _soroush_tech_styled_system.get)(theme, "fonts.body"),
|
|
266
|
+
fontSize: theme.fontSizes[0],
|
|
267
|
+
lineHeight: (0, _soroush_tech_styled_system.get)(theme, "lineHeights.base"),
|
|
268
|
+
overflowWrap: "break-word"
|
|
269
|
+
}));
|
|
270
|
+
const TooltipDescription = require_styled.styled("span", { label: "TooltipDescription" })({
|
|
271
|
+
position: "absolute",
|
|
272
|
+
width: 1,
|
|
273
|
+
height: 1,
|
|
274
|
+
margin: -1,
|
|
275
|
+
padding: 0,
|
|
276
|
+
border: 0,
|
|
277
|
+
overflow: "hidden",
|
|
278
|
+
clip: "rect(0 0 0 0)",
|
|
279
|
+
whiteSpace: "nowrap"
|
|
280
|
+
});
|
|
281
|
+
const TooltipTarget = require_styled.styled("span", { label: "TooltipTarget" })({ display: "inline-grid" });
|
|
282
|
+
const TooltipArrow = require_styled.styled("span", {
|
|
283
|
+
name: "Tooltip",
|
|
284
|
+
slot: "arrow",
|
|
285
|
+
label: "TooltipArrow",
|
|
286
|
+
shouldForwardProp: (prop) => prop !== "side" && prop !== "offset"
|
|
287
|
+
})(({ side, offset }) => {
|
|
288
|
+
const along = (0, _umber_style_react.subtract)(offset, ARROW / 2);
|
|
289
|
+
const edge = {
|
|
290
|
+
top: {
|
|
291
|
+
bottom: -4,
|
|
292
|
+
left: along
|
|
293
|
+
},
|
|
294
|
+
bottom: {
|
|
295
|
+
top: -4,
|
|
296
|
+
left: along
|
|
297
|
+
},
|
|
298
|
+
left: {
|
|
299
|
+
right: -4,
|
|
300
|
+
top: along
|
|
301
|
+
},
|
|
302
|
+
right: {
|
|
303
|
+
left: -4,
|
|
304
|
+
top: along
|
|
305
|
+
}
|
|
306
|
+
}[side];
|
|
307
|
+
return {
|
|
308
|
+
position: "absolute",
|
|
309
|
+
width: ARROW,
|
|
310
|
+
height: ARROW,
|
|
311
|
+
backgroundColor: "inherit",
|
|
312
|
+
transform: "rotate(45deg)",
|
|
313
|
+
pointerEvents: "none",
|
|
314
|
+
...edge
|
|
315
|
+
};
|
|
316
|
+
});
|
|
317
|
+
const getArrow = ({ anchorRect, surfaceSize, top, left }) => {
|
|
318
|
+
const { width, height } = surfaceSize;
|
|
319
|
+
if (top + height <= anchorRect.top + 1 || top >= anchorRect.bottom - 1) {
|
|
320
|
+
const side = top + height <= anchorRect.top + 1 ? "top" : "bottom";
|
|
321
|
+
const middle = anchorRect.left + anchorRect.width / 2 - left;
|
|
322
|
+
return {
|
|
323
|
+
side,
|
|
324
|
+
offset: Math.min(Math.max(middle, ARROW), width - ARROW)
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
const side = left + width <= anchorRect.left + 1 ? "left" : "right";
|
|
328
|
+
const middle = anchorRect.top + anchorRect.height / 2 - top;
|
|
329
|
+
return {
|
|
330
|
+
side,
|
|
331
|
+
offset: Math.min(Math.max(middle, ARROW), height - ARROW)
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
const isSameArrow = (a, b) => a !== null && a.side === b.side && a.offset === b.offset;
|
|
335
|
+
const mergeForwarded = (own, forwarded) => Object.fromEntries(Object.entries(forwarded).filter(([, value]) => value !== void 0).map(([name, value]) => {
|
|
336
|
+
const current = own[name];
|
|
337
|
+
if (typeof value === "function" && typeof current === "function") return [name, (...args) => {
|
|
338
|
+
current(...args);
|
|
339
|
+
value(...args);
|
|
340
|
+
}];
|
|
341
|
+
if (name === "aria-describedby" && typeof current === "string" && current) return [name, `${current} ${String(value)}`];
|
|
342
|
+
return [name, value];
|
|
343
|
+
}));
|
|
344
|
+
const getChildName = (title, own) => {
|
|
345
|
+
const isHidden = own["aria-hidden"] === true || own["aria-hidden"] === "true";
|
|
346
|
+
const isNamed = Boolean(own["aria-label"] || own["aria-labelledby"]);
|
|
347
|
+
return typeof title === "string" && !isHidden && !isNamed ? { "aria-label": title } : {};
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* @description A short description of one child, shown on hover, keyboard focus and a long touch -
|
|
351
|
+
* a `role="tooltip"` in a `Portal`, placed beside its child and flipped for want of room. The
|
|
352
|
+
* child is named by it (`aria-label`) or described by it (`aria-describedby`, with
|
|
353
|
+
* `shouldDescribeChild`). It opens and closes after their delays, stays open while the pointer is
|
|
354
|
+
* on the tooltip itself, closes on Escape, and never takes or traps the focus.
|
|
355
|
+
*/
|
|
356
|
+
const Tooltip = (0, react.forwardRef)(function Tooltip({ children, anchorPosition, title, placement: placementProp, hasArrow: hasArrowProp, enterDelay: enterDelayProp, leaveDelay: leaveDelayProp, enterTouchDelay: enterTouchDelayProp, leaveTouchDelay: leaveTouchDelayProp, shouldDescribeChild: shouldDescribeChildProp, isDescriptionPersistent: isDescriptionPersistentProp, isOpen: isOpenProp, defaultOpen = false, onOpen, onClose, isInteractive: isInteractiveProp, shouldWrapDisabledChild: shouldWrapDisabledChildProp, shouldOpenOnHover: shouldOpenOnHoverProp, shouldOpenOnFocus: shouldOpenOnFocusProp, shouldOpenOnTouch: shouldOpenOnTouchProp, slots, slotProps, layer: layerProp, borderRadius: borderRadiusProp, bg: bgProp, textColor: textColorProp, className, style, "data-testid": dataTestid, ...forwarded }, forwardedRef) {
|
|
357
|
+
const dp = require_useDefaultProps.useDefaultProps("Tooltip");
|
|
358
|
+
const placement = placementProp ?? dp.placement ?? "top";
|
|
359
|
+
const hasArrow = hasArrowProp ?? dp.hasArrow ?? false;
|
|
360
|
+
const shouldDescribeChild = shouldDescribeChildProp ?? dp.shouldDescribeChild ?? false;
|
|
361
|
+
const isDescriptionPersistent = isDescriptionPersistentProp ?? dp.isDescriptionPersistent ?? false;
|
|
362
|
+
const isInteractive = isInteractiveProp ?? dp.isInteractive ?? true;
|
|
363
|
+
const shouldWrapDisabledChild = shouldWrapDisabledChildProp ?? dp.shouldWrapDisabledChild ?? true;
|
|
364
|
+
const layer = layerProp ?? dp.layer ?? "tooltip";
|
|
365
|
+
const borderRadius = borderRadiusProp ?? dp.borderRadius;
|
|
366
|
+
const bg = bgProp ?? dp.bg;
|
|
367
|
+
const textColor = textColorProp ?? dp.textColor;
|
|
368
|
+
const id = (0, react.useId)();
|
|
369
|
+
const isAtPoint = anchorPosition !== void 0;
|
|
370
|
+
const { isOpen, childHandlers, surfaceHandlers } = useTooltip({
|
|
371
|
+
isOpen: isOpenProp,
|
|
372
|
+
defaultOpen,
|
|
373
|
+
isAtPoint,
|
|
374
|
+
onOpen,
|
|
375
|
+
onClose,
|
|
376
|
+
enterDelay: enterDelayProp ?? dp.enterDelay ?? 100,
|
|
377
|
+
leaveDelay: leaveDelayProp ?? dp.leaveDelay ?? 0,
|
|
378
|
+
enterTouchDelay: enterTouchDelayProp ?? dp.enterTouchDelay ?? 700,
|
|
379
|
+
leaveTouchDelay: leaveTouchDelayProp ?? dp.leaveTouchDelay ?? 1500,
|
|
380
|
+
shouldOpenOnHover: shouldOpenOnHoverProp ?? dp.shouldOpenOnHover ?? true,
|
|
381
|
+
shouldOpenOnFocus: shouldOpenOnFocusProp ?? dp.shouldOpenOnFocus ?? true,
|
|
382
|
+
shouldOpenOnTouch: shouldOpenOnTouchProp ?? dp.shouldOpenOnTouch ?? true,
|
|
383
|
+
skipDelayDuration: dp.skipDelayDuration
|
|
384
|
+
});
|
|
385
|
+
const hasTitle = title !== void 0 && title !== null && title !== "";
|
|
386
|
+
const isShown = isOpen && hasTitle;
|
|
387
|
+
const anchorRef = (0, react.useRef)(null);
|
|
388
|
+
const noAnchorRef = (0, react.useRef)(null);
|
|
389
|
+
const surfaceRef = (0, react.useRef)(null);
|
|
390
|
+
const childProps = children?.props ?? {};
|
|
391
|
+
const forwardedProps = mergeForwarded(childProps, forwarded);
|
|
392
|
+
const own = {
|
|
393
|
+
...childProps,
|
|
394
|
+
...forwardedProps
|
|
395
|
+
};
|
|
396
|
+
const isChildDisabled = shouldWrapDisabledChild && own.disabled === true;
|
|
397
|
+
const childRef = (0, _gild_ui_hooks_useMergedRefs.useMergedRefs)(require_getElementRef.getElementRef(children), forwardedRef);
|
|
398
|
+
const ref = (0, _gild_ui_hooks_useMergedRefs.useMergedRefs)(isChildDisabled ? void 0 : anchorRef, childRef);
|
|
399
|
+
const [arrow, setArrow] = (0, react.useState)(null);
|
|
400
|
+
const arrowOffset = require_useLiveValue.useLiveValue(arrow?.offset ?? 0, "px");
|
|
401
|
+
const getOrigins = (0, react.useCallback)((context) => getTooltipOrigins(resolveTooltipPlacement(placement, context), context.isRtl), [placement]);
|
|
402
|
+
const onPlaced = (0, react.useCallback)((placed) => {
|
|
403
|
+
if (!hasArrow) return;
|
|
404
|
+
const next = getArrow(placed);
|
|
405
|
+
setArrow((current) => isSameArrow(current, next) ? current : next);
|
|
406
|
+
}, [hasArrow]);
|
|
407
|
+
require_useAnchoredPlacement.useAnchoredPlacement({
|
|
408
|
+
isOpen: isShown,
|
|
409
|
+
anchorRef: anchorPosition ? noAnchorRef : anchorRef,
|
|
410
|
+
anchorPosition,
|
|
411
|
+
surfaceRef,
|
|
412
|
+
getOrigins,
|
|
413
|
+
margin: MARGIN,
|
|
414
|
+
gap: GAP,
|
|
415
|
+
onPlaced
|
|
416
|
+
});
|
|
417
|
+
const handlers = Object.fromEntries(Object.entries(childHandlers).map(([name, handler]) => [name, (event) => {
|
|
418
|
+
own[name]?.(event);
|
|
419
|
+
handler(event);
|
|
420
|
+
}]));
|
|
421
|
+
const ownDescription = own["aria-describedby"];
|
|
422
|
+
const names = getChildName(title, own);
|
|
423
|
+
const descriptionId = `${id}-description`;
|
|
424
|
+
const hasPersistentDescription = children !== void 0 && shouldDescribeChild && isDescriptionPersistent && hasTitle;
|
|
425
|
+
const describedBy = (shown) => hasPersistentDescription ? [ownDescription, descriptionId].filter(Boolean).join(" ") : [ownDescription, shown ? id : void 0].filter(Boolean).join(" ") || void 0;
|
|
426
|
+
const ariaProps = shouldDescribeChild ? { "aria-describedby": describedBy(isShown) } : names;
|
|
427
|
+
const child = children ? (0, react.cloneElement)(children, {
|
|
428
|
+
...forwardedProps,
|
|
429
|
+
...isChildDisabled || isAtPoint ? {} : handlers,
|
|
430
|
+
...ariaProps,
|
|
431
|
+
ref
|
|
432
|
+
}) : null;
|
|
433
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
434
|
+
isChildDisabled && !isAtPoint ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTarget, {
|
|
435
|
+
ref: anchorRef,
|
|
436
|
+
...handlers,
|
|
437
|
+
children: child
|
|
438
|
+
}) : child,
|
|
439
|
+
hasPersistentDescription && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipDescription, {
|
|
440
|
+
id: descriptionId,
|
|
441
|
+
children: title
|
|
442
|
+
}),
|
|
443
|
+
isShown && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Portal.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TooltipSurface, {
|
|
444
|
+
...require_overrides.mergeOverrides(slotProps?.root, {
|
|
445
|
+
style,
|
|
446
|
+
className
|
|
447
|
+
}),
|
|
448
|
+
as: slots?.root,
|
|
449
|
+
ref: surfaceRef,
|
|
450
|
+
id,
|
|
451
|
+
role: "tooltip",
|
|
452
|
+
layer,
|
|
453
|
+
isInteractive,
|
|
454
|
+
borderRadius,
|
|
455
|
+
bg,
|
|
456
|
+
textColor,
|
|
457
|
+
"data-testid": dataTestid ?? slotProps?.root?.["data-testid"],
|
|
458
|
+
...isAtPoint || !isInteractive ? {} : surfaceHandlers,
|
|
459
|
+
children: [title, hasArrow && arrow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipArrow, {
|
|
460
|
+
...slotProps?.arrow,
|
|
461
|
+
as: slots?.arrow,
|
|
462
|
+
side: arrow.side,
|
|
463
|
+
offset: arrowOffset,
|
|
464
|
+
"aria-hidden": "true"
|
|
465
|
+
}) : null]
|
|
466
|
+
}) })
|
|
467
|
+
] });
|
|
468
|
+
});
|
|
469
|
+
// src/Tooltip/TooltipGroup.tsx
|
|
470
|
+
/**
|
|
471
|
+
* Lets the tooltips inside it open at once, with no enter delay, when the pointer or the focus
|
|
472
|
+
* moves to the next one just after another closed - a toolbar or a rail read from one icon to the
|
|
473
|
+
* next. It renders nothing of its own. Tooltips outside a group are unchanged, a touch keeps its
|
|
474
|
+
* own delay, and a tooltip whose `isOpen` the app controls is left alone: the group neither opens
|
|
475
|
+
* nor closes it, and it does not start the window.
|
|
476
|
+
*/
|
|
477
|
+
function TooltipGroup({ children, skipDelayDuration = 300 }) {
|
|
478
|
+
const state = (0, react.useMemo)(() => createTooltipGroupState(skipDelayDuration), [skipDelayDuration]);
|
|
479
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipGroupContext.Provider, {
|
|
480
|
+
value: state,
|
|
481
|
+
children
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
Object.defineProperty(exports, "Tooltip", {
|
|
485
|
+
enumerable: true,
|
|
486
|
+
get: function() {
|
|
487
|
+
return Tooltip;
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
Object.defineProperty(exports, "TooltipGroup", {
|
|
491
|
+
enumerable: true,
|
|
492
|
+
get: function() {
|
|
493
|
+
return TooltipGroup;
|
|
494
|
+
}
|
|
495
|
+
});
|
package/dist/Tooltip.cjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { D as Theme, F as TooltipOwnerState, I as TooltipSlot, L as TooltipThemeConfig, gi as StyleOverride, mi as SlotProps } from "./index-DZFF1vMV.cjs";
|
|
2
|
+
import { n as PopoverPosition } from "./computePopoverPosition-JgOwCM7k.cjs";
|
|
3
|
+
import { ElementType, HTMLAttributes, ReactElement, ReactNode, Ref, SyntheticEvent } from "react";
|
|
4
|
+
/** A side of its child a tooltip sits on - and, after the dash, which end of that side it lines up with. */
|
|
5
|
+
type FixedTooltipPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
6
|
+
/** A fixed placement, or `auto` - the side with the most room, chosen as it is placed. */
|
|
7
|
+
type TooltipPlacement = FixedTooltipPlacement | 'auto' | 'auto-start' | 'auto-end';
|
|
8
|
+
export interface TooltipSlots {
|
|
9
|
+
root?: ElementType;
|
|
10
|
+
arrow?: ElementType;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What a parent that clones its child (a `Menu` with a `Tooltip` for a trigger) hands the tooltip
|
|
14
|
+
* instead: it is not the tooltip's, so it goes on to the child. The tooltip's own props are left out.
|
|
15
|
+
*/
|
|
16
|
+
export type TooltipForwardedProps = Omit<HTMLAttributes<HTMLElement>, 'title' | 'children' | 'className' | 'color' | 'style'> & {
|
|
17
|
+
ref?: Ref<HTMLElement>;
|
|
18
|
+
};
|
|
19
|
+
export interface TooltipProps extends TooltipForwardedProps {
|
|
20
|
+
/**
|
|
21
|
+
* The one element the tooltip is about - it holds a `ref` and takes the handlers. Without it, the
|
|
22
|
+
* tooltip is at `anchorPosition`, and open when `isOpen` says so.
|
|
23
|
+
*/
|
|
24
|
+
children?: ReactElement;
|
|
25
|
+
/**
|
|
26
|
+
* A point in the window - client coordinates, as Popover's - to place the tooltip at instead of
|
|
27
|
+
* beside the child: a hint that depends on where the pointer is. It follows the point and the
|
|
28
|
+
* `title` as they change.
|
|
29
|
+
*/
|
|
30
|
+
anchorPosition?: PopoverPosition;
|
|
31
|
+
/** What the tooltip says. Nothing says no tooltip. */
|
|
32
|
+
title?: ReactNode;
|
|
33
|
+
/** The side of the child it sits on, and the end it lines up with; `auto` takes the side with the most room. Flips for want of room. Default: `'top'`. */
|
|
34
|
+
placement?: TooltipPlacement;
|
|
35
|
+
/** Swaps the element a part is drawn as - it keeps its styles. `root` is the surface. */
|
|
36
|
+
slots?: TooltipSlots;
|
|
37
|
+
/** Overrides for the slots a theme can style: `style`, `className`, `data-*` and `aria-*`. `root` is the surface. The arrow's position is the tooltip's. */
|
|
38
|
+
slotProps?: SlotProps<TooltipSlot>;
|
|
39
|
+
/** Overrides the CSS of the surface: an entry of `StyleSheet.create`, or a list of them. It wins over `slotProps.root.style`. */
|
|
40
|
+
style?: StyleOverride;
|
|
41
|
+
/** Draws an arrow towards the child. Default: `false`. */
|
|
42
|
+
hasArrow?: boolean;
|
|
43
|
+
/** How long the pointer or focus rests on the child before it opens, in milliseconds. Default: `100`. */
|
|
44
|
+
enterDelay?: number;
|
|
45
|
+
/** How long after they leave before it closes. Default: `0`. */
|
|
46
|
+
leaveDelay?: number;
|
|
47
|
+
/** How long a touch is held before it opens. Default: `700`. */
|
|
48
|
+
enterTouchDelay?: number;
|
|
49
|
+
/** How long after a touch ends before it closes. Default: `1500`. */
|
|
50
|
+
leaveTouchDelay?: number;
|
|
51
|
+
/** Describes the child (`aria-describedby`, while open) instead of naming it (`aria-label`). Default: `false`. */
|
|
52
|
+
shouldDescribeChild?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* With `shouldDescribeChild`: the child is described the whole time, as by a native `title`, not
|
|
55
|
+
* only while the tooltip is open. A visually hidden copy of a `title` sits beside the child for it
|
|
56
|
+
* to point at. Default: `false`.
|
|
57
|
+
*/
|
|
58
|
+
isDescriptionPersistent?: boolean;
|
|
59
|
+
/** Whether it is shown. Controlled with `onOpen` and `onClose`. */
|
|
60
|
+
isOpen?: boolean;
|
|
61
|
+
/** Whether it is shown at first, when uncontrolled. Default: `false`. */
|
|
62
|
+
defaultOpen?: boolean;
|
|
63
|
+
/** Fired when it asks to open. */
|
|
64
|
+
onOpen?: (event: Event | SyntheticEvent) => void;
|
|
65
|
+
/** Fired when it asks to close. */
|
|
66
|
+
onClose?: (event: Event | SyntheticEvent) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Whether a disabled child (`disabled`) is wrapped in an element of its own, which takes the pointer
|
|
69
|
+
* handlers and the placement, since a disabled control sends no pointer events. Left out for a child
|
|
70
|
+
* that is only marked disabled and still takes them - a menu row. Default: `true`.
|
|
71
|
+
*/
|
|
72
|
+
shouldWrapDisabledChild?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Whether the pointer can be moved onto the tooltip, which then stays open (WCAG 1.4.13). With
|
|
75
|
+
* `false` it takes no pointer events - a click goes to what is under it - and closes as the
|
|
76
|
+
* pointer leaves the child: for a text hint that holds nothing to use. Default: `true`.
|
|
77
|
+
*/
|
|
78
|
+
isInteractive?: boolean;
|
|
79
|
+
/** Opens on hover. Default: `true`. */
|
|
80
|
+
shouldOpenOnHover?: boolean;
|
|
81
|
+
/** Opens on keyboard focus. Default: `true`. */
|
|
82
|
+
shouldOpenOnFocus?: boolean;
|
|
83
|
+
/** Opens on a long touch. Default: `true`. */
|
|
84
|
+
shouldOpenOnTouch?: boolean;
|
|
85
|
+
/** Corner radius, resolves against `theme.radii`. Default: `theme.defaults.surfaceRadius`, else square. */
|
|
86
|
+
borderRadius?: keyof Theme['radii'];
|
|
87
|
+
/** Background, resolves against `theme.background`. Default: `'modal'`. */
|
|
88
|
+
bg?: keyof Theme['background'];
|
|
89
|
+
/** Text color, resolves against `theme.text`. Default: `theme.defaults.textColor`, else `'initial'`. */
|
|
90
|
+
textColor?: keyof Theme['text'];
|
|
91
|
+
/** Stacking layer from `theme.zOrder`. Default: `'tooltip'`. */
|
|
92
|
+
layer?: keyof Theme['zOrder'];
|
|
93
|
+
className?: string;
|
|
94
|
+
'data-testid'?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @description A short description of one child, shown on hover, keyboard focus and a long touch -
|
|
98
|
+
* a `role="tooltip"` in a `Portal`, placed beside its child and flipped for want of room. The
|
|
99
|
+
* child is named by it (`aria-label`) or described by it (`aria-describedby`, with
|
|
100
|
+
* `shouldDescribeChild`). It opens and closes after their delays, stays open while the pointer is
|
|
101
|
+
* on the tooltip itself, closes on Escape, and never takes or traps the focus.
|
|
102
|
+
*/
|
|
103
|
+
export declare const Tooltip: import("react").ForwardRefExoticComponent<Omit<TooltipProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
|
|
104
|
+
export interface TooltipGroupProps {
|
|
105
|
+
children?: ReactNode;
|
|
106
|
+
/**
|
|
107
|
+
* How long after a tooltip of the group closes the next one opens with no enter delay, in
|
|
108
|
+
* milliseconds - and for as long as one is open. After it, the tooltip's own `enterDelay`
|
|
109
|
+
* applies again. A tooltip that opens closes the one still showing, at once. It wins over
|
|
110
|
+
* `skipDelayDuration` in `theme.components.Tooltip.defaultProps`.
|
|
111
|
+
*/
|
|
112
|
+
skipDelayDuration?: number;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Lets the tooltips inside it open at once, with no enter delay, when the pointer or the focus
|
|
116
|
+
* moves to the next one just after another closed - a toolbar or a rail read from one icon to the
|
|
117
|
+
* next. It renders nothing of its own. Tooltips outside a group are unchanged, a touch keeps its
|
|
118
|
+
* own delay, and a tooltip whose `isOpen` the app controls is left alone: the group neither opens
|
|
119
|
+
* nor closes it, and it does not start the window.
|
|
120
|
+
*/
|
|
121
|
+
export declare function TooltipGroup({ children, skipDelayDuration }: Readonly<TooltipGroupProps>): import("react").JSX.Element;
|
|
122
|
+
export { TooltipOwnerState, type TooltipPlacement, TooltipSlot, TooltipThemeConfig };
|