@tamagui/tooltip 1.7.6 → 1.7.8
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/dist/cjs/Tooltip.js +93 -94
- package/dist/cjs/Tooltip.js.map +3 -3
- package/dist/esm/Tooltip.js +98 -95
- package/dist/esm/Tooltip.js.map +3 -3
- package/dist/esm/Tooltip.mjs +98 -95
- package/dist/esm/Tooltip.mjs.map +3 -3
- package/dist/jsx/Tooltip.js +91 -88
- package/dist/jsx/Tooltip.js.map +3 -3
- package/dist/jsx/Tooltip.mjs +91 -88
- package/dist/jsx/Tooltip.mjs.map +3 -3
- package/package.json +13 -13
- package/src/Tooltip.tsx +116 -108
- package/types/Tooltip.d.ts +25 -10
- package/types/Tooltip.d.ts.map +1 -1
package/dist/jsx/Tooltip.mjs
CHANGED
|
@@ -21,23 +21,29 @@ import {
|
|
|
21
21
|
__PopoverProviderInternal,
|
|
22
22
|
usePopoverScope
|
|
23
23
|
} from "@tamagui/popover";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
Popper,
|
|
26
|
+
PopperContentFrame,
|
|
27
|
+
usePopperContext
|
|
28
|
+
} from "@tamagui/popper";
|
|
25
29
|
import * as React from "react";
|
|
26
|
-
const TooltipContent =
|
|
27
|
-
(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
const TooltipContent = PopperContentFrame.extractable(
|
|
31
|
+
React.forwardRef(
|
|
32
|
+
({ __scopePopover, ...props }, ref) => {
|
|
33
|
+
const popperScope = usePopoverScope(__scopePopover);
|
|
34
|
+
const popper = usePopperContext("PopperContent", popperScope["__scopePopper"]);
|
|
35
|
+
const padding = props.size || popper.size || stepTokenUpOrDown("size", "$true", -2);
|
|
36
|
+
return <PopoverContent
|
|
37
|
+
componentName="Tooltip"
|
|
38
|
+
disableRemoveScroll
|
|
39
|
+
trapFocus={false}
|
|
40
|
+
padding={padding}
|
|
41
|
+
pointerEvents="none"
|
|
42
|
+
ref={ref}
|
|
43
|
+
{...props}
|
|
44
|
+
/>;
|
|
45
|
+
}
|
|
46
|
+
)
|
|
41
47
|
);
|
|
42
48
|
const TooltipArrow = React.forwardRef((props, ref) => {
|
|
43
49
|
return <PopoverArrow componentName="Tooltip" ref={ref} {...props} />;
|
|
@@ -45,83 +51,80 @@ const TooltipArrow = React.forwardRef((props, ref) => {
|
|
|
45
51
|
const TooltipGroup = ({ children, delay }) => {
|
|
46
52
|
return <FloatingDelayGroup delay={React.useMemo(() => delay, [JSON.stringify(delay)])}>{children}</FloatingDelayGroup>;
|
|
47
53
|
};
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
const TooltipComponent = React.forwardRef(function Tooltip(props, ref) {
|
|
55
|
+
const {
|
|
56
|
+
__scopePopover,
|
|
57
|
+
children,
|
|
58
|
+
delay: delayProp,
|
|
59
|
+
restMs = typeof delayProp === "undefined" ? 500 : typeof delayProp === "number" ? delayProp : 0,
|
|
60
|
+
onOpenChange: onOpenChangeProp,
|
|
61
|
+
focus,
|
|
62
|
+
...restProps
|
|
63
|
+
} = props;
|
|
64
|
+
const popperScope = usePopoverScope(__scopePopover);
|
|
65
|
+
const triggerRef = React.useRef(null);
|
|
66
|
+
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
67
|
+
const { delay: delayGroup, setCurrentId } = useDelayGroupContext();
|
|
68
|
+
const delay = delayProp ?? delayGroup;
|
|
69
|
+
const [open, setOpen] = React.useState(false);
|
|
70
|
+
const id = props.groupId;
|
|
71
|
+
const onOpenChange = useEvent((open2) => {
|
|
72
|
+
setOpen(open2);
|
|
73
|
+
if (open2) {
|
|
74
|
+
setCurrentId(id);
|
|
75
|
+
}
|
|
76
|
+
onOpenChangeProp?.(open2);
|
|
77
|
+
});
|
|
78
|
+
const useFloatingFn = (props2) => {
|
|
79
|
+
const floating = useFloating({
|
|
80
|
+
...props2,
|
|
81
|
+
open,
|
|
82
|
+
onOpenChange
|
|
72
83
|
});
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
useDelayGroup(floating.context, { id })
|
|
85
|
-
]);
|
|
86
|
-
return {
|
|
87
|
-
...floating,
|
|
88
|
-
getReferenceProps,
|
|
89
|
-
getFloatingProps
|
|
90
|
-
};
|
|
84
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
85
|
+
useHover(floating.context, { delay, restMs }),
|
|
86
|
+
useFocus(floating.context, focus),
|
|
87
|
+
useRole(floating.context, { role: "tooltip" }),
|
|
88
|
+
useDismiss(floating.context),
|
|
89
|
+
useDelayGroup(floating.context, { id })
|
|
90
|
+
]);
|
|
91
|
+
return {
|
|
92
|
+
...floating,
|
|
93
|
+
getReferenceProps,
|
|
94
|
+
getFloatingProps
|
|
91
95
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
);
|
|
120
|
-
Tooltip.displayName = "Tooltip";
|
|
96
|
+
};
|
|
97
|
+
const useFloatingContext = React.useCallback(useFloatingFn, [id, delay, open]);
|
|
98
|
+
const onCustomAnchorAdd = React.useCallback(() => setHasCustomAnchor(true), []);
|
|
99
|
+
const onCustomAnchorRemove = React.useCallback(() => setHasCustomAnchor(false), []);
|
|
100
|
+
const contentId = useId();
|
|
101
|
+
const twoSmallerKey = stepTokenUpOrDown("size", "$true", -2).key;
|
|
102
|
+
const size = `$${twoSmallerKey}`;
|
|
103
|
+
return <FloatingOverrideContext.Provider value={useFloatingContext}><Popper size={size} {...popperScope} {...restProps}><__PopoverProviderInternal
|
|
104
|
+
scope={__scopePopover}
|
|
105
|
+
popperScope={popperScope.__scopePopper}
|
|
106
|
+
contentId={contentId}
|
|
107
|
+
triggerRef={triggerRef}
|
|
108
|
+
sheetBreakpoint={false}
|
|
109
|
+
scopeKey=""
|
|
110
|
+
open={open}
|
|
111
|
+
onOpenChange={setOpen}
|
|
112
|
+
onOpenToggle={voidFn}
|
|
113
|
+
hasCustomAnchor={hasCustomAnchor}
|
|
114
|
+
onCustomAnchorAdd={onCustomAnchorAdd}
|
|
115
|
+
onCustomAnchorRemove={onCustomAnchorRemove}
|
|
116
|
+
>{children}</__PopoverProviderInternal></Popper></FloatingOverrideContext.Provider>;
|
|
117
|
+
});
|
|
118
|
+
const Tooltip2 = withStaticProperties(TooltipComponent, {
|
|
119
|
+
Anchor: PopoverAnchor,
|
|
120
|
+
Arrow: TooltipArrow,
|
|
121
|
+
Content: TooltipContent,
|
|
122
|
+
Trigger: PopoverTrigger
|
|
123
|
+
});
|
|
121
124
|
const voidFn = () => {
|
|
122
125
|
};
|
|
123
126
|
export {
|
|
124
|
-
Tooltip,
|
|
127
|
+
Tooltip2 as Tooltip,
|
|
125
128
|
TooltipGroup
|
|
126
129
|
};
|
|
127
130
|
//# sourceMappingURL=Tooltip.mjs.map
|
package/dist/jsx/Tooltip.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Tooltip.tsx"],
|
|
4
|
-
"sourcesContent": ["import '@tamagui/polyfill-dev'\n\nimport {\n FloatingDelayGroup,\n useDelayGroup,\n useDelayGroupContext,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useRole,\n} from '@floating-ui/react'\nimport { SizeTokens, useEvent, useId, withStaticProperties } from '@tamagui/core'\nimport { ScopedProps } from '@tamagui/create-context'\nimport { FloatingOverrideContext, UseFloatingFn } from '@tamagui/floating'\nimport { stepTokenUpOrDown } from '@tamagui/get-size'\nimport {\n PopoverAnchor,\n PopoverArrow,\n PopoverArrowProps,\n PopoverContent,\n PopoverContentProps,\n PopoverTrigger,\n __PopoverProviderInternal,\n usePopoverScope,\n} from '@tamagui/popover'\nimport {
|
|
5
|
-
"mappings": "AAAA,OAAO;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAqB,UAAU,OAAO,4BAA4B;AAElE,SAAS,+BAA8C;AACvD,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,
|
|
6
|
-
"names": ["open", "props"]
|
|
4
|
+
"sourcesContent": ["import '@tamagui/polyfill-dev'\n\nimport {\n FloatingDelayGroup,\n useDelayGroup,\n useDelayGroupContext,\n useDismiss,\n useFloating,\n useFocus,\n useHover,\n useInteractions,\n useRole,\n} from '@floating-ui/react'\nimport { SizeTokens, useEvent, useId, withStaticProperties } from '@tamagui/core'\nimport { ScopedProps } from '@tamagui/create-context'\nimport { FloatingOverrideContext, UseFloatingFn } from '@tamagui/floating'\nimport { stepTokenUpOrDown } from '@tamagui/get-size'\nimport {\n PopoverAnchor,\n PopoverArrow,\n PopoverArrowProps,\n PopoverContent,\n PopoverContentProps,\n PopoverTrigger,\n __PopoverProviderInternal,\n usePopoverScope,\n} from '@tamagui/popover'\nimport {\n Popper,\n PopperContentFrame,\n PopperProps,\n usePopperContext,\n} from '@tamagui/popper'\nimport * as React from 'react'\n\nconst TooltipContent = PopperContentFrame.extractable(\n React.forwardRef(\n (\n { __scopePopover, ...props }: ScopedProps<PopoverContentProps, 'Popover'>,\n ref: any\n ) => {\n const popperScope = usePopoverScope(__scopePopover)\n const popper = usePopperContext('PopperContent', popperScope['__scopePopper'])\n const padding = props.size || popper.size || stepTokenUpOrDown('size', '$true', -2)\n return (\n <PopoverContent\n componentName=\"Tooltip\"\n disableRemoveScroll\n trapFocus={false}\n padding={padding}\n pointerEvents=\"none\"\n ref={ref}\n {...props}\n />\n )\n }\n )\n)\n\nconst TooltipArrow = React.forwardRef((props: PopoverArrowProps, ref: any) => {\n return <PopoverArrow componentName=\"Tooltip\" ref={ref} {...props} />\n})\n\nexport type TooltipProps = PopperProps & {\n children?: React.ReactNode\n onOpenChange?: (open: boolean) => void\n focus?: {\n enabled?: boolean\n keyboardOnly?: boolean\n }\n groupId?: string\n restMs?: number\n delay?:\n | number\n | {\n open?: number\n close?: number\n }\n}\n\ntype Delay =\n | number\n | Partial<{\n open: number\n close: number\n }>\n\nexport const TooltipGroup = ({ children, delay }: { children?: any; delay: Delay }) => {\n return (\n <FloatingDelayGroup delay={React.useMemo(() => delay, [JSON.stringify(delay)])}>\n {children}\n </FloatingDelayGroup>\n )\n}\n\nconst TooltipComponent = React.forwardRef(function Tooltip(\n props: ScopedProps<TooltipProps, 'Popover'>,\n // theres no real ref here but React complaining need to see why see SandboxCustomStyledAnimatedTooltip.ts\n ref\n) {\n const {\n __scopePopover,\n children,\n delay: delayProp,\n restMs = typeof delayProp === 'undefined'\n ? 500\n : typeof delayProp === 'number'\n ? delayProp\n : 0,\n onOpenChange: onOpenChangeProp,\n focus,\n ...restProps\n } = props\n const popperScope = usePopoverScope(__scopePopover)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false)\n const { delay: delayGroup, setCurrentId } = useDelayGroupContext()\n const delay = delayProp ?? delayGroup\n const [open, setOpen] = React.useState(false)\n const id = props.groupId\n\n const onOpenChange = useEvent((open) => {\n setOpen(open)\n if (open) {\n setCurrentId(id)\n }\n onOpenChangeProp?.(open)\n })\n\n const useFloatingFn: UseFloatingFn = (props) => {\n // @ts-ignore\n const floating = useFloating({\n ...props,\n open,\n onOpenChange,\n })\n const { getReferenceProps, getFloatingProps } = useInteractions([\n useHover(floating.context, { delay, restMs }),\n useFocus(floating.context, focus),\n useRole(floating.context, { role: 'tooltip' }),\n useDismiss(floating.context),\n useDelayGroup(floating.context, { id }),\n ])\n return {\n ...floating,\n getReferenceProps,\n getFloatingProps,\n } as any\n }\n\n const useFloatingContext = React.useCallback(useFloatingFn, [id, delay, open])\n const onCustomAnchorAdd = React.useCallback(() => setHasCustomAnchor(true), [])\n const onCustomAnchorRemove = React.useCallback(() => setHasCustomAnchor(false), [])\n const contentId = useId()\n const twoSmallerKey = stepTokenUpOrDown('size', '$true', -2).key\n const size = `$${twoSmallerKey}`\n\n return (\n <FloatingOverrideContext.Provider value={useFloatingContext}>\n {/* default tooltip to a smaller size */}\n <Popper size={size as SizeTokens} {...popperScope} {...restProps}>\n <__PopoverProviderInternal\n scope={__scopePopover}\n popperScope={popperScope.__scopePopper}\n contentId={contentId}\n triggerRef={triggerRef}\n sheetBreakpoint={false}\n scopeKey=\"\"\n open={open}\n onOpenChange={setOpen}\n onOpenToggle={voidFn}\n hasCustomAnchor={hasCustomAnchor}\n onCustomAnchorAdd={onCustomAnchorAdd}\n onCustomAnchorRemove={onCustomAnchorRemove}\n >\n {children}\n </__PopoverProviderInternal>\n </Popper>\n </FloatingOverrideContext.Provider>\n )\n})\n\nexport const Tooltip = withStaticProperties(TooltipComponent, {\n Anchor: PopoverAnchor,\n Arrow: TooltipArrow,\n Content: TooltipContent,\n Trigger: PopoverTrigger,\n})\n\nconst voidFn = () => {}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["open", "props", "Tooltip"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/tooltip",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -32,24 +32,24 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@floating-ui/react": "^0.19.1",
|
|
35
|
-
"@tamagui/compose-refs": "1.7.
|
|
36
|
-
"@tamagui/core": "1.7.
|
|
37
|
-
"@tamagui/create-context": "1.7.
|
|
38
|
-
"@tamagui/floating": "1.7.
|
|
39
|
-
"@tamagui/get-size": "1.7.
|
|
40
|
-
"@tamagui/polyfill-dev": "1.7.
|
|
41
|
-
"@tamagui/popover": "1.7.
|
|
42
|
-
"@tamagui/popper": "1.7.
|
|
43
|
-
"@tamagui/stacks": "1.7.
|
|
44
|
-
"@tamagui/text": "1.7.
|
|
45
|
-
"@tamagui/use-controllable-state": "1.7.
|
|
35
|
+
"@tamagui/compose-refs": "1.7.8",
|
|
36
|
+
"@tamagui/core": "1.7.8",
|
|
37
|
+
"@tamagui/create-context": "1.7.8",
|
|
38
|
+
"@tamagui/floating": "1.7.8",
|
|
39
|
+
"@tamagui/get-size": "1.7.8",
|
|
40
|
+
"@tamagui/polyfill-dev": "1.7.8",
|
|
41
|
+
"@tamagui/popover": "1.7.8",
|
|
42
|
+
"@tamagui/popper": "1.7.8",
|
|
43
|
+
"@tamagui/stacks": "1.7.8",
|
|
44
|
+
"@tamagui/text": "1.7.8",
|
|
45
|
+
"@tamagui/use-controllable-state": "1.7.8"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "*",
|
|
49
49
|
"react-native": "*"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@tamagui/build": "1.7.
|
|
52
|
+
"@tamagui/build": "1.7.8",
|
|
53
53
|
"react": "^18.2.0",
|
|
54
54
|
"react-native": "*"
|
|
55
55
|
},
|
package/src/Tooltip.tsx
CHANGED
|
@@ -25,29 +25,36 @@ import {
|
|
|
25
25
|
__PopoverProviderInternal,
|
|
26
26
|
usePopoverScope,
|
|
27
27
|
} from '@tamagui/popover'
|
|
28
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
Popper,
|
|
30
|
+
PopperContentFrame,
|
|
31
|
+
PopperProps,
|
|
32
|
+
usePopperContext,
|
|
33
|
+
} from '@tamagui/popper'
|
|
29
34
|
import * as React from 'react'
|
|
30
35
|
|
|
31
|
-
const TooltipContent =
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
36
|
+
const TooltipContent = PopperContentFrame.extractable(
|
|
37
|
+
React.forwardRef(
|
|
38
|
+
(
|
|
39
|
+
{ __scopePopover, ...props }: ScopedProps<PopoverContentProps, 'Popover'>,
|
|
40
|
+
ref: any
|
|
41
|
+
) => {
|
|
42
|
+
const popperScope = usePopoverScope(__scopePopover)
|
|
43
|
+
const popper = usePopperContext('PopperContent', popperScope['__scopePopper'])
|
|
44
|
+
const padding = props.size || popper.size || stepTokenUpOrDown('size', '$true', -2)
|
|
45
|
+
return (
|
|
46
|
+
<PopoverContent
|
|
47
|
+
componentName="Tooltip"
|
|
48
|
+
disableRemoveScroll
|
|
49
|
+
trapFocus={false}
|
|
50
|
+
padding={padding}
|
|
51
|
+
pointerEvents="none"
|
|
52
|
+
ref={ref}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
)
|
|
51
58
|
)
|
|
52
59
|
|
|
53
60
|
const TooltipArrow = React.forwardRef((props: PopoverArrowProps, ref: any) => {
|
|
@@ -86,97 +93,98 @@ export const TooltipGroup = ({ children, delay }: { children?: any; delay: Delay
|
|
|
86
93
|
)
|
|
87
94
|
}
|
|
88
95
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
96
|
+
const TooltipComponent = React.forwardRef(function Tooltip(
|
|
97
|
+
props: ScopedProps<TooltipProps, 'Popover'>,
|
|
98
|
+
// theres no real ref here but React complaining need to see why see SandboxCustomStyledAnimatedTooltip.ts
|
|
99
|
+
ref
|
|
100
|
+
) {
|
|
101
|
+
const {
|
|
102
|
+
__scopePopover,
|
|
103
|
+
children,
|
|
104
|
+
delay: delayProp,
|
|
105
|
+
restMs = typeof delayProp === 'undefined'
|
|
106
|
+
? 500
|
|
107
|
+
: typeof delayProp === 'number'
|
|
108
|
+
? delayProp
|
|
109
|
+
: 0,
|
|
110
|
+
onOpenChange: onOpenChangeProp,
|
|
111
|
+
focus,
|
|
112
|
+
...restProps
|
|
113
|
+
} = props
|
|
114
|
+
const popperScope = usePopoverScope(__scopePopover)
|
|
115
|
+
const triggerRef = React.useRef<HTMLButtonElement>(null)
|
|
116
|
+
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false)
|
|
117
|
+
const { delay: delayGroup, setCurrentId } = useDelayGroupContext()
|
|
118
|
+
const delay = delayProp ?? delayGroup
|
|
119
|
+
const [open, setOpen] = React.useState(false)
|
|
120
|
+
const id = props.groupId
|
|
111
121
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
onOpenChangeProp?.(open)
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
const useFloatingFn: UseFloatingFn = (props) => {
|
|
121
|
-
// @ts-ignore
|
|
122
|
-
const floating = useFloating({
|
|
123
|
-
...props,
|
|
124
|
-
open,
|
|
125
|
-
onOpenChange,
|
|
126
|
-
})
|
|
127
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
128
|
-
useHover(floating.context, { delay, restMs }),
|
|
129
|
-
useFocus(floating.context, focus),
|
|
130
|
-
useRole(floating.context, { role: 'tooltip' }),
|
|
131
|
-
useDismiss(floating.context),
|
|
132
|
-
useDelayGroup(floating.context, { id }),
|
|
133
|
-
])
|
|
134
|
-
return {
|
|
135
|
-
...floating,
|
|
136
|
-
getReferenceProps,
|
|
137
|
-
getFloatingProps,
|
|
138
|
-
} as any
|
|
122
|
+
const onOpenChange = useEvent((open) => {
|
|
123
|
+
setOpen(open)
|
|
124
|
+
if (open) {
|
|
125
|
+
setCurrentId(id)
|
|
139
126
|
}
|
|
127
|
+
onOpenChangeProp?.(open)
|
|
128
|
+
})
|
|
140
129
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
onOpenChange={setOpen}
|
|
161
|
-
onOpenToggle={voidFn}
|
|
162
|
-
hasCustomAnchor={hasCustomAnchor}
|
|
163
|
-
onCustomAnchorAdd={onCustomAnchorAdd}
|
|
164
|
-
onCustomAnchorRemove={onCustomAnchorRemove}
|
|
165
|
-
>
|
|
166
|
-
{children}
|
|
167
|
-
</__PopoverProviderInternal>
|
|
168
|
-
</Popper>
|
|
169
|
-
</FloatingOverrideContext.Provider>
|
|
170
|
-
)
|
|
171
|
-
}) as React.FC<TooltipProps>,
|
|
172
|
-
{
|
|
173
|
-
Anchor: PopoverAnchor,
|
|
174
|
-
Arrow: TooltipArrow,
|
|
175
|
-
Content: TooltipContent,
|
|
176
|
-
Trigger: PopoverTrigger,
|
|
130
|
+
const useFloatingFn: UseFloatingFn = (props) => {
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
const floating = useFloating({
|
|
133
|
+
...props,
|
|
134
|
+
open,
|
|
135
|
+
onOpenChange,
|
|
136
|
+
})
|
|
137
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
138
|
+
useHover(floating.context, { delay, restMs }),
|
|
139
|
+
useFocus(floating.context, focus),
|
|
140
|
+
useRole(floating.context, { role: 'tooltip' }),
|
|
141
|
+
useDismiss(floating.context),
|
|
142
|
+
useDelayGroup(floating.context, { id }),
|
|
143
|
+
])
|
|
144
|
+
return {
|
|
145
|
+
...floating,
|
|
146
|
+
getReferenceProps,
|
|
147
|
+
getFloatingProps,
|
|
148
|
+
} as any
|
|
177
149
|
}
|
|
178
|
-
)
|
|
179
150
|
|
|
180
|
-
|
|
151
|
+
const useFloatingContext = React.useCallback(useFloatingFn, [id, delay, open])
|
|
152
|
+
const onCustomAnchorAdd = React.useCallback(() => setHasCustomAnchor(true), [])
|
|
153
|
+
const onCustomAnchorRemove = React.useCallback(() => setHasCustomAnchor(false), [])
|
|
154
|
+
const contentId = useId()
|
|
155
|
+
const twoSmallerKey = stepTokenUpOrDown('size', '$true', -2).key
|
|
156
|
+
const size = `$${twoSmallerKey}`
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<FloatingOverrideContext.Provider value={useFloatingContext}>
|
|
160
|
+
{/* default tooltip to a smaller size */}
|
|
161
|
+
<Popper size={size as SizeTokens} {...popperScope} {...restProps}>
|
|
162
|
+
<__PopoverProviderInternal
|
|
163
|
+
scope={__scopePopover}
|
|
164
|
+
popperScope={popperScope.__scopePopper}
|
|
165
|
+
contentId={contentId}
|
|
166
|
+
triggerRef={triggerRef}
|
|
167
|
+
sheetBreakpoint={false}
|
|
168
|
+
scopeKey=""
|
|
169
|
+
open={open}
|
|
170
|
+
onOpenChange={setOpen}
|
|
171
|
+
onOpenToggle={voidFn}
|
|
172
|
+
hasCustomAnchor={hasCustomAnchor}
|
|
173
|
+
onCustomAnchorAdd={onCustomAnchorAdd}
|
|
174
|
+
onCustomAnchorRemove={onCustomAnchorRemove}
|
|
175
|
+
>
|
|
176
|
+
{children}
|
|
177
|
+
</__PopoverProviderInternal>
|
|
178
|
+
</Popper>
|
|
179
|
+
</FloatingOverrideContext.Provider>
|
|
180
|
+
)
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
export const Tooltip = withStaticProperties(TooltipComponent, {
|
|
184
|
+
Anchor: PopoverAnchor,
|
|
185
|
+
Arrow: TooltipArrow,
|
|
186
|
+
Content: TooltipContent,
|
|
187
|
+
Trigger: PopoverTrigger,
|
|
188
|
+
})
|
|
181
189
|
|
|
182
190
|
const voidFn = () => {}
|
package/types/Tooltip.d.ts
CHANGED
|
@@ -24,24 +24,39 @@ export declare const TooltipGroup: ({ children, delay }: {
|
|
|
24
24
|
children?: any;
|
|
25
25
|
delay: Delay;
|
|
26
26
|
}) => JSX.Element;
|
|
27
|
-
export declare const Tooltip: React.
|
|
28
|
-
|
|
27
|
+
export declare const Tooltip: React.ForwardRefExoticComponent<PopperProps & {
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
onOpenChange?: ((open: boolean) => void) | undefined;
|
|
30
|
+
focus?: {
|
|
31
|
+
enabled?: boolean | undefined;
|
|
32
|
+
keyboardOnly?: boolean | undefined;
|
|
33
|
+
} | undefined;
|
|
34
|
+
groupId?: string | undefined;
|
|
35
|
+
restMs?: number | undefined;
|
|
36
|
+
delay?: number | {
|
|
37
|
+
open?: number | undefined;
|
|
38
|
+
close?: number | undefined;
|
|
39
|
+
} | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
__scopePopover?: import("@tamagui/create-context").Scope<any>;
|
|
42
|
+
} & React.RefAttributes<unknown>> & {
|
|
43
|
+
Anchor: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
29
44
|
readonly fullscreen?: boolean | undefined;
|
|
30
45
|
readonly elevation?: SizeTokens | undefined;
|
|
31
|
-
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "
|
|
46
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
32
47
|
readonly fullscreen?: boolean | undefined;
|
|
33
48
|
readonly elevation?: SizeTokens | undefined;
|
|
34
|
-
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "
|
|
49
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
35
50
|
readonly fullscreen?: boolean | undefined;
|
|
36
51
|
readonly elevation?: SizeTokens | undefined;
|
|
37
52
|
}>> & React.RefAttributes<HTMLElement | import("react-native").View>>;
|
|
38
|
-
Arrow: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "
|
|
53
|
+
Arrow: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
39
54
|
readonly fullscreen?: boolean | undefined;
|
|
40
55
|
readonly elevation?: SizeTokens | undefined;
|
|
41
|
-
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "
|
|
56
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
42
57
|
readonly fullscreen?: boolean | undefined;
|
|
43
58
|
readonly elevation?: SizeTokens | undefined;
|
|
44
|
-
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "
|
|
59
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
45
60
|
readonly fullscreen?: boolean | undefined;
|
|
46
61
|
readonly elevation?: SizeTokens | undefined;
|
|
47
62
|
}>> & {
|
|
@@ -51,13 +66,13 @@ export declare const Tooltip: React.FC<TooltipProps> & {
|
|
|
51
66
|
Content: React.ForwardRefExoticComponent<import("@tamagui/popover").PopoverContentTypeProps & {
|
|
52
67
|
__scopePopover?: import("@tamagui/create-context").Scope<any>;
|
|
53
68
|
} & React.RefAttributes<unknown>>;
|
|
54
|
-
Trigger: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "
|
|
69
|
+
Trigger: React.ForwardRefExoticComponent<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
55
70
|
readonly fullscreen?: boolean | undefined;
|
|
56
71
|
readonly elevation?: SizeTokens | undefined;
|
|
57
|
-
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "
|
|
72
|
+
} & import("@tamagui/core").MediaProps<Partial<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
58
73
|
readonly fullscreen?: boolean | undefined;
|
|
59
74
|
readonly elevation?: SizeTokens | undefined;
|
|
60
|
-
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "
|
|
75
|
+
}>> & import("@tamagui/core").PseudoProps<Partial<Omit<import("react-native").ViewProps, "children" | "display" | "onLayout" | keyof import("react-native").GestureResponderHandlers> & import("@tamagui/core").ExtendBaseStackProps & import("@tamagui/core").TamaguiComponentPropsBase & import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase> & import("@tamagui/core").WithShorthands<import("@tamagui/core").WithThemeValues<import("@tamagui/core").StackStylePropsBase>> & import("@tamagui/core/types/reactNativeTypes").RNViewProps & Omit<{}, "elevation" | "fullscreen"> & {
|
|
61
76
|
readonly fullscreen?: boolean | undefined;
|
|
62
77
|
readonly elevation?: SizeTokens | undefined;
|
|
63
78
|
}>> & React.RefAttributes<HTMLElement | import("react-native").View>>;
|