@soroush.tech/design-system 2.0.0-rc.6 → 2.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/README.md +3 -3
- package/dist/Accordion/Accordion.d.cts +2 -2
- package/dist/Accordion/Accordion.d.mts +2 -2
- package/dist/Accordion/AccordionGroup.d.cts +1 -1
- package/dist/Accordion/AccordionGroup.d.mts +1 -1
- package/dist/Alert/Alert.d.cts +1 -1
- package/dist/Alert/Alert.d.mts +1 -1
- package/dist/AppBar.d.cts +1 -1
- package/dist/AppBar.d.mts +1 -1
- package/dist/Autocomplete.cjs +1 -1
- package/dist/Autocomplete.d.cts +1 -1
- package/dist/Autocomplete.d.mts +1 -1
- package/dist/Autocomplete.mjs +1 -1
- package/dist/Avatar.d.cts +1 -1
- package/dist/Avatar.d.mts +1 -1
- package/dist/Backdrop.d.cts +1 -1
- package/dist/Backdrop.d.mts +1 -1
- package/dist/Badge.d.cts +1 -1
- package/dist/Badge.d.mts +1 -1
- package/dist/Breadcrumbs.d.cts +3 -3
- package/dist/Breadcrumbs.d.mts +3 -3
- package/dist/Button.d.cts +1 -1
- package/dist/Button.d.mts +1 -1
- package/dist/ButtonGroup.d.cts +1 -1
- package/dist/ButtonGroup.d.mts +1 -1
- package/dist/Card.d.cts +4 -4
- package/dist/Card.d.mts +4 -4
- package/dist/Checkbox.d.cts +1 -1
- package/dist/Checkbox.d.mts +1 -1
- package/dist/Chip.d.cts +1 -1
- package/dist/Chip.d.mts +1 -1
- package/dist/CircularProgress.d.cts +2 -2
- package/dist/CircularProgress.d.mts +2 -2
- package/dist/Collapse.d.cts +1 -1
- package/dist/Collapse.d.mts +1 -1
- package/dist/Drawer.d.cts +3 -3
- package/dist/Drawer.d.mts +3 -3
- package/dist/Fab.d.cts +1 -1
- package/dist/Fab.d.mts +1 -1
- package/dist/FabMenu/FabMenu.d.cts +1 -1
- package/dist/FabMenu/FabMenu.d.mts +1 -1
- package/dist/FabMenu/FabMenuItem.d.cts +1 -1
- package/dist/FabMenu/FabMenuItem.d.mts +1 -1
- package/dist/Fade.d.cts +1 -1
- package/dist/Fade.d.mts +1 -1
- package/dist/Flex.d.cts +1 -1
- package/dist/Flex.d.mts +1 -1
- package/dist/Form.d.cts +1 -1
- package/dist/Form.d.mts +1 -1
- package/dist/FormControl.d.cts +1 -1
- package/dist/FormControl.d.mts +1 -1
- package/dist/FormHelperText.d.cts +1 -1
- package/dist/FormHelperText.d.mts +1 -1
- package/dist/FormLabel.d.cts +1 -1
- package/dist/FormLabel.d.mts +1 -1
- package/dist/Grid.d.cts +1 -1
- package/dist/Grid.d.mts +1 -1
- package/dist/Grow.d.cts +1 -1
- package/dist/Grow.d.mts +1 -1
- package/dist/Icon.d.cts +1 -1
- package/dist/Icon.d.mts +1 -1
- package/dist/Image.d.cts +1 -1
- package/dist/Image.d.mts +1 -1
- package/dist/LinearProgress.d.cts +2 -2
- package/dist/LinearProgress.d.mts +2 -2
- package/dist/Link.d.cts +1 -1
- package/dist/Link.d.mts +1 -1
- package/dist/Menu/ContextMenu.cjs +1 -1
- package/dist/Menu/ContextMenu.d.cts +5 -5
- package/dist/Menu/ContextMenu.d.mts +5 -5
- package/dist/Menu/ContextMenu.mjs +1 -1
- package/dist/Menu/Menu.cjs +1 -1
- package/dist/Menu/Menu.d.cts +1 -1
- package/dist/Menu/Menu.d.mts +1 -1
- package/dist/Menu/Menu.mjs +1 -1
- package/dist/Menu/MenuItems.cjs +1 -1
- package/dist/Menu/MenuItems.d.cts +1 -1
- package/dist/Menu/MenuItems.d.mts +1 -1
- package/dist/Menu/MenuItems.mjs +1 -1
- package/dist/Menu/MenuList.d.cts +2 -2
- package/dist/Menu/MenuList.d.mts +2 -2
- package/dist/{Menu-Bx9jaHOy.cjs → Menu-BfJF32J2.cjs} +1 -1
- package/dist/{Menu-D4AIpdJv.mjs → Menu-CX9V2DAu.mjs} +1 -1
- package/dist/Menu.cjs +1 -1
- package/dist/Menu.d.cts +3 -3
- package/dist/Menu.d.mts +3 -3
- package/dist/Menu.mjs +1 -1
- package/dist/{MenuItem-DXRw3Yca.cjs → MenuItem-CvCMGXuL.cjs} +1 -1
- package/dist/{MenuItem-vXHGPK8g.mjs → MenuItem-DdPzSWZY.mjs} +1 -1
- package/dist/MenuItem.cjs +1 -1
- package/dist/MenuItem.d.cts +1 -1
- package/dist/MenuItem.d.mts +1 -1
- package/dist/MenuItem.mjs +1 -1
- package/dist/{MenuListContext-BwgQHUu9.d.cts → MenuListContext-DJ_qJ1Uo.d.cts} +2 -2
- package/dist/{MenuListContext-DbnAoUdJ.d.mts → MenuListContext-DiZAVDCb.d.mts} +2 -2
- package/dist/Modal.d.cts +1 -1
- package/dist/Modal.d.mts +1 -1
- package/dist/NativeSelect.d.cts +2 -2
- package/dist/NativeSelect.d.mts +2 -2
- package/dist/NavTree/NavLink.d.cts +1 -1
- package/dist/NavTree/NavLink.d.mts +1 -1
- package/dist/NavTree/NavTree.d.cts +1 -1
- package/dist/NavTree/NavTree.d.mts +1 -1
- package/dist/NumberInput.d.cts +1 -1
- package/dist/NumberInput.d.mts +1 -1
- package/dist/Pagination/PaginationItem.d.cts +1 -1
- package/dist/Pagination/PaginationItem.d.mts +1 -1
- package/dist/Pagination.d.cts +2 -2
- package/dist/Pagination.d.mts +2 -2
- package/dist/Paper.d.cts +2 -2
- package/dist/Paper.d.mts +2 -2
- package/dist/Popover.d.cts +4 -14
- package/dist/Popover.d.mts +4 -14
- package/dist/Pressable.d.cts +1 -1
- package/dist/Pressable.d.mts +1 -1
- package/dist/Quote.d.cts +2 -2
- package/dist/Quote.d.mts +2 -2
- package/dist/Radio.d.cts +1 -1
- package/dist/Radio.d.mts +1 -1
- package/dist/RangeInput.d.cts +1 -1
- package/dist/RangeInput.d.mts +1 -1
- package/dist/Rating.d.cts +1 -1
- package/dist/Rating.d.mts +1 -1
- package/dist/ScrollArea.d.cts +1 -1
- package/dist/ScrollArea.d.mts +1 -1
- package/dist/Select.d.cts +2 -2
- package/dist/Select.d.mts +2 -2
- package/dist/Sidebar/Sidebar.d.cts +1 -1
- package/dist/Sidebar/Sidebar.d.mts +1 -1
- package/dist/Sidebar/SidebarItem.d.cts +3 -3
- package/dist/Sidebar/SidebarItem.d.mts +3 -3
- package/dist/Skeleton.d.cts +1 -1
- package/dist/Skeleton.d.mts +1 -1
- package/dist/Slide.d.cts +1 -1
- package/dist/Slide.d.mts +1 -1
- package/dist/Snackbar.d.cts +2 -2
- package/dist/Snackbar.d.mts +2 -2
- package/dist/Switch.d.cts +1 -1
- package/dist/Switch.d.mts +1 -1
- package/dist/Table/Table.d.cts +2 -2
- package/dist/Table/Table.d.mts +2 -2
- package/dist/Table/TableBody.d.cts +1 -1
- package/dist/Table/TableBody.d.mts +1 -1
- package/dist/Table/TableCell.d.cts +1 -1
- package/dist/Table/TableCell.d.mts +1 -1
- package/dist/Table/TableContainer.d.cts +1 -1
- package/dist/Table/TableContainer.d.mts +1 -1
- package/dist/Table/TableControl.d.cts +1 -1
- package/dist/Table/TableControl.d.mts +1 -1
- package/dist/Table/TableFooter.d.cts +1 -1
- package/dist/Table/TableFooter.d.mts +1 -1
- package/dist/Table/TableHead.d.cts +1 -1
- package/dist/Table/TableHead.d.mts +1 -1
- package/dist/Table/TablePagination.d.cts +2 -2
- package/dist/Table/TablePagination.d.mts +2 -2
- package/dist/Table/TablePaginationActions.d.cts +1 -1
- package/dist/Table/TablePaginationActions.d.mts +1 -1
- package/dist/Table/TableRow.d.cts +1 -1
- package/dist/Table/TableRow.d.mts +1 -1
- package/dist/Table/TableSortLabel.d.cts +1 -1
- package/dist/Table/TableSortLabel.d.mts +1 -1
- package/dist/Table/hooks.d.cts +1 -1
- package/dist/Table/hooks.d.mts +1 -1
- package/dist/Table.d.cts +5 -5
- package/dist/Table.d.mts +5 -5
- package/dist/{TableContext-0hifLOKH.d.mts → TableContext-4sJdk84N.d.cts} +1 -1
- package/dist/{TableContext-fIyMD_Bj.d.cts → TableContext-BCW5av9c.d.mts} +1 -1
- package/dist/Tabs/Tab.d.cts +2 -2
- package/dist/Tabs/Tab.d.mts +2 -2
- package/dist/Tabs/TabContext.d.cts +1 -1
- package/dist/Tabs/TabContext.d.mts +1 -1
- package/dist/Tabs/TabList.cjs +1 -1
- package/dist/Tabs/TabList.d.cts +1 -1
- package/dist/Tabs/TabList.d.mts +1 -1
- package/dist/Tabs/TabList.mjs +1 -1
- package/dist/Tabs/TabPanel.d.cts +2 -2
- package/dist/Tabs/TabPanel.d.mts +2 -2
- package/dist/Tabs/TabScrollButton.d.cts +1 -1
- package/dist/Tabs/TabScrollButton.d.mts +1 -1
- package/dist/Tabs/Tabs.cjs +1 -1
- package/dist/Tabs/Tabs.d.cts +2 -2
- package/dist/Tabs/Tabs.d.mts +2 -2
- package/dist/Tabs/Tabs.mjs +1 -1
- package/dist/{Tabs-JvjuCU8m.mjs → Tabs-CG-hRs9L.mjs} +2 -2
- package/dist/{Tabs-BsbX0jFL.cjs → Tabs-CPH0H6yp.cjs} +2 -2
- package/dist/Tabs.cjs +1 -1
- package/dist/Tabs.d.cts +3 -3
- package/dist/Tabs.d.mts +3 -3
- package/dist/Tabs.mjs +1 -1
- package/dist/{TabsContext-0ZtedNyH.d.mts → TabsContext-CsiW5MOp.d.mts} +1 -1
- package/dist/{TabsContext-MpMEEVuB.d.cts → TabsContext-DrmDtBqA.d.cts} +1 -1
- package/dist/TextInput.d.cts +1 -1
- package/dist/TextInput.d.mts +1 -1
- package/dist/ToggleButton/ToggleButton.d.cts +1 -1
- package/dist/ToggleButton/ToggleButton.d.mts +1 -1
- package/dist/ToggleButton/ToggleButtonGroup.d.cts +1 -1
- package/dist/ToggleButton/ToggleButtonGroup.d.mts +1 -1
- package/dist/Tooltip.cjs +78 -34
- package/dist/Tooltip.d.cts +26 -4
- package/dist/Tooltip.d.mts +26 -4
- package/dist/Tooltip.mjs +78 -34
- package/dist/TransferList.d.cts +1 -1
- package/dist/TransferList.d.mts +1 -1
- package/dist/Typography.d.cts +2 -2
- package/dist/Typography.d.mts +2 -2
- package/dist/View.d.cts +1 -1
- package/dist/View.d.mts +1 -1
- package/dist/Zoom.d.cts +1 -1
- package/dist/Zoom.d.mts +1 -1
- package/dist/catalog.cjs +8 -0
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.mts +1 -1
- package/dist/catalog.mjs +8 -0
- package/dist/computePopoverPosition-JgOwCM7k.d.cts +12 -0
- package/dist/computePopoverPosition-JgOwCM7k.d.mts +12 -0
- package/dist/engine.d.cts +1 -1
- package/dist/engine.d.mts +1 -1
- package/dist/{index-76zijQoi.d.mts → index-5TAVgzbU.d.mts} +2 -2
- package/dist/index-6zQ2VUlM.d.cts +1 -0
- package/dist/index-B1qv6yGM.d.mts +1 -0
- package/dist/{index-CR8qkP8U.d.mts → index-BWiDilH8.d.mts} +2 -0
- package/dist/{index-C7EUYyom.d.cts → index-BYAtunSZ.d.cts} +2 -2
- package/dist/{index-Dm7vQHor.d.cts → index-Ba39mhDf.d.cts} +4 -4
- package/dist/{index-CKywwIep.d.mts → index-BgmEVOSj.d.mts} +1 -1
- package/dist/{index-SotXsXXb.d.mts → index-Biqn5xUs.d.mts} +4 -4
- package/dist/{index-CJYWGPVO.d.mts → index-BlHFb150.d.cts} +2 -2
- package/dist/{index-DBF5n3ey.d.cts → index-Bo8Og0oC.d.cts} +2 -2
- package/dist/{index-Byk1_ms9.d.cts → index-Bp9ECTzr.d.mts} +2 -2
- package/dist/{index-CfB7OceY.d.cts → index-Buu5MtRG.d.mts} +1 -1
- package/dist/{index-BChRNCld.d.mts → index-Bx-4KmJU.d.mts} +1 -1
- package/dist/{index-CAt0-L4i.d.cts → index-C3TrdOpQ.d.cts} +2 -2
- package/dist/{index-CF_pl72E.d.mts → index-CAICXdTA.d.cts} +1 -1
- package/dist/{index-CQeTS_zL.d.cts → index-CBOtkDdX.d.cts} +1 -1
- package/dist/{index-DbgrItbx.d.cts → index-CW0DW6Aq.d.mts} +2 -2
- package/dist/{index-Dt274Ngt.d.mts → index-CeFExef3.d.cts} +2 -2
- package/dist/{index-C2a-5yop.d.mts → index-CyOSmefH.d.cts} +2 -2
- package/dist/{index-CLTFsCYC.d.cts → index-D--R4_5H.d.mts} +2 -2
- package/dist/{index-hoHPfsc1.d.cts → index-D24iFgwR.d.cts} +2 -2
- package/dist/{index-BXlBouWV.d.mts → index-DKNvADeE.d.mts} +2 -2
- package/dist/{index-C2tTbEBS.d.mts → index-DM7HHa4V.d.mts} +2 -2
- package/dist/{index-RaDENVX_.d.cts → index-DQYhGgbl.d.cts} +2 -2
- package/dist/{index-BuAKhHMs.d.cts → index-DR76LcSz.d.mts} +1 -1
- package/dist/{index-BV5BvdeN.d.mts → index-DWon54cO.d.cts} +1 -1
- package/dist/{index-C_J58B_n.d.mts → index-D_azfqsX.d.mts} +1 -1
- package/dist/{index-BzQze7eY.d.cts → index-DgLjcrkG.d.cts} +1 -1
- package/dist/{index-Dxu6Ks2A.d.cts → index-DhTzn0mf.d.cts} +1 -1
- package/dist/{index-BAzMLTVi.d.mts → index-DhzjNAzv.d.mts} +4 -4
- package/dist/{index-D48qVo1X.d.mts → index-DjmWIzXF.d.mts} +2 -2
- package/dist/{index-B3Bdupj3.d.mts → index-DrfJt7W6.d.cts} +2 -2
- package/dist/{index-BC9S8Fpr.d.cts → index-Dt-ZNTnC.d.cts} +1 -1
- package/dist/{index-4maWM1H8.d.mts → index-DtK3SaKA.d.mts} +1 -1
- package/dist/{index-CGyIuCRh.d.cts → index-DtVrZFJI.d.mts} +2 -2
- package/dist/{index-CnVvfG9_.d.mts → index-Dudkopvi.d.mts} +1 -1
- package/dist/{index-Lsm4v8fB.d.cts → index-DvVQLBZc.d.cts} +2 -0
- package/dist/{index-D4PcgL-c.d.cts → index-HAVWK7RM.d.cts} +2 -2
- package/dist/{index-Bo45R0nD.d.cts → index-HLDMvfb2.d.cts} +4 -4
- package/dist/{index-UiyZAKID.d.mts → index-YKXzINGk.d.mts} +2 -2
- package/dist/{index-Cjh607-v.d.cts → index-fRyMPKtY.d.cts} +1 -1
- package/dist/{index-tOrd12AJ.d.mts → index-m1RGSQlP.d.mts} +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/style.d.cts +2 -2
- package/dist/style.d.mts +2 -2
- package/dist/theme.d.cts +2 -2
- package/dist/theme.d.mts +2 -2
- package/dist/{useAnchoredPlacement-ee6KzG3t.cjs → useAnchoredPlacement-BSfjNMut.cjs} +10 -5
- package/dist/{useAnchoredPlacement-COrXZxhm.mjs → useAnchoredPlacement-txSaWzfk.mjs} +10 -5
- package/dist/{useTablePagination-BlD8mK8k.d.mts → useTablePagination-BOzuKUnF.d.mts} +1 -1
- package/dist/{useTablePagination-CGjb_jPX.d.cts → useTablePagination-CraL2Mux.d.cts} +1 -1
- package/dist/{useTransition-3EoagwIe.d.mts → useTransition-B-hzi7Sm.d.mts} +1 -1
- package/dist/{useTransition-C89K0mS7.d.cts → useTransition-CF_Zy_tM.d.cts} +1 -1
- package/package.json +2 -2
- package/dist/index-1Xzj0iAs.d.mts +0 -1
- package/dist/index-323PrYLR.d.cts +0 -1
package/dist/Tooltip.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const require_themeDefault = require("./themeDefault-DbPHBbNO.cjs");
|
|
|
5
5
|
const require_getSurfaceRadius = require("./getSurfaceRadius-DwOn3ALC.cjs");
|
|
6
6
|
const require_useControlled = require("./useControlled-CzCxM4J3.cjs");
|
|
7
7
|
const require_Portal = require("./Portal.cjs");
|
|
8
|
-
const require_useAnchoredPlacement = require("./useAnchoredPlacement-
|
|
8
|
+
const require_useAnchoredPlacement = require("./useAnchoredPlacement-BSfjNMut.cjs");
|
|
9
9
|
const require_useMergedRefs = require("./useMergedRefs-BtctsnmX.cjs");
|
|
10
10
|
const require_getTooltipOrigins = require("./getTooltipOrigins-8b5zQafY.cjs");
|
|
11
11
|
let react = require("react");
|
|
@@ -25,7 +25,7 @@ const isKeyboardFocus = (event) => {
|
|
|
25
25
|
* delayed; moving from the child onto the tooltip does not close it, so its text can be read and
|
|
26
26
|
* selected (WCAG 1.4.13); Escape closes it at once.
|
|
27
27
|
*/
|
|
28
|
-
function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDelay, leaveDelay, enterTouchDelay, leaveTouchDelay, shouldOpenOnHover, shouldOpenOnFocus, shouldOpenOnTouch }) {
|
|
28
|
+
function useTooltip({ isOpen: isOpenProp, defaultOpen, isAtPoint = false, onOpen, onClose, enterDelay, leaveDelay, enterTouchDelay, leaveTouchDelay, shouldOpenOnHover, shouldOpenOnFocus, shouldOpenOnTouch }) {
|
|
29
29
|
const [isOpen, setIsOpen] = require_useControlled.useControlled({
|
|
30
30
|
controlled: isOpenProp,
|
|
31
31
|
default: defaultOpen
|
|
@@ -34,6 +34,7 @@ function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDel
|
|
|
34
34
|
const latest = (0, react.useRef)({
|
|
35
35
|
isOpen,
|
|
36
36
|
isOpenProp,
|
|
37
|
+
isAtPoint,
|
|
37
38
|
onOpen,
|
|
38
39
|
onClose
|
|
39
40
|
});
|
|
@@ -41,6 +42,7 @@ function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDel
|
|
|
41
42
|
latest.current = {
|
|
42
43
|
isOpen,
|
|
43
44
|
isOpenProp,
|
|
45
|
+
isAtPoint,
|
|
44
46
|
onOpen,
|
|
45
47
|
onClose
|
|
46
48
|
};
|
|
@@ -51,6 +53,7 @@ function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDel
|
|
|
51
53
|
timer.current = window.setTimeout(() => {
|
|
52
54
|
const current = latest.current;
|
|
53
55
|
if (current.isOpen === next) return;
|
|
56
|
+
if (next && current.isAtPoint) return;
|
|
54
57
|
if (current.isOpenProp === void 0) setIsOpen(next);
|
|
55
58
|
(next ? current.onOpen : current.onClose)?.(event);
|
|
56
59
|
}, delay);
|
|
@@ -87,6 +90,9 @@ function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDel
|
|
|
87
90
|
},
|
|
88
91
|
onTouchCancel: (event) => {
|
|
89
92
|
if (shouldOpenOnTouch) ask(false, event, leaveTouchDelay);
|
|
93
|
+
},
|
|
94
|
+
onPointerDown: (event) => {
|
|
95
|
+
if (event.pointerType !== "touch") ask(false, event, 0);
|
|
90
96
|
}
|
|
91
97
|
},
|
|
92
98
|
surfaceHandlers: {
|
|
@@ -108,12 +114,14 @@ const TooltipSurface = require_src.styled("div", {
|
|
|
108
114
|
label: "Tooltip",
|
|
109
115
|
shouldForwardProp: (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([
|
|
110
116
|
"layer",
|
|
117
|
+
"isInteractive",
|
|
111
118
|
"borderRadius",
|
|
112
119
|
"bg",
|
|
113
120
|
"textColor"
|
|
114
121
|
])
|
|
115
|
-
})(({ theme, layer, borderRadius, bg, textColor }) => ({
|
|
122
|
+
})(({ theme, layer, isInteractive, borderRadius, bg, textColor }) => ({
|
|
116
123
|
position: "fixed",
|
|
124
|
+
...!isInteractive && { pointerEvents: "none" },
|
|
117
125
|
top: 0,
|
|
118
126
|
left: 0,
|
|
119
127
|
visibility: "hidden",
|
|
@@ -130,6 +138,18 @@ const TooltipSurface = require_src.styled("div", {
|
|
|
130
138
|
lineHeight: (0, require_src.src_exports.get)(theme, "lineHeights.base"),
|
|
131
139
|
overflowWrap: "break-word"
|
|
132
140
|
}));
|
|
141
|
+
const TooltipDescription = require_src.styled("span", { label: "TooltipDescription" })({
|
|
142
|
+
position: "absolute",
|
|
143
|
+
width: 1,
|
|
144
|
+
height: 1,
|
|
145
|
+
margin: -1,
|
|
146
|
+
padding: 0,
|
|
147
|
+
border: 0,
|
|
148
|
+
overflow: "hidden",
|
|
149
|
+
clip: "rect(0 0 0 0)",
|
|
150
|
+
whiteSpace: "nowrap"
|
|
151
|
+
});
|
|
152
|
+
const TooltipTarget = require_src.styled("span", { label: "TooltipTarget" })({ display: "inline-grid" });
|
|
133
153
|
const TooltipArrow = require_src.styled("span", {
|
|
134
154
|
name: "Tooltip",
|
|
135
155
|
slot: "arrow",
|
|
@@ -186,19 +206,23 @@ const getArrowStyle = ({ side, offset }) => {
|
|
|
186
206
|
* `shouldDescribeChild`). It opens and closes after their delays, stays open while the pointer is
|
|
187
207
|
* on the tooltip itself, closes on Escape, and never takes or traps the focus.
|
|
188
208
|
*/
|
|
189
|
-
function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrowProp, enterDelay: enterDelayProp, leaveDelay: leaveDelayProp, enterTouchDelay: enterTouchDelayProp, leaveTouchDelay: leaveTouchDelayProp, shouldDescribeChild: shouldDescribeChildProp, isOpen: isOpenProp, defaultOpen = false, onOpen, onClose, shouldOpenOnHover: shouldOpenOnHoverProp, shouldOpenOnFocus: shouldOpenOnFocusProp, shouldOpenOnTouch: shouldOpenOnTouchProp, slots, slotProps, layer: layerProp, borderRadius: borderRadiusProp, bg: bgProp, textColor: textColorProp, className, "data-testid": dataTestid }) {
|
|
209
|
+
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, shouldOpenOnHover: shouldOpenOnHoverProp, shouldOpenOnFocus: shouldOpenOnFocusProp, shouldOpenOnTouch: shouldOpenOnTouchProp, slots, slotProps, layer: layerProp, borderRadius: borderRadiusProp, bg: bgProp, textColor: textColorProp, className, "data-testid": dataTestid }) {
|
|
190
210
|
const dp = require_theme.useDefaultProps("Tooltip");
|
|
191
211
|
const placement = placementProp ?? dp.placement ?? "top";
|
|
192
212
|
const hasArrow = hasArrowProp ?? dp.hasArrow ?? false;
|
|
193
213
|
const shouldDescribeChild = shouldDescribeChildProp ?? dp.shouldDescribeChild ?? false;
|
|
214
|
+
const isDescriptionPersistent = isDescriptionPersistentProp ?? dp.isDescriptionPersistent ?? false;
|
|
215
|
+
const isInteractive = isInteractiveProp ?? dp.isInteractive ?? true;
|
|
194
216
|
const layer = layerProp ?? dp.layer ?? "tooltip";
|
|
195
217
|
const borderRadius = borderRadiusProp ?? dp.borderRadius;
|
|
196
218
|
const bg = bgProp ?? dp.bg;
|
|
197
219
|
const textColor = textColorProp ?? dp.textColor;
|
|
198
220
|
const id = (0, react.useId)();
|
|
221
|
+
const isAtPoint = anchorPosition !== void 0;
|
|
199
222
|
const { isOpen, childHandlers, surfaceHandlers } = useTooltip({
|
|
200
223
|
isOpen: isOpenProp,
|
|
201
224
|
defaultOpen,
|
|
225
|
+
isAtPoint,
|
|
202
226
|
onOpen,
|
|
203
227
|
onClose,
|
|
204
228
|
enterDelay: enterDelayProp ?? dp.enterDelay ?? 100,
|
|
@@ -209,11 +233,14 @@ function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrow
|
|
|
209
233
|
shouldOpenOnFocus: shouldOpenOnFocusProp ?? dp.shouldOpenOnFocus ?? true,
|
|
210
234
|
shouldOpenOnTouch: shouldOpenOnTouchProp ?? dp.shouldOpenOnTouch ?? true
|
|
211
235
|
});
|
|
212
|
-
const
|
|
236
|
+
const hasTitle = title !== void 0 && title !== null && title !== "";
|
|
237
|
+
const isShown = isOpen && hasTitle;
|
|
213
238
|
const anchorRef = (0, react.useRef)(null);
|
|
239
|
+
const noAnchorRef = (0, react.useRef)(null);
|
|
214
240
|
const surfaceRef = (0, react.useRef)(null);
|
|
215
|
-
const own = children
|
|
216
|
-
const
|
|
241
|
+
const own = children?.props ?? {};
|
|
242
|
+
const isChildDisabled = own.disabled === true;
|
|
243
|
+
const ref = require_useMergedRefs.useMergedRefs(isChildDisabled ? void 0 : anchorRef, own.ref);
|
|
217
244
|
const [arrow, setArrow] = (0, react.useState)(null);
|
|
218
245
|
const getOrigins = (0, react.useCallback)((context) => require_getTooltipOrigins.getTooltipOrigins(require_getTooltipOrigins.resolveTooltipPlacement(placement, context), context.isRtl), [placement]);
|
|
219
246
|
const onPlaced = (0, react.useCallback)((placed) => {
|
|
@@ -223,7 +250,8 @@ function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrow
|
|
|
223
250
|
}, [hasArrow]);
|
|
224
251
|
require_useAnchoredPlacement.useAnchoredPlacement({
|
|
225
252
|
isOpen: isShown,
|
|
226
|
-
anchorRef,
|
|
253
|
+
anchorRef: anchorPosition ? noAnchorRef : anchorRef,
|
|
254
|
+
anchorPosition,
|
|
227
255
|
surfaceRef,
|
|
228
256
|
getOrigins,
|
|
229
257
|
margin: MARGIN,
|
|
@@ -236,33 +264,49 @@ function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrow
|
|
|
236
264
|
}]));
|
|
237
265
|
const ownDescription = own["aria-describedby"];
|
|
238
266
|
const names = typeof title === "string" && own["aria-label"] === void 0 && own["aria-labelledby"] === void 0 ? { "aria-label": title } : {};
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
267
|
+
const descriptionId = `${id}-description`;
|
|
268
|
+
const hasPersistentDescription = children !== void 0 && shouldDescribeChild && isDescriptionPersistent && hasTitle;
|
|
269
|
+
const describedBy = (shown) => hasPersistentDescription ? [ownDescription, descriptionId].filter(Boolean).join(" ") : [ownDescription, shown ? id : void 0].filter(Boolean).join(" ") || void 0;
|
|
270
|
+
const ariaProps = shouldDescribeChild ? { "aria-describedby": describedBy(isShown) } : names;
|
|
271
|
+
const child = children ? (0, react.cloneElement)(children, {
|
|
272
|
+
...isChildDisabled || isAtPoint ? {} : handlers,
|
|
242
273
|
...ariaProps,
|
|
243
274
|
ref
|
|
244
|
-
})
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
275
|
+
}) : null;
|
|
276
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
277
|
+
isChildDisabled && !isAtPoint ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipTarget, {
|
|
278
|
+
ref: anchorRef,
|
|
279
|
+
...handlers,
|
|
280
|
+
children: child
|
|
281
|
+
}) : child,
|
|
282
|
+
hasPersistentDescription && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipDescription, {
|
|
283
|
+
id: descriptionId,
|
|
284
|
+
children: title
|
|
285
|
+
}),
|
|
286
|
+
isShown && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Portal.Portal, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(TooltipSurface, {
|
|
287
|
+
...slotProps?.root,
|
|
288
|
+
as: slots?.root,
|
|
289
|
+
ref: surfaceRef,
|
|
290
|
+
id,
|
|
291
|
+
role: "tooltip",
|
|
292
|
+
layer,
|
|
293
|
+
isInteractive,
|
|
294
|
+
borderRadius,
|
|
295
|
+
bg,
|
|
296
|
+
textColor,
|
|
297
|
+
className: [slotProps?.root?.className, className].filter(Boolean).join(" ") || void 0,
|
|
298
|
+
"data-testid": dataTestid ?? slotProps?.root?.["data-testid"],
|
|
299
|
+
...isAtPoint || !isInteractive ? {} : surfaceHandlers,
|
|
300
|
+
children: [title, hasArrow && arrow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TooltipArrow, {
|
|
301
|
+
...slotProps?.arrow,
|
|
302
|
+
as: slots?.arrow,
|
|
303
|
+
style: {
|
|
304
|
+
...slotProps?.arrow?.style,
|
|
305
|
+
...getArrowStyle(arrow)
|
|
306
|
+
},
|
|
307
|
+
"aria-hidden": "true"
|
|
308
|
+
}) : null]
|
|
309
|
+
}) })
|
|
310
|
+
] });
|
|
267
311
|
}
|
|
268
312
|
exports.Tooltip = Tooltip;
|
package/dist/Tooltip.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { nt as Theme } from "./index-
|
|
1
|
+
import { nt as Theme } from "./index-DvVQLBZc.cjs";
|
|
2
|
+
import { n as PopoverPosition } from "./computePopoverPosition-JgOwCM7k.cjs";
|
|
2
3
|
import { ElementType, HTMLAttributes, ReactElement, ReactNode, SyntheticEvent } from "react";
|
|
3
4
|
/** A side of its child a tooltip sits on - and, after the dash, which end of that side it lines up with. */
|
|
4
5
|
type FixedTooltipPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
@@ -16,8 +17,17 @@ interface TooltipSlotProps {
|
|
|
16
17
|
arrow?: SlotProps;
|
|
17
18
|
}
|
|
18
19
|
interface TooltipProps {
|
|
19
|
-
/**
|
|
20
|
-
|
|
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;
|
|
21
31
|
/** What the tooltip says. Nothing says no tooltip. */
|
|
22
32
|
title?: ReactNode;
|
|
23
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'`. */
|
|
@@ -38,6 +48,12 @@ interface TooltipProps {
|
|
|
38
48
|
leaveTouchDelay?: number;
|
|
39
49
|
/** Describes the child (`aria-describedby`, while open) instead of naming it (`aria-label`). Default: `false`. */
|
|
40
50
|
shouldDescribeChild?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* With `shouldDescribeChild`: the child is described the whole time, as by a native `title`, not
|
|
53
|
+
* only while the tooltip is open. A visually hidden copy of a `title` sits beside the child for it
|
|
54
|
+
* to point at. Default: `false`.
|
|
55
|
+
*/
|
|
56
|
+
isDescriptionPersistent?: boolean;
|
|
41
57
|
/** Whether it is shown. Controlled with `onOpen` and `onClose`. */
|
|
42
58
|
isOpen?: boolean;
|
|
43
59
|
/** Whether it is shown at first, when uncontrolled. Default: `false`. */
|
|
@@ -46,6 +62,12 @@ interface TooltipProps {
|
|
|
46
62
|
onOpen?: (event: Event | SyntheticEvent) => void;
|
|
47
63
|
/** Fired when it asks to close. */
|
|
48
64
|
onClose?: (event: Event | SyntheticEvent) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the pointer can be moved onto the tooltip, which then stays open (WCAG 1.4.13). With
|
|
67
|
+
* `false` it takes no pointer events - a click goes to what is under it - and closes as the
|
|
68
|
+
* pointer leaves the child: for a text hint that holds nothing to use. Default: `true`.
|
|
69
|
+
*/
|
|
70
|
+
isInteractive?: boolean;
|
|
49
71
|
/** Opens on hover. Default: `true`. */
|
|
50
72
|
shouldOpenOnHover?: boolean;
|
|
51
73
|
/** Opens on keyboard focus. Default: `true`. */
|
|
@@ -70,5 +92,5 @@ interface TooltipProps {
|
|
|
70
92
|
* `shouldDescribeChild`). It opens and closes after their delays, stays open while the pointer is
|
|
71
93
|
* on the tooltip itself, closes on Escape, and never takes or traps the focus.
|
|
72
94
|
*/
|
|
73
|
-
declare function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrowProp, enterDelay: enterDelayProp, leaveDelay: leaveDelayProp, enterTouchDelay: enterTouchDelayProp, leaveTouchDelay: leaveTouchDelayProp, shouldDescribeChild: shouldDescribeChildProp, isOpen: isOpenProp, defaultOpen, onOpen, onClose, shouldOpenOnHover: shouldOpenOnHoverProp, shouldOpenOnFocus: shouldOpenOnFocusProp, shouldOpenOnTouch: shouldOpenOnTouchProp, slots, slotProps, layer: layerProp, borderRadius: borderRadiusProp, bg: bgProp, textColor: textColorProp, className, 'data-testid': dataTestid }: Readonly<TooltipProps>): import("react").JSX.Element;
|
|
95
|
+
declare function Tooltip({ children, anchorPosition, title, placement: placementProp, hasArrow: hasArrowProp, enterDelay: enterDelayProp, leaveDelay: leaveDelayProp, enterTouchDelay: enterTouchDelayProp, leaveTouchDelay: leaveTouchDelayProp, shouldDescribeChild: shouldDescribeChildProp, isDescriptionPersistent: isDescriptionPersistentProp, isOpen: isOpenProp, defaultOpen, onOpen, onClose, isInteractive: isInteractiveProp, shouldOpenOnHover: shouldOpenOnHoverProp, shouldOpenOnFocus: shouldOpenOnFocusProp, shouldOpenOnTouch: shouldOpenOnTouchProp, slots, slotProps, layer: layerProp, borderRadius: borderRadiusProp, bg: bgProp, textColor: textColorProp, className, 'data-testid': dataTestid }: Readonly<TooltipProps>): import("react").JSX.Element;
|
|
74
96
|
export { Tooltip, type TooltipPlacement, TooltipProps, TooltipSlotProps, TooltipSlots };
|
package/dist/Tooltip.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { nt as Theme } from "./index-
|
|
1
|
+
import { nt as Theme } from "./index-BWiDilH8.mjs";
|
|
2
|
+
import { n as PopoverPosition } from "./computePopoverPosition-JgOwCM7k.mjs";
|
|
2
3
|
import { ElementType, HTMLAttributes, ReactElement, ReactNode, SyntheticEvent } from "react";
|
|
3
4
|
/** A side of its child a tooltip sits on - and, after the dash, which end of that side it lines up with. */
|
|
4
5
|
type FixedTooltipPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
@@ -16,8 +17,17 @@ interface TooltipSlotProps {
|
|
|
16
17
|
arrow?: SlotProps;
|
|
17
18
|
}
|
|
18
19
|
interface TooltipProps {
|
|
19
|
-
/**
|
|
20
|
-
|
|
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;
|
|
21
31
|
/** What the tooltip says. Nothing says no tooltip. */
|
|
22
32
|
title?: ReactNode;
|
|
23
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'`. */
|
|
@@ -38,6 +48,12 @@ interface TooltipProps {
|
|
|
38
48
|
leaveTouchDelay?: number;
|
|
39
49
|
/** Describes the child (`aria-describedby`, while open) instead of naming it (`aria-label`). Default: `false`. */
|
|
40
50
|
shouldDescribeChild?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* With `shouldDescribeChild`: the child is described the whole time, as by a native `title`, not
|
|
53
|
+
* only while the tooltip is open. A visually hidden copy of a `title` sits beside the child for it
|
|
54
|
+
* to point at. Default: `false`.
|
|
55
|
+
*/
|
|
56
|
+
isDescriptionPersistent?: boolean;
|
|
41
57
|
/** Whether it is shown. Controlled with `onOpen` and `onClose`. */
|
|
42
58
|
isOpen?: boolean;
|
|
43
59
|
/** Whether it is shown at first, when uncontrolled. Default: `false`. */
|
|
@@ -46,6 +62,12 @@ interface TooltipProps {
|
|
|
46
62
|
onOpen?: (event: Event | SyntheticEvent) => void;
|
|
47
63
|
/** Fired when it asks to close. */
|
|
48
64
|
onClose?: (event: Event | SyntheticEvent) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the pointer can be moved onto the tooltip, which then stays open (WCAG 1.4.13). With
|
|
67
|
+
* `false` it takes no pointer events - a click goes to what is under it - and closes as the
|
|
68
|
+
* pointer leaves the child: for a text hint that holds nothing to use. Default: `true`.
|
|
69
|
+
*/
|
|
70
|
+
isInteractive?: boolean;
|
|
49
71
|
/** Opens on hover. Default: `true`. */
|
|
50
72
|
shouldOpenOnHover?: boolean;
|
|
51
73
|
/** Opens on keyboard focus. Default: `true`. */
|
|
@@ -70,5 +92,5 @@ interface TooltipProps {
|
|
|
70
92
|
* `shouldDescribeChild`). It opens and closes after their delays, stays open while the pointer is
|
|
71
93
|
* on the tooltip itself, closes on Escape, and never takes or traps the focus.
|
|
72
94
|
*/
|
|
73
|
-
declare function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrowProp, enterDelay: enterDelayProp, leaveDelay: leaveDelayProp, enterTouchDelay: enterTouchDelayProp, leaveTouchDelay: leaveTouchDelayProp, shouldDescribeChild: shouldDescribeChildProp, isOpen: isOpenProp, defaultOpen, onOpen, onClose, shouldOpenOnHover: shouldOpenOnHoverProp, shouldOpenOnFocus: shouldOpenOnFocusProp, shouldOpenOnTouch: shouldOpenOnTouchProp, slots, slotProps, layer: layerProp, borderRadius: borderRadiusProp, bg: bgProp, textColor: textColorProp, className, 'data-testid': dataTestid }: Readonly<TooltipProps>): import("react").JSX.Element;
|
|
95
|
+
declare function Tooltip({ children, anchorPosition, title, placement: placementProp, hasArrow: hasArrowProp, enterDelay: enterDelayProp, leaveDelay: leaveDelayProp, enterTouchDelay: enterTouchDelayProp, leaveTouchDelay: leaveTouchDelayProp, shouldDescribeChild: shouldDescribeChildProp, isDescriptionPersistent: isDescriptionPersistentProp, isOpen: isOpenProp, defaultOpen, onOpen, onClose, isInteractive: isInteractiveProp, shouldOpenOnHover: shouldOpenOnHoverProp, shouldOpenOnFocus: shouldOpenOnFocusProp, shouldOpenOnTouch: shouldOpenOnTouchProp, slots, slotProps, layer: layerProp, borderRadius: borderRadiusProp, bg: bgProp, textColor: textColorProp, className, 'data-testid': dataTestid }: Readonly<TooltipProps>): import("react").JSX.Element;
|
|
74
96
|
export { Tooltip, type TooltipPlacement, TooltipProps, TooltipSlotProps, TooltipSlots };
|
package/dist/Tooltip.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { t as themeDefault } from "./themeDefault-BeZJzqJj.mjs";
|
|
|
4
4
|
import { t as getSurfaceRadius } from "./getSurfaceRadius-B1QE_VLa.mjs";
|
|
5
5
|
import { t as useControlled } from "./useControlled-B4uQ9Bj6.mjs";
|
|
6
6
|
import { Portal } from "./Portal.mjs";
|
|
7
|
-
import { t as useAnchoredPlacement } from "./useAnchoredPlacement-
|
|
7
|
+
import { t as useAnchoredPlacement } from "./useAnchoredPlacement-txSaWzfk.mjs";
|
|
8
8
|
import { t as useMergedRefs } from "./useMergedRefs-CdfwtmUd.mjs";
|
|
9
9
|
import { n as resolveTooltipPlacement, t as getTooltipOrigins } from "./getTooltipOrigins-D0bLLXwY.mjs";
|
|
10
10
|
import { cloneElement, useCallback, useEffect, useId, useRef, useState } from "react";
|
|
@@ -23,7 +23,7 @@ const isKeyboardFocus = (event) => {
|
|
|
23
23
|
* delayed; moving from the child onto the tooltip does not close it, so its text can be read and
|
|
24
24
|
* selected (WCAG 1.4.13); Escape closes it at once.
|
|
25
25
|
*/
|
|
26
|
-
function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDelay, leaveDelay, enterTouchDelay, leaveTouchDelay, shouldOpenOnHover, shouldOpenOnFocus, shouldOpenOnTouch }) {
|
|
26
|
+
function useTooltip({ isOpen: isOpenProp, defaultOpen, isAtPoint = false, onOpen, onClose, enterDelay, leaveDelay, enterTouchDelay, leaveTouchDelay, shouldOpenOnHover, shouldOpenOnFocus, shouldOpenOnTouch }) {
|
|
27
27
|
const [isOpen, setIsOpen] = useControlled({
|
|
28
28
|
controlled: isOpenProp,
|
|
29
29
|
default: defaultOpen
|
|
@@ -32,6 +32,7 @@ function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDel
|
|
|
32
32
|
const latest = useRef({
|
|
33
33
|
isOpen,
|
|
34
34
|
isOpenProp,
|
|
35
|
+
isAtPoint,
|
|
35
36
|
onOpen,
|
|
36
37
|
onClose
|
|
37
38
|
});
|
|
@@ -39,6 +40,7 @@ function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDel
|
|
|
39
40
|
latest.current = {
|
|
40
41
|
isOpen,
|
|
41
42
|
isOpenProp,
|
|
43
|
+
isAtPoint,
|
|
42
44
|
onOpen,
|
|
43
45
|
onClose
|
|
44
46
|
};
|
|
@@ -49,6 +51,7 @@ function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDel
|
|
|
49
51
|
timer.current = window.setTimeout(() => {
|
|
50
52
|
const current = latest.current;
|
|
51
53
|
if (current.isOpen === next) return;
|
|
54
|
+
if (next && current.isAtPoint) return;
|
|
52
55
|
if (current.isOpenProp === void 0) setIsOpen(next);
|
|
53
56
|
(next ? current.onOpen : current.onClose)?.(event);
|
|
54
57
|
}, delay);
|
|
@@ -85,6 +88,9 @@ function useTooltip({ isOpen: isOpenProp, defaultOpen, onOpen, onClose, enterDel
|
|
|
85
88
|
},
|
|
86
89
|
onTouchCancel: (event) => {
|
|
87
90
|
if (shouldOpenOnTouch) ask(false, event, leaveTouchDelay);
|
|
91
|
+
},
|
|
92
|
+
onPointerDown: (event) => {
|
|
93
|
+
if (event.pointerType !== "touch") ask(false, event, 0);
|
|
88
94
|
}
|
|
89
95
|
},
|
|
90
96
|
surfaceHandlers: {
|
|
@@ -106,12 +112,14 @@ const TooltipSurface = styled("div", {
|
|
|
106
112
|
label: "Tooltip",
|
|
107
113
|
shouldForwardProp: createShouldForwardProp([
|
|
108
114
|
"layer",
|
|
115
|
+
"isInteractive",
|
|
109
116
|
"borderRadius",
|
|
110
117
|
"bg",
|
|
111
118
|
"textColor"
|
|
112
119
|
])
|
|
113
|
-
})(({ theme, layer, borderRadius, bg, textColor }) => ({
|
|
120
|
+
})(({ theme, layer, isInteractive, borderRadius, bg, textColor }) => ({
|
|
114
121
|
position: "fixed",
|
|
122
|
+
...!isInteractive && { pointerEvents: "none" },
|
|
115
123
|
top: 0,
|
|
116
124
|
left: 0,
|
|
117
125
|
visibility: "hidden",
|
|
@@ -128,6 +136,18 @@ const TooltipSurface = styled("div", {
|
|
|
128
136
|
lineHeight: (0, src_exports.get)(theme, "lineHeights.base"),
|
|
129
137
|
overflowWrap: "break-word"
|
|
130
138
|
}));
|
|
139
|
+
const TooltipDescription = styled("span", { label: "TooltipDescription" })({
|
|
140
|
+
position: "absolute",
|
|
141
|
+
width: 1,
|
|
142
|
+
height: 1,
|
|
143
|
+
margin: -1,
|
|
144
|
+
padding: 0,
|
|
145
|
+
border: 0,
|
|
146
|
+
overflow: "hidden",
|
|
147
|
+
clip: "rect(0 0 0 0)",
|
|
148
|
+
whiteSpace: "nowrap"
|
|
149
|
+
});
|
|
150
|
+
const TooltipTarget = styled("span", { label: "TooltipTarget" })({ display: "inline-grid" });
|
|
131
151
|
const TooltipArrow = styled("span", {
|
|
132
152
|
name: "Tooltip",
|
|
133
153
|
slot: "arrow",
|
|
@@ -184,19 +204,23 @@ const getArrowStyle = ({ side, offset }) => {
|
|
|
184
204
|
* `shouldDescribeChild`). It opens and closes after their delays, stays open while the pointer is
|
|
185
205
|
* on the tooltip itself, closes on Escape, and never takes or traps the focus.
|
|
186
206
|
*/
|
|
187
|
-
function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrowProp, enterDelay: enterDelayProp, leaveDelay: leaveDelayProp, enterTouchDelay: enterTouchDelayProp, leaveTouchDelay: leaveTouchDelayProp, shouldDescribeChild: shouldDescribeChildProp, isOpen: isOpenProp, defaultOpen = false, onOpen, onClose, shouldOpenOnHover: shouldOpenOnHoverProp, shouldOpenOnFocus: shouldOpenOnFocusProp, shouldOpenOnTouch: shouldOpenOnTouchProp, slots, slotProps, layer: layerProp, borderRadius: borderRadiusProp, bg: bgProp, textColor: textColorProp, className, "data-testid": dataTestid }) {
|
|
207
|
+
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, shouldOpenOnHover: shouldOpenOnHoverProp, shouldOpenOnFocus: shouldOpenOnFocusProp, shouldOpenOnTouch: shouldOpenOnTouchProp, slots, slotProps, layer: layerProp, borderRadius: borderRadiusProp, bg: bgProp, textColor: textColorProp, className, "data-testid": dataTestid }) {
|
|
188
208
|
const dp = useDefaultProps("Tooltip");
|
|
189
209
|
const placement = placementProp ?? dp.placement ?? "top";
|
|
190
210
|
const hasArrow = hasArrowProp ?? dp.hasArrow ?? false;
|
|
191
211
|
const shouldDescribeChild = shouldDescribeChildProp ?? dp.shouldDescribeChild ?? false;
|
|
212
|
+
const isDescriptionPersistent = isDescriptionPersistentProp ?? dp.isDescriptionPersistent ?? false;
|
|
213
|
+
const isInteractive = isInteractiveProp ?? dp.isInteractive ?? true;
|
|
192
214
|
const layer = layerProp ?? dp.layer ?? "tooltip";
|
|
193
215
|
const borderRadius = borderRadiusProp ?? dp.borderRadius;
|
|
194
216
|
const bg = bgProp ?? dp.bg;
|
|
195
217
|
const textColor = textColorProp ?? dp.textColor;
|
|
196
218
|
const id = useId();
|
|
219
|
+
const isAtPoint = anchorPosition !== void 0;
|
|
197
220
|
const { isOpen, childHandlers, surfaceHandlers } = useTooltip({
|
|
198
221
|
isOpen: isOpenProp,
|
|
199
222
|
defaultOpen,
|
|
223
|
+
isAtPoint,
|
|
200
224
|
onOpen,
|
|
201
225
|
onClose,
|
|
202
226
|
enterDelay: enterDelayProp ?? dp.enterDelay ?? 100,
|
|
@@ -207,11 +231,14 @@ function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrow
|
|
|
207
231
|
shouldOpenOnFocus: shouldOpenOnFocusProp ?? dp.shouldOpenOnFocus ?? true,
|
|
208
232
|
shouldOpenOnTouch: shouldOpenOnTouchProp ?? dp.shouldOpenOnTouch ?? true
|
|
209
233
|
});
|
|
210
|
-
const
|
|
234
|
+
const hasTitle = title !== void 0 && title !== null && title !== "";
|
|
235
|
+
const isShown = isOpen && hasTitle;
|
|
211
236
|
const anchorRef = useRef(null);
|
|
237
|
+
const noAnchorRef = useRef(null);
|
|
212
238
|
const surfaceRef = useRef(null);
|
|
213
|
-
const own = children
|
|
214
|
-
const
|
|
239
|
+
const own = children?.props ?? {};
|
|
240
|
+
const isChildDisabled = own.disabled === true;
|
|
241
|
+
const ref = useMergedRefs(isChildDisabled ? void 0 : anchorRef, own.ref);
|
|
215
242
|
const [arrow, setArrow] = useState(null);
|
|
216
243
|
const getOrigins = useCallback((context) => getTooltipOrigins(resolveTooltipPlacement(placement, context), context.isRtl), [placement]);
|
|
217
244
|
const onPlaced = useCallback((placed) => {
|
|
@@ -221,7 +248,8 @@ function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrow
|
|
|
221
248
|
}, [hasArrow]);
|
|
222
249
|
useAnchoredPlacement({
|
|
223
250
|
isOpen: isShown,
|
|
224
|
-
anchorRef,
|
|
251
|
+
anchorRef: anchorPosition ? noAnchorRef : anchorRef,
|
|
252
|
+
anchorPosition,
|
|
225
253
|
surfaceRef,
|
|
226
254
|
getOrigins,
|
|
227
255
|
margin: MARGIN,
|
|
@@ -234,33 +262,49 @@ function Tooltip({ children, title, placement: placementProp, hasArrow: hasArrow
|
|
|
234
262
|
}]));
|
|
235
263
|
const ownDescription = own["aria-describedby"];
|
|
236
264
|
const names = typeof title === "string" && own["aria-label"] === void 0 && own["aria-labelledby"] === void 0 ? { "aria-label": title } : {};
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
265
|
+
const descriptionId = `${id}-description`;
|
|
266
|
+
const hasPersistentDescription = children !== void 0 && shouldDescribeChild && isDescriptionPersistent && hasTitle;
|
|
267
|
+
const describedBy = (shown) => hasPersistentDescription ? [ownDescription, descriptionId].filter(Boolean).join(" ") : [ownDescription, shown ? id : void 0].filter(Boolean).join(" ") || void 0;
|
|
268
|
+
const ariaProps = shouldDescribeChild ? { "aria-describedby": describedBy(isShown) } : names;
|
|
269
|
+
const child = children ? cloneElement(children, {
|
|
270
|
+
...isChildDisabled || isAtPoint ? {} : handlers,
|
|
240
271
|
...ariaProps,
|
|
241
272
|
ref
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
273
|
+
}) : null;
|
|
274
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
275
|
+
isChildDisabled && !isAtPoint ? /* @__PURE__ */ jsx(TooltipTarget, {
|
|
276
|
+
ref: anchorRef,
|
|
277
|
+
...handlers,
|
|
278
|
+
children: child
|
|
279
|
+
}) : child,
|
|
280
|
+
hasPersistentDescription && /* @__PURE__ */ jsx(TooltipDescription, {
|
|
281
|
+
id: descriptionId,
|
|
282
|
+
children: title
|
|
283
|
+
}),
|
|
284
|
+
isShown && /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsxs(TooltipSurface, {
|
|
285
|
+
...slotProps?.root,
|
|
286
|
+
as: slots?.root,
|
|
287
|
+
ref: surfaceRef,
|
|
288
|
+
id,
|
|
289
|
+
role: "tooltip",
|
|
290
|
+
layer,
|
|
291
|
+
isInteractive,
|
|
292
|
+
borderRadius,
|
|
293
|
+
bg,
|
|
294
|
+
textColor,
|
|
295
|
+
className: [slotProps?.root?.className, className].filter(Boolean).join(" ") || void 0,
|
|
296
|
+
"data-testid": dataTestid ?? slotProps?.root?.["data-testid"],
|
|
297
|
+
...isAtPoint || !isInteractive ? {} : surfaceHandlers,
|
|
298
|
+
children: [title, hasArrow && arrow ? /* @__PURE__ */ jsx(TooltipArrow, {
|
|
299
|
+
...slotProps?.arrow,
|
|
300
|
+
as: slots?.arrow,
|
|
301
|
+
style: {
|
|
302
|
+
...slotProps?.arrow?.style,
|
|
303
|
+
...getArrowStyle(arrow)
|
|
304
|
+
},
|
|
305
|
+
"aria-hidden": "true"
|
|
306
|
+
}) : null]
|
|
307
|
+
}) })
|
|
308
|
+
] });
|
|
265
309
|
}
|
|
266
310
|
export { Tooltip };
|
package/dist/TransferList.d.cts
CHANGED
package/dist/TransferList.d.mts
CHANGED
package/dist/Typography.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { jt as TypographyVariant } from "./index-
|
|
2
|
-
import { a as TypographyProps, i as TypographyAlign, n as TextColorToken, r as Typography, t as BackgroundToken } from "./index-
|
|
1
|
+
import { jt as TypographyVariant } from "./index-DvVQLBZc.cjs";
|
|
2
|
+
import { a as TypographyProps, i as TypographyAlign, n as TextColorToken, r as Typography, t as BackgroundToken } from "./index-CyOSmefH.cjs";
|
|
3
3
|
export { BackgroundToken, TextColorToken, Typography, TypographyAlign, TypographyProps, type TypographyVariant };
|
package/dist/Typography.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { jt as TypographyVariant } from "./index-
|
|
2
|
-
import { a as TypographyProps, i as TypographyAlign, n as TextColorToken, r as Typography, t as BackgroundToken } from "./index-
|
|
1
|
+
import { jt as TypographyVariant } from "./index-BWiDilH8.mjs";
|
|
2
|
+
import { a as TypographyProps, i as TypographyAlign, n as TextColorToken, r as Typography, t as BackgroundToken } from "./index-DtVrZFJI.mjs";
|
|
3
3
|
export { BackgroundToken, TextColorToken, Typography, TypographyAlign, TypographyProps, type TypographyVariant };
|
package/dist/View.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _n as ViewBorderWidthToken, gn as ViewBorderRadiusToken, hn as ViewBorderColorToken, mn as ViewBackgroundToken, pn as View, vn as ViewColorToken, yn as ViewProps } from "./index-
|
|
1
|
+
import { _n as ViewBorderWidthToken, gn as ViewBorderRadiusToken, hn as ViewBorderColorToken, mn as ViewBackgroundToken, pn as View, vn as ViewColorToken, yn as ViewProps } from "./index-DvVQLBZc.cjs";
|
|
2
2
|
export { View, ViewBackgroundToken, ViewBorderColorToken, ViewBorderRadiusToken, ViewBorderWidthToken, ViewColorToken, ViewProps };
|
package/dist/View.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _n as ViewBorderWidthToken, gn as ViewBorderRadiusToken, hn as ViewBorderColorToken, mn as ViewBackgroundToken, pn as View, vn as ViewColorToken, yn as ViewProps } from "./index-
|
|
1
|
+
import { _n as ViewBorderWidthToken, gn as ViewBorderRadiusToken, hn as ViewBorderColorToken, mn as ViewBackgroundToken, pn as View, vn as ViewColorToken, yn as ViewProps } from "./index-BWiDilH8.mjs";
|
|
2
2
|
export { View, ViewBackgroundToken, ViewBorderColorToken, ViewBorderRadiusToken, ViewBorderWidthToken, ViewColorToken, ViewProps };
|
package/dist/Zoom.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TransitionProps } from "./useTransition-
|
|
1
|
+
import { n as TransitionProps } from "./useTransition-CF_Zy_tM.cjs";
|
|
2
2
|
type ZoomProps = TransitionProps;
|
|
3
3
|
/**
|
|
4
4
|
* @description Zooms one child in from nothing and out to nothing. The child holds a `ref` and
|
package/dist/Zoom.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TransitionProps } from "./useTransition-
|
|
1
|
+
import { n as TransitionProps } from "./useTransition-B-hzi7Sm.mjs";
|
|
2
2
|
type ZoomProps = TransitionProps;
|
|
3
3
|
/**
|
|
4
4
|
* @description Zooms one child in from nothing and out to nothing. The child holds a `ref` and
|
package/dist/catalog.cjs
CHANGED
|
@@ -618,6 +618,14 @@ const tooltipCatalog = defineCatalogEntry()({
|
|
|
618
618
|
values: [true, false],
|
|
619
619
|
default: false
|
|
620
620
|
},
|
|
621
|
+
isInteractive: {
|
|
622
|
+
values: [true, false],
|
|
623
|
+
default: true
|
|
624
|
+
},
|
|
625
|
+
isDescriptionPersistent: {
|
|
626
|
+
values: [true, false],
|
|
627
|
+
default: false
|
|
628
|
+
},
|
|
621
629
|
shouldOpenOnHover: {
|
|
622
630
|
values: [true, false],
|
|
623
631
|
default: true
|
package/dist/catalog.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nt as Theme } from "./index-
|
|
1
|
+
import { nt as Theme } from "./index-DvVQLBZc.cjs";
|
|
2
2
|
/** A value that survives `JSON.stringify` - all a catalog holds. */
|
|
3
3
|
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
4
4
|
[key: string]: JsonValue;
|
package/dist/catalog.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nt as Theme } from "./index-
|
|
1
|
+
import { nt as Theme } from "./index-BWiDilH8.mjs";
|
|
2
2
|
/** A value that survives `JSON.stringify` - all a catalog holds. */
|
|
3
3
|
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
4
4
|
[key: string]: JsonValue;
|