@hanzogui/tooltip 2.0.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/dist/cjs/Tooltip.cjs +224 -0
- package/dist/cjs/Tooltip.native.js +48 -0
- package/dist/cjs/Tooltip.native.js.map +1 -0
- package/dist/cjs/TooltipSimple.cjs +107 -0
- package/dist/cjs/TooltipSimple.native.js +32 -0
- package/dist/cjs/TooltipSimple.native.js.map +1 -0
- package/dist/cjs/index.cjs +19 -0
- package/dist/cjs/index.native.js +22 -0
- package/dist/cjs/index.native.js.map +1 -0
- package/dist/esm/Tooltip.mjs +187 -0
- package/dist/esm/Tooltip.mjs.map +1 -0
- package/dist/esm/Tooltip.native.js +20 -0
- package/dist/esm/Tooltip.native.js.map +1 -0
- package/dist/esm/TooltipSimple.mjs +73 -0
- package/dist/esm/TooltipSimple.mjs.map +1 -0
- package/dist/esm/TooltipSimple.native.js +6 -0
- package/dist/esm/TooltipSimple.native.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +3 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/jsx/Tooltip.mjs +187 -0
- package/dist/jsx/Tooltip.mjs.map +1 -0
- package/dist/jsx/Tooltip.native.js +48 -0
- package/dist/jsx/Tooltip.native.js.map +1 -0
- package/dist/jsx/TooltipSimple.mjs +73 -0
- package/dist/jsx/TooltipSimple.mjs.map +1 -0
- package/dist/jsx/TooltipSimple.native.js +32 -0
- package/dist/jsx/TooltipSimple.native.js.map +1 -0
- package/dist/jsx/index.js +3 -0
- package/dist/jsx/index.js.map +1 -0
- package/dist/jsx/index.mjs +3 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/index.native.js +22 -0
- package/dist/jsx/index.native.js.map +1 -0
- package/package.json +62 -0
- package/src/Tooltip.native.tsx +26 -0
- package/src/Tooltip.tsx +291 -0
- package/src/TooltipSimple.native.tsx +5 -0
- package/src/TooltipSimple.tsx +85 -0
- package/src/index.tsx +2 -0
- package/types/Tooltip.d.ts +92 -0
- package/types/Tooltip.native.d.ts +10 -0
- package/types/TooltipSimple.d.ts +11 -0
- package/types/TooltipSimple.native.d.ts +2 -0
- package/types/index.d.ts +3 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { withStaticProperties } from '@hanzogui/helpers'
|
|
2
|
+
|
|
3
|
+
// no output on native for now
|
|
4
|
+
// could have an option to long-press or similar to show in a context menu/drawer
|
|
5
|
+
|
|
6
|
+
const RenderChildren = (props: any) => {
|
|
7
|
+
return props.children
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const RenderNull = (props: any) => {
|
|
11
|
+
return null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const TooltipGroup = () => null
|
|
15
|
+
|
|
16
|
+
export const closeOpenTooltips = () => {
|
|
17
|
+
/* noop */
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Tooltip = withStaticProperties(RenderChildren, {
|
|
21
|
+
Anchor: RenderChildren,
|
|
22
|
+
Arrow: RenderNull,
|
|
23
|
+
Close: RenderNull,
|
|
24
|
+
Content: RenderNull,
|
|
25
|
+
Trigger: RenderChildren,
|
|
26
|
+
})
|
package/src/Tooltip.tsx
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import '@hanzogui/polyfill-dev'
|
|
2
|
+
|
|
3
|
+
import { FloatingDelayGroup, useDelayGroupContext, type Delay } from '@hanzogui/floating'
|
|
4
|
+
import type { SizeTokens, GuiElement } from '@hanzogui/core'
|
|
5
|
+
import { useEvent } from '@hanzogui/core'
|
|
6
|
+
import { FloatingOverrideContext } from '@hanzogui/floating'
|
|
7
|
+
import { getSize } from '@hanzogui/get-token'
|
|
8
|
+
import { withStaticProperties } from '@hanzogui/helpers'
|
|
9
|
+
import type {
|
|
10
|
+
PopoverAnchorProps,
|
|
11
|
+
PopoverContentProps,
|
|
12
|
+
PopoverTriggerProps,
|
|
13
|
+
} from '@hanzogui/popover'
|
|
14
|
+
import {
|
|
15
|
+
PopoverAnchor,
|
|
16
|
+
PopoverArrow,
|
|
17
|
+
PopoverContent,
|
|
18
|
+
PopoverContextProvider,
|
|
19
|
+
PopoverTrigger,
|
|
20
|
+
useFloatingContext,
|
|
21
|
+
} from '@hanzogui/popover'
|
|
22
|
+
import type { PopperArrowProps, PopperProps } from '@hanzogui/popper'
|
|
23
|
+
import { Popper, PopperContentFrame } from '@hanzogui/popper'
|
|
24
|
+
import { useControllableState } from '@hanzogui/use-controllable-state'
|
|
25
|
+
import * as React from 'react'
|
|
26
|
+
|
|
27
|
+
const TOOLTIP_SCOPE = ''
|
|
28
|
+
|
|
29
|
+
export type TooltipScopes = string
|
|
30
|
+
|
|
31
|
+
type ScopedProps<P> = Omit<P, 'scope'> & { scope?: TooltipScopes }
|
|
32
|
+
|
|
33
|
+
export type TooltipContentProps = ScopedProps<PopoverContentProps>
|
|
34
|
+
|
|
35
|
+
// warning: setting to stylebale causes issues with themeInverse across portal root
|
|
36
|
+
|
|
37
|
+
// performance: avoid 2 components we never use
|
|
38
|
+
const ALWAYS_DISABLE_TOOLTIP = {
|
|
39
|
+
focus: true,
|
|
40
|
+
'remove-scroll': true,
|
|
41
|
+
// it's nice to hit escape to hide a tooltip
|
|
42
|
+
// dismiss: true
|
|
43
|
+
} as const
|
|
44
|
+
|
|
45
|
+
const TooltipContent = PopperContentFrame.styleable<TooltipContentProps>(
|
|
46
|
+
(props, ref) => {
|
|
47
|
+
const preventAnimation = React.useContext(PreventTooltipAnimationContext)
|
|
48
|
+
const zIndexFromContext = React.useContext(TooltipZIndexContext)
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<PopoverContent
|
|
52
|
+
scope={props.scope || TOOLTIP_SCOPE}
|
|
53
|
+
alwaysDisable={ALWAYS_DISABLE_TOOLTIP}
|
|
54
|
+
{...(!props.unstyled && {
|
|
55
|
+
backgroundColor: '$background',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
pointerEvents: 'none',
|
|
58
|
+
size: '$true',
|
|
59
|
+
})}
|
|
60
|
+
ref={ref}
|
|
61
|
+
// zIndex from root Tooltip prop flows to portal
|
|
62
|
+
{...(zIndexFromContext !== undefined && { zIndex: zIndexFromContext })}
|
|
63
|
+
{...props}
|
|
64
|
+
{...(preventAnimation && {
|
|
65
|
+
transition: null,
|
|
66
|
+
})}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
staticConfig: {
|
|
72
|
+
componentName: 'Tooltip',
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
const TooltipArrow = React.forwardRef<GuiElement, PopperArrowProps>((props, ref) => {
|
|
78
|
+
return (
|
|
79
|
+
<PopoverArrow
|
|
80
|
+
scope={props.scope || TOOLTIP_SCOPE}
|
|
81
|
+
componentName="Tooltip"
|
|
82
|
+
ref={ref}
|
|
83
|
+
{...props}
|
|
84
|
+
/>
|
|
85
|
+
)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
export type TooltipProps = ScopedProps<
|
|
89
|
+
PopperProps & {
|
|
90
|
+
open?: boolean
|
|
91
|
+
unstyled?: boolean
|
|
92
|
+
children?: React.ReactNode
|
|
93
|
+
onOpenChange?: (open: boolean) => void
|
|
94
|
+
focus?: {
|
|
95
|
+
enabled?: boolean
|
|
96
|
+
visibleOnly?: boolean
|
|
97
|
+
}
|
|
98
|
+
groupId?: string
|
|
99
|
+
restMs?: number
|
|
100
|
+
delay?:
|
|
101
|
+
| number
|
|
102
|
+
| {
|
|
103
|
+
open?: number
|
|
104
|
+
close?: number
|
|
105
|
+
}
|
|
106
|
+
disableAutoCloseOnScroll?: boolean
|
|
107
|
+
/**
|
|
108
|
+
* z-index for the tooltip portal. Use this when tooltips need to appear
|
|
109
|
+
* above other portaled content like dialogs.
|
|
110
|
+
*/
|
|
111
|
+
zIndex?: number
|
|
112
|
+
}
|
|
113
|
+
>
|
|
114
|
+
|
|
115
|
+
const PreventTooltipAnimationContext = React.createContext(false)
|
|
116
|
+
const TooltipZIndexContext = React.createContext<number | undefined>(undefined)
|
|
117
|
+
|
|
118
|
+
export const TooltipGroup = ({
|
|
119
|
+
children,
|
|
120
|
+
delay,
|
|
121
|
+
preventAnimation = false,
|
|
122
|
+
timeoutMs,
|
|
123
|
+
}: {
|
|
124
|
+
children?: any
|
|
125
|
+
delay: Delay
|
|
126
|
+
preventAnimation?: boolean
|
|
127
|
+
timeoutMs?: number
|
|
128
|
+
}) => {
|
|
129
|
+
return (
|
|
130
|
+
<PreventTooltipAnimationContext.Provider value={preventAnimation}>
|
|
131
|
+
<FloatingDelayGroup
|
|
132
|
+
timeoutMs={timeoutMs}
|
|
133
|
+
delay={React.useMemo(() => delay, [JSON.stringify(delay)])}
|
|
134
|
+
>
|
|
135
|
+
{children}
|
|
136
|
+
</FloatingDelayGroup>
|
|
137
|
+
</PreventTooltipAnimationContext.Provider>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const setOpens = new Set<React.Dispatch<React.SetStateAction<boolean>>>()
|
|
142
|
+
|
|
143
|
+
export const closeOpenTooltips = () => {
|
|
144
|
+
setOpens.forEach((x) => x(false))
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const TooltipComponent = React.forwardRef(function Tooltip(
|
|
148
|
+
props: TooltipProps,
|
|
149
|
+
// no real ref here but React complaining need to see why see SandboxCustomStyledAnimatedTooltip.ts
|
|
150
|
+
ref
|
|
151
|
+
) {
|
|
152
|
+
// hooks inside useFloatingFn confuse the React Compiler
|
|
153
|
+
'use no memo'
|
|
154
|
+
|
|
155
|
+
const {
|
|
156
|
+
children,
|
|
157
|
+
delay: delayProp,
|
|
158
|
+
restMs: restMsProp,
|
|
159
|
+
onOpenChange: onOpenChangeProp,
|
|
160
|
+
focus,
|
|
161
|
+
open: openProp,
|
|
162
|
+
disableAutoCloseOnScroll,
|
|
163
|
+
zIndex,
|
|
164
|
+
scope = TOOLTIP_SCOPE,
|
|
165
|
+
...restProps
|
|
166
|
+
} = props
|
|
167
|
+
const triggerRef = React.useRef<HTMLButtonElement>(null)
|
|
168
|
+
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false)
|
|
169
|
+
const { delay: delayGroup, setCurrentId } = useDelayGroupContext()
|
|
170
|
+
// Use delayProp if explicitly provided, otherwise fall back to group delay or default 400
|
|
171
|
+
const delay = delayProp !== undefined ? delayProp : (delayGroup ?? 400)
|
|
172
|
+
const restMs = restMsProp ?? (typeof delay === 'number' ? delay : 0)
|
|
173
|
+
const [open, setOpen] = useControllableState({
|
|
174
|
+
prop: openProp,
|
|
175
|
+
defaultProp: false,
|
|
176
|
+
onChange: onOpenChangeProp,
|
|
177
|
+
})
|
|
178
|
+
const id = props.groupId
|
|
179
|
+
|
|
180
|
+
const onOpenChange = useEvent((open: boolean) => {
|
|
181
|
+
if (open) {
|
|
182
|
+
setCurrentId(id)
|
|
183
|
+
}
|
|
184
|
+
setOpen(open)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
// Auto close when document scroll
|
|
188
|
+
React.useEffect(() => {
|
|
189
|
+
if (!open) return
|
|
190
|
+
if (disableAutoCloseOnScroll) return
|
|
191
|
+
if (typeof document === 'undefined') return
|
|
192
|
+
const closeIt = () => {
|
|
193
|
+
setOpen(false)
|
|
194
|
+
}
|
|
195
|
+
setOpens.add(setOpen)
|
|
196
|
+
document.documentElement.addEventListener('scroll', closeIt)
|
|
197
|
+
return () => {
|
|
198
|
+
setOpens.delete(setOpen)
|
|
199
|
+
document.documentElement.removeEventListener('scroll', closeIt)
|
|
200
|
+
}
|
|
201
|
+
}, [open, disableAutoCloseOnScroll])
|
|
202
|
+
|
|
203
|
+
// use the shared floating context from popover — gives us multi-trigger
|
|
204
|
+
// hover coordination (onHoverReference/onLeaveReference + grace period)
|
|
205
|
+
// and safePolygon for free
|
|
206
|
+
const floatingContext = useFloatingContext({
|
|
207
|
+
open,
|
|
208
|
+
setOpen: onOpenChange,
|
|
209
|
+
disable: false,
|
|
210
|
+
disableFocus: false,
|
|
211
|
+
hoverable: true,
|
|
212
|
+
role: 'tooltip',
|
|
213
|
+
focus,
|
|
214
|
+
groupId: id,
|
|
215
|
+
delay,
|
|
216
|
+
restMs,
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
const onCustomAnchorAdd = React.useCallback(() => setHasCustomAnchor(true), [])
|
|
220
|
+
const onCustomAnchorRemove = React.useCallback(() => setHasCustomAnchor(false), [])
|
|
221
|
+
const contentId = React.useId()
|
|
222
|
+
const smallerSize = props.unstyled
|
|
223
|
+
? null
|
|
224
|
+
: getSize('$true', {
|
|
225
|
+
shift: -2,
|
|
226
|
+
bounds: [0],
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
const content = (
|
|
230
|
+
<FloatingOverrideContext.Provider value={floatingContext}>
|
|
231
|
+
{/* default tooltip to a smaller size */}
|
|
232
|
+
<Popper
|
|
233
|
+
scope={scope}
|
|
234
|
+
size={smallerSize?.key as SizeTokens}
|
|
235
|
+
allowFlip
|
|
236
|
+
stayInFrame
|
|
237
|
+
open={open}
|
|
238
|
+
{...restProps}
|
|
239
|
+
>
|
|
240
|
+
<PopoverContextProvider
|
|
241
|
+
scope={scope}
|
|
242
|
+
contentId={contentId}
|
|
243
|
+
triggerRef={triggerRef}
|
|
244
|
+
open={open}
|
|
245
|
+
onOpenChange={setOpen}
|
|
246
|
+
onOpenToggle={voidFn}
|
|
247
|
+
hasCustomAnchor={hasCustomAnchor}
|
|
248
|
+
onCustomAnchorAdd={onCustomAnchorAdd}
|
|
249
|
+
onCustomAnchorRemove={onCustomAnchorRemove}
|
|
250
|
+
>
|
|
251
|
+
{children}
|
|
252
|
+
</PopoverContextProvider>
|
|
253
|
+
</Popper>
|
|
254
|
+
</FloatingOverrideContext.Provider>
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
if (zIndex !== undefined) {
|
|
258
|
+
return (
|
|
259
|
+
<TooltipZIndexContext.Provider value={zIndex}>
|
|
260
|
+
{content}
|
|
261
|
+
</TooltipZIndexContext.Provider>
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
return content
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
const TooltipTrigger = React.forwardRef(function TooltipTrigger(
|
|
269
|
+
props: ScopedProps<PopoverTriggerProps>,
|
|
270
|
+
ref: any
|
|
271
|
+
) {
|
|
272
|
+
const { scope, ...rest } = props
|
|
273
|
+
return <PopoverTrigger {...rest} scope={scope || TOOLTIP_SCOPE} ref={ref} />
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
const TooltipAnchor = React.forwardRef(function TooltipAnchor(
|
|
277
|
+
props: ScopedProps<PopoverAnchorProps>,
|
|
278
|
+
ref: any
|
|
279
|
+
) {
|
|
280
|
+
const { scope, ...rest } = props
|
|
281
|
+
return <PopoverAnchor {...rest} scope={scope || TOOLTIP_SCOPE} ref={ref} />
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
export const Tooltip = withStaticProperties(TooltipComponent, {
|
|
285
|
+
Anchor: TooltipAnchor,
|
|
286
|
+
Arrow: TooltipArrow,
|
|
287
|
+
Content: TooltipContent,
|
|
288
|
+
Trigger: TooltipTrigger,
|
|
289
|
+
})
|
|
290
|
+
|
|
291
|
+
const voidFn = () => {}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { getSpace } from '@hanzogui/get-token'
|
|
2
|
+
import type { SizableStackProps } from '@hanzogui/stacks'
|
|
3
|
+
import { Paragraph } from '@hanzogui/text'
|
|
4
|
+
import * as React from 'react'
|
|
5
|
+
|
|
6
|
+
import type { TooltipProps } from './Tooltip'
|
|
7
|
+
import { Tooltip } from './Tooltip'
|
|
8
|
+
|
|
9
|
+
export type TooltipSimpleProps = TooltipProps & {
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
label?: React.ReactNode
|
|
12
|
+
children?: React.ReactNode
|
|
13
|
+
contentProps?: SizableStackProps
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const TooltipSimple: React.FC<TooltipSimpleProps> = React.forwardRef(
|
|
17
|
+
({ label, children, contentProps, disabled, ...tooltipProps }, ref) => {
|
|
18
|
+
'use no memo'
|
|
19
|
+
|
|
20
|
+
const child = React.Children.only(children)
|
|
21
|
+
|
|
22
|
+
if (!label) {
|
|
23
|
+
return children
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Tooltip
|
|
28
|
+
disableRTL
|
|
29
|
+
offset={15}
|
|
30
|
+
restMs={40}
|
|
31
|
+
delay={40}
|
|
32
|
+
// ensure tooltips appear above dialogs and other portaled content
|
|
33
|
+
zIndex={1_000_000}
|
|
34
|
+
{...tooltipProps}
|
|
35
|
+
{...(disabled ? { open: false } : null)}
|
|
36
|
+
>
|
|
37
|
+
<Tooltip.Trigger
|
|
38
|
+
{...(typeof label === 'string' && {
|
|
39
|
+
'aria-label': label,
|
|
40
|
+
})}
|
|
41
|
+
asChild="except-style"
|
|
42
|
+
>
|
|
43
|
+
{ref && React.isValidElement(child)
|
|
44
|
+
? React.cloneElement(child, { ref } as any)
|
|
45
|
+
: child}
|
|
46
|
+
</Tooltip.Trigger>
|
|
47
|
+
|
|
48
|
+
<Tooltip.Content
|
|
49
|
+
enterStyle={{ y: -4, opacity: 0, scale: 0.96 }}
|
|
50
|
+
exitStyle={{ y: -4, opacity: 0, scale: 0.96 }}
|
|
51
|
+
scale={1}
|
|
52
|
+
elevation="$0.5"
|
|
53
|
+
opacity={1}
|
|
54
|
+
pointerEvents="none"
|
|
55
|
+
paddingVertical={getSpace(tooltipProps.size || '$true', {
|
|
56
|
+
shift: -4,
|
|
57
|
+
})}
|
|
58
|
+
animateOnly={['transform', 'opacity']}
|
|
59
|
+
transition={[
|
|
60
|
+
'quicker',
|
|
61
|
+
{
|
|
62
|
+
opacity: {
|
|
63
|
+
overshootClamping: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
]}
|
|
67
|
+
{...contentProps}
|
|
68
|
+
>
|
|
69
|
+
<Tooltip.Arrow />
|
|
70
|
+
<Paragraph
|
|
71
|
+
maxWidth={350}
|
|
72
|
+
overflow="hidden"
|
|
73
|
+
size="$3"
|
|
74
|
+
textAlign="center"
|
|
75
|
+
$platform-web={{
|
|
76
|
+
textWrap: 'balance',
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
{label}
|
|
80
|
+
</Paragraph>
|
|
81
|
+
</Tooltip.Content>
|
|
82
|
+
</Tooltip>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
)
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import '@gui/polyfill-dev';
|
|
2
|
+
import { type Delay } from '@gui/floating';
|
|
3
|
+
import type { SizeTokens, GuiElement } from '@gui/core';
|
|
4
|
+
import type { PopoverAnchorProps, PopoverContentProps, PopoverTriggerProps } from '@gui/popover';
|
|
5
|
+
import type { PopperProps } from '@gui/popper';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
export type TooltipScopes = string;
|
|
8
|
+
type ScopedProps<P> = Omit<P, 'scope'> & {
|
|
9
|
+
scope?: TooltipScopes;
|
|
10
|
+
};
|
|
11
|
+
export type TooltipContentProps = ScopedProps<PopoverContentProps>;
|
|
12
|
+
export type TooltipProps = ScopedProps<PopperProps & {
|
|
13
|
+
open?: boolean;
|
|
14
|
+
unstyled?: boolean;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
onOpenChange?: (open: boolean) => void;
|
|
17
|
+
focus?: {
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
visibleOnly?: boolean;
|
|
20
|
+
};
|
|
21
|
+
groupId?: string;
|
|
22
|
+
restMs?: number;
|
|
23
|
+
delay?: number | {
|
|
24
|
+
open?: number;
|
|
25
|
+
close?: number;
|
|
26
|
+
};
|
|
27
|
+
disableAutoCloseOnScroll?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* z-index for the tooltip portal. Use this when tooltips need to appear
|
|
30
|
+
* above other portaled content like dialogs.
|
|
31
|
+
*/
|
|
32
|
+
zIndex?: number;
|
|
33
|
+
}>;
|
|
34
|
+
export declare const TooltipGroup: ({ children, delay, preventAnimation, timeoutMs, }: {
|
|
35
|
+
children?: any;
|
|
36
|
+
delay: Delay;
|
|
37
|
+
preventAnimation?: boolean;
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
export declare const closeOpenTooltips: () => void;
|
|
41
|
+
export declare const Tooltip: React.ForwardRefExoticComponent<Omit<PopperProps & {
|
|
42
|
+
open?: boolean;
|
|
43
|
+
unstyled?: boolean;
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
onOpenChange?: (open: boolean) => void;
|
|
46
|
+
focus?: {
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
visibleOnly?: boolean;
|
|
49
|
+
};
|
|
50
|
+
groupId?: string;
|
|
51
|
+
restMs?: number;
|
|
52
|
+
delay?: number | {
|
|
53
|
+
open?: number;
|
|
54
|
+
close?: number;
|
|
55
|
+
};
|
|
56
|
+
disableAutoCloseOnScroll?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* z-index for the tooltip portal. Use this when tooltips need to appear
|
|
59
|
+
* above other portaled content like dialogs.
|
|
60
|
+
*/
|
|
61
|
+
zIndex?: number;
|
|
62
|
+
}, "scope"> & {
|
|
63
|
+
scope?: TooltipScopes;
|
|
64
|
+
} & React.RefAttributes<unknown>> & {
|
|
65
|
+
Anchor: React.ForwardRefExoticComponent<Omit<PopoverAnchorProps, "scope"> & {
|
|
66
|
+
scope?: TooltipScopes;
|
|
67
|
+
} & React.RefAttributes<unknown>>;
|
|
68
|
+
Arrow: React.ForwardRefExoticComponent<Omit<import("@gui/core").GetFinalProps<import("@gui/core").RNGuiViewNonStyleProps, import("@gui/core").StackStyleBase, {
|
|
69
|
+
elevation?: number | SizeTokens | undefined;
|
|
70
|
+
fullscreen?: boolean | undefined;
|
|
71
|
+
}>, keyof import("@gui/stacks").StackVariants> & import("@gui/stacks").StackVariants & import("@gui/popper").PopperArrowExtraProps & React.RefAttributes<GuiElement>>;
|
|
72
|
+
Content: import("@gui/core").GuiComponent<Omit<import("@gui/core").GetFinalProps<import("@gui/core").RNGuiViewNonStyleProps, import("@gui/core").StackStyleBase, {
|
|
73
|
+
size?: SizeTokens | undefined;
|
|
74
|
+
unstyled?: boolean | undefined;
|
|
75
|
+
elevation?: number | SizeTokens | undefined;
|
|
76
|
+
fullscreen?: boolean | undefined;
|
|
77
|
+
}>, "theme" | "debug" | "scope" | "hitSlop" | "pointerEvents" | "display" | "children" | "target" | "htmlFor" | "asChild" | "dangerouslySetInnerHTML" | "disabled" | "className" | "themeShallow" | "unstyled" | "id" | "render" | "group" | "untilMeasured" | "componentName" | "tabIndex" | "role" | "disableOptimization" | "forceStyle" | "disableClassName" | "animatedBy" | "onStartShouldSetResponder" | "onScrollShouldSetResponder" | "onScrollShouldSetResponderCapture" | "onSelectionChangeShouldSetResponder" | "onSelectionChangeShouldSetResponderCapture" | "onLayout" | "elevationAndroid" | "rel" | "download" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "style" | "onFocus" | "onBlur" | "onPointerCancel" | "onPointerDown" | "onPointerMove" | "onPointerUp" | "needsOffscreenAlphaCompositing" | "removeClippedSubviews" | "testID" | "nativeID" | "collapsable" | "collapsableChildren" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMoveCapture" | "onPointerCancelCapture" | "onPointerDownCapture" | "onPointerUpCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "aria-label" | "accessibilityRole" | "accessibilityState" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-selected" | "accessibilityHint" | "accessibilityValue" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onAccessibilityAction" | "importantForAccessibility" | "aria-hidden" | "aria-modal" | "accessibilityLabelledBy" | "aria-labelledby" | "accessibilityLiveRegion" | "aria-live" | "screenReaderFocusable" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "accessibilityLanguage" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityRespondsToUserInteraction" | "onPress" | "onLongPress" | "onPressIn" | "onPressOut" | "onMouseEnter" | "onMouseLeave" | "onMouseDown" | "onMouseUp" | "onMouseMove" | "onMouseOver" | "onMouseOut" | "onClick" | "onDoubleClick" | "onContextMenu" | "onWheel" | "onKeyDown" | "onKeyUp" | "onChange" | "onInput" | "onBeforeInput" | "onScroll" | "onCopy" | "onCut" | "onPaste" | "onDrag" | "onDragStart" | "onDragEnd" | "onDragEnter" | "onDragLeave" | "onDragOver" | "onDrop" | "position" | "x" | "y" | "perspective" | "scale" | "scaleX" | "scaleY" | "skewX" | "skewY" | "matrix" | "rotate" | "rotateY" | "rotateX" | "rotateZ" | "borderCurve" | "contain" | "cursor" | "outlineColor" | "outlineOffset" | "outlineStyle" | "outlineWidth" | "outline" | "userSelect" | "backdropFilter" | "background" | "backgroundImage" | "backgroundOrigin" | "backgroundPosition" | "backgroundRepeat" | "backgroundSize" | "boxShadow" | "border" | "overflowX" | "overflowY" | "transformOrigin" | "filter" | "backgroundClip" | "backgroundBlendMode" | "backgroundAttachment" | "clipPath" | "caretColor" | "transformStyle" | "mask" | "maskImage" | "textEmphasis" | "borderImage" | "float" | "content" | "overflowBlock" | "overflowInline" | "maskBorder" | "maskBorderMode" | "maskBorderOutset" | "maskBorderRepeat" | "maskBorderSlice" | "maskBorderSource" | "maskBorderWidth" | "maskClip" | "maskComposite" | "maskMode" | "maskOrigin" | "maskPosition" | "maskRepeat" | "maskSize" | "maskType" | "gridRow" | "gridRowEnd" | "gridRowGap" | "gridRowStart" | "gridColumn" | "gridColumnEnd" | "gridColumnGap" | "gridColumnStart" | "gridTemplateColumns" | "gridTemplateAreas" | "containerType" | "blockSize" | "inlineSize" | "minBlockSize" | "maxBlockSize" | "objectFit" | "verticalAlign" | "minInlineSize" | "maxInlineSize" | "borderInlineColor" | "borderInlineStartColor" | "borderInlineEndColor" | "borderBlockWidth" | "borderBlockStartWidth" | "borderBlockEndWidth" | "borderInlineWidth" | "borderInlineStartWidth" | "borderInlineEndWidth" | "borderBlockStyle" | "borderBlockStartStyle" | "borderBlockEndStyle" | "borderInlineStyle" | "borderInlineStartStyle" | "borderInlineEndStyle" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "inset" | "insetBlock" | "insetBlockStart" | "insetBlockEnd" | "insetInline" | "insetInlineStart" | "insetInlineEnd" | "transition" | "animateOnly" | "animatePresence" | "passThrough" | "elevation" | "backfaceVisibility" | "backgroundColor" | "borderBlockColor" | "borderBlockEndColor" | "borderBlockStartColor" | "borderBottomColor" | "borderBottomEndRadius" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStartRadius" | "borderColor" | "borderEndColor" | "borderEndEndRadius" | "borderEndStartRadius" | "borderLeftColor" | "borderRadius" | "borderRightColor" | "borderStartColor" | "borderStartEndRadius" | "borderStartStartRadius" | "borderStyle" | "borderTopColor" | "borderTopEndRadius" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStartRadius" | "opacity" | "isolation" | "mixBlendMode" | "experimental_backgroundImage" | "alignContent" | "alignItems" | "alignSelf" | "aspectRatio" | "borderBottomWidth" | "borderEndWidth" | "borderLeftWidth" | "borderRightWidth" | "borderStartWidth" | "borderTopWidth" | "borderWidth" | "bottom" | "boxSizing" | "end" | "flex" | "flexBasis" | "flexDirection" | "rowGap" | "gap" | "columnGap" | "flexGrow" | "flexShrink" | "flexWrap" | "height" | "justifyContent" | "left" | "margin" | "marginBottom" | "marginEnd" | "marginHorizontal" | "marginLeft" | "marginRight" | "marginStart" | "marginTop" | "marginVertical" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "overflow" | "padding" | "paddingBottom" | "paddingEnd" | "paddingHorizontal" | "paddingLeft" | "paddingRight" | "paddingStart" | "paddingTop" | "paddingVertical" | "right" | "start" | "top" | "width" | "zIndex" | "direction" | "shadowColor" | "shadowOffset" | "shadowOpacity" | "shadowRadius" | "transform" | "transformMatrix" | "rotation" | "translateX" | "translateY" | "size" | "transparent" | "fullscreen" | "circular" | "elevate" | "bordered" | "chromeless" | `$${string}` | `$${number}` | `$group-${string}` | `$group-${number}` | `$group-${string}-hover` | `$group-${string}-press` | `$group-${string}-focus` | `$group-${string}-focusVisible` | `$group-${string}-focusWithin` | `$group-${number}-hover` | `$group-${number}-press` | `$group-${number}-focus` | `$group-${number}-focusVisible` | `$group-${number}-focusWithin` | `$theme-${string}` | `$theme-${number}` | "branches" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside" | "forceUnmount" | "onBlurCapture" | "onFocusCapture" | "hoverStyle" | "pressStyle" | "focusStyle" | "focusWithinStyle" | "focusVisibleStyle" | "disabledStyle" | "exitStyle" | "enterStyle" | "animatePosition" | "enableAnimationForPositionChange" | "lazyMount" | "trapFocus" | "disableFocusScope" | "onOpenAutoFocus" | "onCloseAutoFocus" | "enableRemoveScroll" | "freezeContentsWhenHidden" | "alwaysDisable"> & Omit<import("@gui/popover").PopoverContentTypeProps, "scope"> & {
|
|
78
|
+
scope?: TooltipScopes;
|
|
79
|
+
}, GuiElement, import("@gui/core").RNGuiViewNonStyleProps & Omit<import("@gui/popover").PopoverContentTypeProps, "scope"> & {
|
|
80
|
+
scope?: TooltipScopes;
|
|
81
|
+
}, import("@gui/core").StackStyleBase, {
|
|
82
|
+
size?: SizeTokens | undefined;
|
|
83
|
+
unstyled?: boolean | undefined;
|
|
84
|
+
elevation?: number | SizeTokens | undefined;
|
|
85
|
+
fullscreen?: boolean | undefined;
|
|
86
|
+
}, import("@gui/core").StaticConfigPublic>;
|
|
87
|
+
Trigger: React.ForwardRefExoticComponent<Omit<PopoverTriggerProps, "scope"> & {
|
|
88
|
+
scope?: TooltipScopes;
|
|
89
|
+
} & React.RefAttributes<unknown>>;
|
|
90
|
+
};
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const TooltipGroup: () => null;
|
|
2
|
+
export declare const closeOpenTooltips: () => void;
|
|
3
|
+
export declare const Tooltip: ((props: any) => any) & {
|
|
4
|
+
Anchor: (props: any) => any;
|
|
5
|
+
Arrow: (props: any) => null;
|
|
6
|
+
Close: (props: any) => null;
|
|
7
|
+
Content: (props: any) => null;
|
|
8
|
+
Trigger: (props: any) => any;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=Tooltip.native.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SizableStackProps } from '@gui/stacks';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { TooltipProps } from './Tooltip';
|
|
4
|
+
export type TooltipSimpleProps = TooltipProps & {
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
label?: React.ReactNode;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
contentProps?: SizableStackProps;
|
|
9
|
+
};
|
|
10
|
+
export declare const TooltipSimple: React.FC<TooltipSimpleProps>;
|
|
11
|
+
//# sourceMappingURL=TooltipSimple.d.ts.map
|
package/types/index.d.ts
ADDED