@lattice-ui/tooltip 0.1.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/out/index.d.ts +12 -5
- package/out/init.luau +15 -7
- package/package.json +10 -6
- package/src/Tooltip/TooltipContent.tsx +0 -144
- package/src/Tooltip/TooltipPortal.tsx +0 -28
- package/src/Tooltip/TooltipProvider.tsx +0 -43
- package/src/Tooltip/TooltipRoot.tsx +0 -76
- package/src/Tooltip/TooltipTrigger.tsx +0 -75
- package/src/Tooltip/context.ts +0 -21
- package/src/Tooltip/types.ts +0 -59
- package/src/index.ts +0 -12
- package/tsconfig.json +0 -16
- package/tsconfig.typecheck.json +0 -25
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 astra-void
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/out/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { TooltipContent } from "./Tooltip/TooltipContent";
|
|
2
|
+
import { TooltipPortal } from "./Tooltip/TooltipPortal";
|
|
3
|
+
import { TooltipProvider } from "./Tooltip/TooltipProvider";
|
|
4
|
+
import { Tooltip as TooltipRoot } from "./Tooltip/TooltipRoot";
|
|
5
|
+
import { TooltipTrigger } from "./Tooltip/TooltipTrigger";
|
|
6
|
+
export declare const Tooltip: {
|
|
7
|
+
readonly Provider: typeof TooltipProvider;
|
|
8
|
+
readonly Root: typeof TooltipRoot;
|
|
9
|
+
readonly Trigger: typeof TooltipTrigger;
|
|
10
|
+
readonly Portal: typeof TooltipPortal;
|
|
11
|
+
readonly Content: typeof TooltipContent;
|
|
12
|
+
};
|
|
6
13
|
export type { TooltipContentProps, TooltipPortalProps, TooltipProps, TooltipProviderProps, TooltipTriggerProps, } from "./Tooltip/types";
|
package/out/init.luau
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
|
-
local
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
local TooltipContent = TS.import(script, script, "Tooltip", "TooltipContent").TooltipContent
|
|
4
|
+
local TooltipPortal = TS.import(script, script, "Tooltip", "TooltipPortal").TooltipPortal
|
|
5
|
+
local TooltipProvider = TS.import(script, script, "Tooltip", "TooltipProvider").TooltipProvider
|
|
6
|
+
local TooltipRoot = TS.import(script, script, "Tooltip", "TooltipRoot").Tooltip
|
|
7
|
+
local TooltipTrigger = TS.import(script, script, "Tooltip", "TooltipTrigger").TooltipTrigger
|
|
8
|
+
local Tooltip = {
|
|
9
|
+
Provider = TooltipProvider,
|
|
10
|
+
Root = TooltipRoot,
|
|
11
|
+
Trigger = TooltipTrigger,
|
|
12
|
+
Portal = TooltipPortal,
|
|
13
|
+
Content = TooltipContent,
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
Tooltip = Tooltip,
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lattice-ui/tooltip",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "out/init.luau",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"out",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
7
11
|
"dependencies": {
|
|
8
|
-
"@lattice-ui/
|
|
9
|
-
"@lattice-ui/
|
|
10
|
-
"@lattice-ui/popper": "0.
|
|
12
|
+
"@lattice-ui/layer": "0.3.1",
|
|
13
|
+
"@lattice-ui/core": "0.3.1",
|
|
14
|
+
"@lattice-ui/popper": "0.3.1"
|
|
11
15
|
},
|
|
12
16
|
"devDependencies": {
|
|
13
17
|
"@rbxts/react": "17.3.7-ts.1",
|
|
@@ -19,7 +23,7 @@
|
|
|
19
23
|
},
|
|
20
24
|
"scripts": {
|
|
21
25
|
"build": "rbxtsc -p tsconfig.json",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
26
|
+
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
27
|
+
"watch": "rbxtsc -p tsconfig.json -w"
|
|
24
28
|
}
|
|
25
29
|
}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { React, Slot } from "@lattice-ui/core";
|
|
2
|
-
import { DismissableLayer, Presence } from "@lattice-ui/layer";
|
|
3
|
-
import { usePopper } from "@lattice-ui/popper";
|
|
4
|
-
import { useTooltipContext } from "./context";
|
|
5
|
-
import type { TooltipContentProps } from "./types";
|
|
6
|
-
|
|
7
|
-
type TooltipContentImplProps = {
|
|
8
|
-
enabled: boolean;
|
|
9
|
-
visible: boolean;
|
|
10
|
-
onDismiss: () => void;
|
|
11
|
-
asChild?: boolean;
|
|
12
|
-
placement?: TooltipContentProps["placement"];
|
|
13
|
-
offset?: TooltipContentProps["offset"];
|
|
14
|
-
padding?: TooltipContentProps["padding"];
|
|
15
|
-
} & Pick<TooltipContentProps, "children" | "onEscapeKeyDown" | "onInteractOutside" | "onPointerDownOutside">;
|
|
16
|
-
|
|
17
|
-
function toGuiObject(instance: Instance | undefined) {
|
|
18
|
-
if (!instance || !instance.IsA("GuiObject")) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return instance;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function TooltipContentImpl(props: TooltipContentImplProps) {
|
|
26
|
-
const tooltipContext = useTooltipContext();
|
|
27
|
-
|
|
28
|
-
const popper = usePopper({
|
|
29
|
-
anchorRef: tooltipContext.triggerRef,
|
|
30
|
-
contentRef: tooltipContext.contentRef,
|
|
31
|
-
placement: props.placement,
|
|
32
|
-
offset: props.offset,
|
|
33
|
-
padding: props.padding,
|
|
34
|
-
enabled: props.enabled,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const setContentRef = React.useCallback(
|
|
38
|
-
(instance: Instance | undefined) => {
|
|
39
|
-
tooltipContext.contentRef.current = toGuiObject(instance);
|
|
40
|
-
},
|
|
41
|
-
[tooltipContext.contentRef],
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
if (props.asChild) {
|
|
45
|
-
const child = props.children;
|
|
46
|
-
if (!React.isValidElement(child)) {
|
|
47
|
-
error("[TooltipContent] `asChild` requires a child element.");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<DismissableLayer
|
|
52
|
-
enabled={props.enabled}
|
|
53
|
-
modal={false}
|
|
54
|
-
onDismiss={props.onDismiss}
|
|
55
|
-
onEscapeKeyDown={props.onEscapeKeyDown}
|
|
56
|
-
onInteractOutside={props.onInteractOutside}
|
|
57
|
-
onPointerDownOutside={props.onPointerDownOutside}
|
|
58
|
-
>
|
|
59
|
-
<Slot AnchorPoint={popper.anchorPoint} Position={popper.position} Visible={props.visible} ref={setContentRef}>
|
|
60
|
-
{child}
|
|
61
|
-
</Slot>
|
|
62
|
-
</DismissableLayer>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<DismissableLayer
|
|
68
|
-
enabled={props.enabled}
|
|
69
|
-
modal={false}
|
|
70
|
-
onDismiss={props.onDismiss}
|
|
71
|
-
onEscapeKeyDown={props.onEscapeKeyDown}
|
|
72
|
-
onInteractOutside={props.onInteractOutside}
|
|
73
|
-
onPointerDownOutside={props.onPointerDownOutside}
|
|
74
|
-
>
|
|
75
|
-
<frame
|
|
76
|
-
AnchorPoint={popper.anchorPoint}
|
|
77
|
-
BackgroundTransparency={1}
|
|
78
|
-
BorderSizePixel={0}
|
|
79
|
-
Position={popper.position}
|
|
80
|
-
Size={UDim2.fromOffset(0, 0)}
|
|
81
|
-
Visible={props.visible}
|
|
82
|
-
ref={setContentRef}
|
|
83
|
-
>
|
|
84
|
-
{props.children}
|
|
85
|
-
</frame>
|
|
86
|
-
</DismissableLayer>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function TooltipContent(props: TooltipContentProps) {
|
|
91
|
-
const tooltipContext = useTooltipContext();
|
|
92
|
-
const open = tooltipContext.open;
|
|
93
|
-
const forceMount = props.forceMount === true;
|
|
94
|
-
|
|
95
|
-
const handleDismiss = React.useCallback(() => {
|
|
96
|
-
tooltipContext.close();
|
|
97
|
-
}, [tooltipContext]);
|
|
98
|
-
|
|
99
|
-
if (!open && !forceMount) {
|
|
100
|
-
return undefined;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (forceMount) {
|
|
104
|
-
return (
|
|
105
|
-
<TooltipContentImpl
|
|
106
|
-
asChild={props.asChild}
|
|
107
|
-
enabled={open}
|
|
108
|
-
offset={props.offset}
|
|
109
|
-
onDismiss={handleDismiss}
|
|
110
|
-
onEscapeKeyDown={props.onEscapeKeyDown}
|
|
111
|
-
onInteractOutside={props.onInteractOutside}
|
|
112
|
-
onPointerDownOutside={props.onPointerDownOutside}
|
|
113
|
-
padding={props.padding}
|
|
114
|
-
placement={props.placement}
|
|
115
|
-
visible={open}
|
|
116
|
-
>
|
|
117
|
-
{props.children}
|
|
118
|
-
</TooltipContentImpl>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<Presence
|
|
124
|
-
exitFallbackMs={0}
|
|
125
|
-
present={open}
|
|
126
|
-
render={(state) => (
|
|
127
|
-
<TooltipContentImpl
|
|
128
|
-
asChild={props.asChild}
|
|
129
|
-
enabled={state.isPresent}
|
|
130
|
-
offset={props.offset}
|
|
131
|
-
onDismiss={handleDismiss}
|
|
132
|
-
onEscapeKeyDown={props.onEscapeKeyDown}
|
|
133
|
-
onInteractOutside={props.onInteractOutside}
|
|
134
|
-
onPointerDownOutside={props.onPointerDownOutside}
|
|
135
|
-
padding={props.padding}
|
|
136
|
-
placement={props.placement}
|
|
137
|
-
visible={state.isPresent}
|
|
138
|
-
>
|
|
139
|
-
{props.children}
|
|
140
|
-
</TooltipContentImpl>
|
|
141
|
-
)}
|
|
142
|
-
/>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { React } from "@lattice-ui/core";
|
|
2
|
-
import { Portal, PortalProvider, usePortalContext } from "@lattice-ui/layer";
|
|
3
|
-
import type { TooltipPortalProps } from "./types";
|
|
4
|
-
|
|
5
|
-
function TooltipPortalWithOverrides(props: TooltipPortalProps) {
|
|
6
|
-
const portalContext = usePortalContext();
|
|
7
|
-
const container = props.container ?? portalContext.container;
|
|
8
|
-
const displayOrderBase = props.displayOrderBase ?? portalContext.displayOrderBase;
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<PortalProvider container={container} displayOrderBase={displayOrderBase}>
|
|
12
|
-
<Portal>{props.children}</Portal>
|
|
13
|
-
</PortalProvider>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function TooltipPortal(props: TooltipPortalProps) {
|
|
18
|
-
const hasOverrides = props.container !== undefined || props.displayOrderBase !== undefined;
|
|
19
|
-
if (hasOverrides) {
|
|
20
|
-
return (
|
|
21
|
-
<TooltipPortalWithOverrides container={props.container} displayOrderBase={props.displayOrderBase}>
|
|
22
|
-
{props.children}
|
|
23
|
-
</TooltipPortalWithOverrides>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return <Portal>{props.children}</Portal>;
|
|
28
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { React } from "@lattice-ui/core";
|
|
2
|
-
import { TooltipProviderContext } from "./context";
|
|
3
|
-
import type { TooltipProviderContextValue, TooltipProviderProps } from "./types";
|
|
4
|
-
|
|
5
|
-
export function TooltipProvider(props: TooltipProviderProps) {
|
|
6
|
-
const delayDuration = props.delayDuration ?? 700;
|
|
7
|
-
const skipDelayDuration = props.skipDelayDuration ?? 300;
|
|
8
|
-
const lastOpenTimestampRef = React.useRef<number>();
|
|
9
|
-
|
|
10
|
-
const markOpen = React.useCallback(() => {
|
|
11
|
-
lastOpenTimestampRef.current = os.clock();
|
|
12
|
-
}, []);
|
|
13
|
-
|
|
14
|
-
const resolveOpenDelay = React.useCallback(
|
|
15
|
-
(requestedDelay?: number) => {
|
|
16
|
-
const baseDelay = requestedDelay ?? delayDuration;
|
|
17
|
-
const lastOpenTimestamp = lastOpenTimestampRef.current;
|
|
18
|
-
if (lastOpenTimestamp === undefined) {
|
|
19
|
-
return baseDelay;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const elapsedMs = (os.clock() - lastOpenTimestamp) * 1000;
|
|
23
|
-
if (elapsedMs <= skipDelayDuration) {
|
|
24
|
-
return math.min(baseDelay, skipDelayDuration);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return baseDelay;
|
|
28
|
-
},
|
|
29
|
-
[delayDuration, skipDelayDuration],
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const contextValue = React.useMemo<TooltipProviderContextValue>(
|
|
33
|
-
() => ({
|
|
34
|
-
delayDuration,
|
|
35
|
-
skipDelayDuration,
|
|
36
|
-
resolveOpenDelay,
|
|
37
|
-
markOpen,
|
|
38
|
-
}),
|
|
39
|
-
[delayDuration, markOpen, resolveOpenDelay, skipDelayDuration],
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
return <TooltipProviderContext.Provider value={contextValue}>{props.children}</TooltipProviderContext.Provider>;
|
|
43
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { React, useControllableState } from "@lattice-ui/core";
|
|
2
|
-
import { TooltipContextProvider, useTooltipProviderContext } from "./context";
|
|
3
|
-
import type { TooltipProps } from "./types";
|
|
4
|
-
|
|
5
|
-
export function Tooltip(props: TooltipProps) {
|
|
6
|
-
const providerContext = useTooltipProviderContext();
|
|
7
|
-
const [open, setOpenState] = useControllableState<boolean>({
|
|
8
|
-
value: props.open,
|
|
9
|
-
defaultValue: props.defaultOpen ?? false,
|
|
10
|
-
onChange: props.onOpenChange,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const triggerRef = React.useRef<GuiObject>();
|
|
14
|
-
const contentRef = React.useRef<GuiObject>();
|
|
15
|
-
const openDelayTaskRef = React.useRef<thread>();
|
|
16
|
-
|
|
17
|
-
const cancelPendingOpen = React.useCallback(() => {
|
|
18
|
-
const openDelayTask = openDelayTaskRef.current;
|
|
19
|
-
if (!openDelayTask) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
task.cancel(openDelayTask);
|
|
24
|
-
openDelayTaskRef.current = undefined;
|
|
25
|
-
}, []);
|
|
26
|
-
|
|
27
|
-
const setOpen = React.useCallback(
|
|
28
|
-
(nextOpen: boolean) => {
|
|
29
|
-
setOpenState(nextOpen);
|
|
30
|
-
if (nextOpen) {
|
|
31
|
-
providerContext.markOpen();
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
[providerContext, setOpenState],
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const openWithDelay = React.useCallback(() => {
|
|
38
|
-
cancelPendingOpen();
|
|
39
|
-
|
|
40
|
-
const resolvedDelay = providerContext.resolveOpenDelay(props.delayDuration);
|
|
41
|
-
if (resolvedDelay <= 0) {
|
|
42
|
-
setOpen(true);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
openDelayTaskRef.current = task.delay(resolvedDelay / 1000, () => {
|
|
47
|
-
openDelayTaskRef.current = undefined;
|
|
48
|
-
setOpen(true);
|
|
49
|
-
});
|
|
50
|
-
}, [cancelPendingOpen, props.delayDuration, providerContext, setOpen]);
|
|
51
|
-
|
|
52
|
-
const close = React.useCallback(() => {
|
|
53
|
-
cancelPendingOpen();
|
|
54
|
-
setOpen(false);
|
|
55
|
-
}, [cancelPendingOpen, setOpen]);
|
|
56
|
-
|
|
57
|
-
React.useEffect(() => {
|
|
58
|
-
return () => {
|
|
59
|
-
cancelPendingOpen();
|
|
60
|
-
};
|
|
61
|
-
}, [cancelPendingOpen]);
|
|
62
|
-
|
|
63
|
-
const contextValue = React.useMemo(
|
|
64
|
-
() => ({
|
|
65
|
-
open,
|
|
66
|
-
setOpen,
|
|
67
|
-
openWithDelay,
|
|
68
|
-
close,
|
|
69
|
-
triggerRef,
|
|
70
|
-
contentRef,
|
|
71
|
-
}),
|
|
72
|
-
[close, open, openWithDelay, setOpen],
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
return <TooltipContextProvider value={contextValue}>{props.children}</TooltipContextProvider>;
|
|
76
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { React, Slot } from "@lattice-ui/core";
|
|
2
|
-
import { useTooltipContext } from "./context";
|
|
3
|
-
import type { TooltipTriggerProps } from "./types";
|
|
4
|
-
|
|
5
|
-
function toGuiObject(instance: Instance | undefined) {
|
|
6
|
-
if (!instance || !instance.IsA("GuiObject")) {
|
|
7
|
-
return undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return instance;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function TooltipTrigger(props: TooltipTriggerProps) {
|
|
14
|
-
const tooltipContext = useTooltipContext();
|
|
15
|
-
|
|
16
|
-
const setTriggerRef = React.useCallback(
|
|
17
|
-
(instance: Instance | undefined) => {
|
|
18
|
-
tooltipContext.triggerRef.current = toGuiObject(instance);
|
|
19
|
-
},
|
|
20
|
-
[tooltipContext.triggerRef],
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const handleOpen = React.useCallback(() => {
|
|
24
|
-
if (props.disabled) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
tooltipContext.openWithDelay();
|
|
29
|
-
}, [props.disabled, tooltipContext]);
|
|
30
|
-
|
|
31
|
-
const handleClose = React.useCallback(() => {
|
|
32
|
-
tooltipContext.close();
|
|
33
|
-
}, [tooltipContext]);
|
|
34
|
-
|
|
35
|
-
const eventHandlers = React.useMemo(
|
|
36
|
-
() => ({
|
|
37
|
-
MouseEnter: handleOpen,
|
|
38
|
-
MouseLeave: handleClose,
|
|
39
|
-
SelectionGained: handleOpen,
|
|
40
|
-
SelectionLost: handleClose,
|
|
41
|
-
}),
|
|
42
|
-
[handleClose, handleOpen],
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
if (props.asChild) {
|
|
46
|
-
const child = props.children;
|
|
47
|
-
if (!child) {
|
|
48
|
-
error("[TooltipTrigger] `asChild` requires a child element.");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<Slot Event={eventHandlers} ref={setTriggerRef}>
|
|
53
|
-
{child}
|
|
54
|
-
</Slot>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<textbutton
|
|
60
|
-
Active={props.disabled !== true}
|
|
61
|
-
AutoButtonColor={false}
|
|
62
|
-
BackgroundTransparency={1}
|
|
63
|
-
BorderSizePixel={0}
|
|
64
|
-
Event={eventHandlers}
|
|
65
|
-
Selectable={props.disabled !== true}
|
|
66
|
-
Size={UDim2.fromOffset(140, 36)}
|
|
67
|
-
Text="Tooltip Trigger"
|
|
68
|
-
TextColor3={Color3.fromRGB(240, 244, 250)}
|
|
69
|
-
TextSize={15}
|
|
70
|
-
ref={setTriggerRef}
|
|
71
|
-
>
|
|
72
|
-
{props.children}
|
|
73
|
-
</textbutton>
|
|
74
|
-
);
|
|
75
|
-
}
|
package/src/Tooltip/context.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createStrictContext, React } from "@lattice-ui/core";
|
|
2
|
-
import type { TooltipContextValue, TooltipProviderContextValue } from "./types";
|
|
3
|
-
|
|
4
|
-
const [TooltipContextProvider, useTooltipContext] = createStrictContext<TooltipContextValue>("Tooltip");
|
|
5
|
-
|
|
6
|
-
const DEFAULT_TOOLTIP_PROVIDER_CONTEXT: TooltipProviderContextValue = {
|
|
7
|
-
delayDuration: 700,
|
|
8
|
-
skipDelayDuration: 300,
|
|
9
|
-
resolveOpenDelay: (requestedDelay) => requestedDelay ?? 700,
|
|
10
|
-
markOpen: () => {
|
|
11
|
-
// default no-op
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const TooltipProviderContext = React.createContext<TooltipProviderContextValue>(DEFAULT_TOOLTIP_PROVIDER_CONTEXT);
|
|
16
|
-
|
|
17
|
-
function useTooltipProviderContext() {
|
|
18
|
-
return React.useContext(TooltipProviderContext);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { TooltipContextProvider, TooltipProviderContext, useTooltipContext, useTooltipProviderContext };
|
package/src/Tooltip/types.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { LayerInteractEvent } from "@lattice-ui/layer";
|
|
2
|
-
import type { PopperPlacement } from "@lattice-ui/popper";
|
|
3
|
-
import type React from "@rbxts/react";
|
|
4
|
-
|
|
5
|
-
export type TooltipSetOpen = (open: boolean) => void;
|
|
6
|
-
|
|
7
|
-
export type TooltipContextValue = {
|
|
8
|
-
open: boolean;
|
|
9
|
-
setOpen: TooltipSetOpen;
|
|
10
|
-
openWithDelay: () => void;
|
|
11
|
-
close: () => void;
|
|
12
|
-
triggerRef: React.MutableRefObject<GuiObject | undefined>;
|
|
13
|
-
contentRef: React.MutableRefObject<GuiObject | undefined>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type TooltipProviderContextValue = {
|
|
17
|
-
delayDuration: number;
|
|
18
|
-
skipDelayDuration: number;
|
|
19
|
-
resolveOpenDelay: (requestedDelay?: number) => number;
|
|
20
|
-
markOpen: () => void;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type TooltipProviderProps = {
|
|
24
|
-
delayDuration?: number;
|
|
25
|
-
skipDelayDuration?: number;
|
|
26
|
-
children?: React.ReactNode;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type TooltipProps = {
|
|
30
|
-
open?: boolean;
|
|
31
|
-
defaultOpen?: boolean;
|
|
32
|
-
delayDuration?: number;
|
|
33
|
-
onOpenChange?: (open: boolean) => void;
|
|
34
|
-
children?: React.ReactNode;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type TooltipTriggerProps = {
|
|
38
|
-
asChild?: boolean;
|
|
39
|
-
disabled?: boolean;
|
|
40
|
-
children?: React.ReactElement;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type TooltipPortalProps = {
|
|
44
|
-
container?: BasePlayerGui;
|
|
45
|
-
displayOrderBase?: number;
|
|
46
|
-
children?: React.ReactNode;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export type TooltipContentProps = {
|
|
50
|
-
asChild?: boolean;
|
|
51
|
-
forceMount?: boolean;
|
|
52
|
-
placement?: PopperPlacement;
|
|
53
|
-
offset?: Vector2;
|
|
54
|
-
padding?: number;
|
|
55
|
-
onEscapeKeyDown?: (event: LayerInteractEvent) => void;
|
|
56
|
-
onPointerDownOutside?: (event: LayerInteractEvent) => void;
|
|
57
|
-
onInteractOutside?: (event: LayerInteractEvent) => void;
|
|
58
|
-
children?: React.ReactNode;
|
|
59
|
-
};
|
package/src/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { TooltipContent } from "./Tooltip/TooltipContent";
|
|
2
|
-
export { TooltipPortal } from "./Tooltip/TooltipPortal";
|
|
3
|
-
export { TooltipProvider } from "./Tooltip/TooltipProvider";
|
|
4
|
-
export { Tooltip } from "./Tooltip/TooltipRoot";
|
|
5
|
-
export { TooltipTrigger } from "./Tooltip/TooltipTrigger";
|
|
6
|
-
export type {
|
|
7
|
-
TooltipContentProps,
|
|
8
|
-
TooltipPortalProps,
|
|
9
|
-
TooltipProps,
|
|
10
|
-
TooltipProviderProps,
|
|
11
|
-
TooltipTriggerProps,
|
|
12
|
-
} from "./Tooltip/types";
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "src",
|
|
5
|
-
"outDir": "out",
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"typeRoots": [
|
|
8
|
-
"./node_modules/@rbxts",
|
|
9
|
-
"../../node_modules/@rbxts",
|
|
10
|
-
"./node_modules/@lattice-ui",
|
|
11
|
-
"../../node_modules/@lattice-ui"
|
|
12
|
-
],
|
|
13
|
-
"types": ["types", "compiler-types"]
|
|
14
|
-
},
|
|
15
|
-
"include": ["src"]
|
|
16
|
-
}
|
package/tsconfig.typecheck.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"noEmit": true,
|
|
5
|
-
"baseUrl": "..",
|
|
6
|
-
"rootDir": "..",
|
|
7
|
-
"paths": {
|
|
8
|
-
"@lattice-ui/checkbox": ["checkbox/src/index.ts"],
|
|
9
|
-
"@lattice-ui/core": ["core/src/index.ts"],
|
|
10
|
-
"@lattice-ui/dialog": ["dialog/src/index.ts"],
|
|
11
|
-
"@lattice-ui/focus": ["focus/src/index.ts"],
|
|
12
|
-
"@lattice-ui/layer": ["layer/src/index.ts"],
|
|
13
|
-
"@lattice-ui/menu": ["menu/src/index.ts"],
|
|
14
|
-
"@lattice-ui/popover": ["popover/src/index.ts"],
|
|
15
|
-
"@lattice-ui/popper": ["popper/src/index.ts"],
|
|
16
|
-
"@lattice-ui/radio-group": ["radio-group/src/index.ts"],
|
|
17
|
-
"@lattice-ui/style": ["style/src/index.ts"],
|
|
18
|
-
"@lattice-ui/switch": ["switch/src/index.ts"],
|
|
19
|
-
"@lattice-ui/system": ["system/src/index.ts"],
|
|
20
|
-
"@lattice-ui/tabs": ["tabs/src/index.ts"],
|
|
21
|
-
"@lattice-ui/toggle-group": ["toggle-group/src/index.ts"],
|
|
22
|
-
"@lattice-ui/tooltip": ["tooltip/src/index.ts"]
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|