@behivetech/atoms.tooltip 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +8 -0
- package/dist/index.cjs +71 -17
- package/dist/index.css +40 -36
- package/dist/index.d.ts +106 -1
- package/dist/index.js +71 -17
- package/dist/index.native.js +263 -0
- package/dist/native/index.d.ts +2 -0
- package/dist/native/tooltip.block.d.ts +100 -0
- package/dist/native/tooltip.block.native.d.ts +2 -0
- package/dist/native/tooltip.d.ts +30 -0
- package/dist/native/tooltip.native.d.ts +35 -0
- package/docs.json +8 -1
- package/index.ts +2 -2
- package/package.json +28 -7
- package/tooltip.block.css +57 -0
- package/tooltip.block.native.ts +112 -0
- package/tooltip.block.ts +64 -0
- package/tooltip.native.tsx +262 -0
- package/tooltip.tsx +13 -11
- package/tooltip.module.scss +0 -55
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// tooltip.native.tsx
|
|
2
|
+
import {
|
|
3
|
+
assignRef,
|
|
4
|
+
OverlayPortal,
|
|
5
|
+
useBlock
|
|
6
|
+
} from "@behivetech/blocks.core/native";
|
|
7
|
+
import {
|
|
8
|
+
isValidElement,
|
|
9
|
+
useCallback,
|
|
10
|
+
useEffect,
|
|
11
|
+
useRef,
|
|
12
|
+
useState
|
|
13
|
+
} from "react";
|
|
14
|
+
import {
|
|
15
|
+
AccessibilityInfo,
|
|
16
|
+
Platform,
|
|
17
|
+
Pressable,
|
|
18
|
+
Text
|
|
19
|
+
} from "react-native";
|
|
20
|
+
|
|
21
|
+
// tooltip.block.native.ts
|
|
22
|
+
import { createNativeBlock as __bhtCreateNativeBlock } from "@behivetech/blocks.core/native";
|
|
23
|
+
import { StyleSheet as __bhtStyleSheet } from "react-native";
|
|
24
|
+
var __bht0_shared = __bhtStyleSheet.create({
|
|
25
|
+
__disabledTrigger: { display: "flex", flexDirection: "row" },
|
|
26
|
+
"--sideTop__content": { marginBottom: 8 },
|
|
27
|
+
"--sideBottom__content": { marginTop: 8 },
|
|
28
|
+
"--sideLeft__content": { marginRight: 8 },
|
|
29
|
+
"--sideRight__content": { marginLeft: 8 }
|
|
30
|
+
});
|
|
31
|
+
var __bht0_light = __bhtStyleSheet.create({
|
|
32
|
+
__content: {
|
|
33
|
+
paddingTop: 4,
|
|
34
|
+
paddingRight: 8,
|
|
35
|
+
paddingBottom: 4,
|
|
36
|
+
paddingLeft: 8,
|
|
37
|
+
backgroundColor: "#303030",
|
|
38
|
+
color: "#f1f1f1",
|
|
39
|
+
borderTopLeftRadius: 4,
|
|
40
|
+
borderTopRightRadius: 4,
|
|
41
|
+
borderBottomRightRadius: 4,
|
|
42
|
+
borderBottomLeftRadius: 4,
|
|
43
|
+
fontFamily: "Inter",
|
|
44
|
+
fontSize: 12,
|
|
45
|
+
fontWeight: "400",
|
|
46
|
+
lineHeight: 16,
|
|
47
|
+
letterSpacing: 0.3996,
|
|
48
|
+
maxWidth: 256,
|
|
49
|
+
elevation: 8,
|
|
50
|
+
minWidth: 96,
|
|
51
|
+
textAlign: "center"
|
|
52
|
+
},
|
|
53
|
+
"__disabledTrigger:focusVisible": {
|
|
54
|
+
outlineWidth: 3,
|
|
55
|
+
outlineStyle: "solid",
|
|
56
|
+
outlineColor: "#615b71",
|
|
57
|
+
outlineOffset: 2
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var __bht0_dark = __bhtStyleSheet.create({
|
|
61
|
+
__content: {
|
|
62
|
+
paddingTop: 4,
|
|
63
|
+
paddingRight: 8,
|
|
64
|
+
paddingBottom: 4,
|
|
65
|
+
paddingLeft: 8,
|
|
66
|
+
backgroundColor: "#e2e2e2",
|
|
67
|
+
color: "#303030",
|
|
68
|
+
borderTopLeftRadius: 4,
|
|
69
|
+
borderTopRightRadius: 4,
|
|
70
|
+
borderBottomRightRadius: 4,
|
|
71
|
+
borderBottomLeftRadius: 4,
|
|
72
|
+
fontFamily: "Inter",
|
|
73
|
+
fontSize: 12,
|
|
74
|
+
fontWeight: "400",
|
|
75
|
+
lineHeight: 16,
|
|
76
|
+
letterSpacing: 0.3996,
|
|
77
|
+
maxWidth: 256,
|
|
78
|
+
elevation: 8,
|
|
79
|
+
minWidth: 96,
|
|
80
|
+
textAlign: "center"
|
|
81
|
+
},
|
|
82
|
+
"__disabledTrigger:focusVisible": {
|
|
83
|
+
outlineWidth: 3,
|
|
84
|
+
outlineStyle: "solid",
|
|
85
|
+
outlineColor: "#cbc3dc",
|
|
86
|
+
outlineOffset: 2
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
var tooltip = __bhtCreateNativeBlock("BHT__Tooltip", {
|
|
90
|
+
structure: {
|
|
91
|
+
children: {
|
|
92
|
+
content: {},
|
|
93
|
+
arrow: {},
|
|
94
|
+
disabledTrigger: { a11y: { role: "group" } }
|
|
95
|
+
},
|
|
96
|
+
variants: {
|
|
97
|
+
sideTop: { children: { content: {} } },
|
|
98
|
+
sideBottom: { children: { content: {} } },
|
|
99
|
+
sideLeft: { children: { content: {} } },
|
|
100
|
+
sideRight: { children: { content: {} } }
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
sheets: {
|
|
104
|
+
light: { ...__bht0_shared, ...__bht0_light },
|
|
105
|
+
dark: { ...__bht0_shared, ...__bht0_dark }
|
|
106
|
+
},
|
|
107
|
+
plan: {
|
|
108
|
+
root: [],
|
|
109
|
+
children: {
|
|
110
|
+
content: [
|
|
111
|
+
{ key: "__content" },
|
|
112
|
+
{ key: "--sideTop__content", when: { variant: "sideTop" } },
|
|
113
|
+
{ key: "--sideBottom__content", when: { variant: "sideBottom" } },
|
|
114
|
+
{ key: "--sideLeft__content", when: { variant: "sideLeft" } },
|
|
115
|
+
{ key: "--sideRight__content", when: { variant: "sideRight" } }
|
|
116
|
+
],
|
|
117
|
+
arrow: [],
|
|
118
|
+
disabledTrigger: [
|
|
119
|
+
{ key: "__disabledTrigger" },
|
|
120
|
+
{
|
|
121
|
+
key: "__disabledTrigger:focusVisible",
|
|
122
|
+
when: { state: "focusVisible" }
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// tooltip.native.tsx
|
|
130
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
131
|
+
var VISIBLE_MS = 3e3;
|
|
132
|
+
var HOLD_MS = 500;
|
|
133
|
+
var SIDE_KEYS = {
|
|
134
|
+
top: "sideTop",
|
|
135
|
+
right: "sideRight",
|
|
136
|
+
bottom: "sideBottom",
|
|
137
|
+
left: "sideLeft"
|
|
138
|
+
};
|
|
139
|
+
var pointOf = (event) => ({
|
|
140
|
+
x: event?.nativeEvent?.pageX ?? 0,
|
|
141
|
+
y: event?.nativeEvent?.pageY ?? 0,
|
|
142
|
+
width: 0,
|
|
143
|
+
height: 0
|
|
144
|
+
});
|
|
145
|
+
var Tooltip = ({
|
|
146
|
+
label,
|
|
147
|
+
side = "top",
|
|
148
|
+
children,
|
|
149
|
+
styles
|
|
150
|
+
}) => {
|
|
151
|
+
const [anchor, setAnchor] = useState();
|
|
152
|
+
const trigger = useRef(null);
|
|
153
|
+
const hold = useRef(void 0);
|
|
154
|
+
const shownAt = useRef(Number.NEGATIVE_INFINITY);
|
|
155
|
+
const [, childProps] = useBlock(
|
|
156
|
+
tooltip,
|
|
157
|
+
{ [SIDE_KEYS[side]]: true },
|
|
158
|
+
{ styles }
|
|
159
|
+
);
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
let hide;
|
|
162
|
+
if (anchor) {
|
|
163
|
+
hide = setTimeout(() => setAnchor(void 0), VISIBLE_MS);
|
|
164
|
+
}
|
|
165
|
+
return () => clearTimeout(hide);
|
|
166
|
+
}, [anchor]);
|
|
167
|
+
useEffect(() => () => clearTimeout(hold.current), []);
|
|
168
|
+
const show = (touch) => {
|
|
169
|
+
const now = Date.now();
|
|
170
|
+
const node = trigger.current;
|
|
171
|
+
if (now - shownAt.current >= HOLD_MS) {
|
|
172
|
+
shownAt.current = now;
|
|
173
|
+
if (Platform.OS === "ios") {
|
|
174
|
+
AccessibilityInfo.announceForAccessibility(label);
|
|
175
|
+
}
|
|
176
|
+
setAnchor(touch);
|
|
177
|
+
node?.measureInWindow?.((x, y, width, height) => {
|
|
178
|
+
if (width > 0 && height > 0) {
|
|
179
|
+
setAnchor({ x, y, width, height });
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
const release = () => clearTimeout(hold.current);
|
|
185
|
+
const child = isValidElement(children) ? children : void 0;
|
|
186
|
+
const own = child?.props;
|
|
187
|
+
const Trigger = child?.type;
|
|
188
|
+
const ownRef = own?.ref;
|
|
189
|
+
const setTrigger = useCallback(
|
|
190
|
+
(node) => {
|
|
191
|
+
trigger.current = node;
|
|
192
|
+
const cleanup = assignRef(ownRef, node);
|
|
193
|
+
return () => {
|
|
194
|
+
trigger.current = null;
|
|
195
|
+
if (cleanup) {
|
|
196
|
+
cleanup();
|
|
197
|
+
} else {
|
|
198
|
+
assignRef(ownRef, null);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
[ownRef]
|
|
203
|
+
);
|
|
204
|
+
const startHold = (event) => {
|
|
205
|
+
const touch = pointOf(event);
|
|
206
|
+
own?.onResponderGrant?.(event);
|
|
207
|
+
clearTimeout(hold.current);
|
|
208
|
+
hold.current = setTimeout(() => show(touch), HOLD_MS);
|
|
209
|
+
};
|
|
210
|
+
let element = children;
|
|
211
|
+
if (own?.disabled === true) {
|
|
212
|
+
element = /* @__PURE__ */ jsx(
|
|
213
|
+
Pressable,
|
|
214
|
+
{
|
|
215
|
+
...childProps("disabledTrigger"),
|
|
216
|
+
ref: (node) => {
|
|
217
|
+
trigger.current = node;
|
|
218
|
+
},
|
|
219
|
+
accessibilityHint: label,
|
|
220
|
+
onLongPress: (event) => show(pointOf(event)),
|
|
221
|
+
children
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
} else if (own !== void 0 && Trigger !== void 0) {
|
|
225
|
+
element = /* @__PURE__ */ jsx(
|
|
226
|
+
Trigger,
|
|
227
|
+
{
|
|
228
|
+
...own,
|
|
229
|
+
ref: setTrigger,
|
|
230
|
+
accessibilityHint: own.accessibilityHint ?? label,
|
|
231
|
+
onLongPress: (event) => {
|
|
232
|
+
own.onLongPress?.(event);
|
|
233
|
+
show(pointOf(event));
|
|
234
|
+
},
|
|
235
|
+
onStartShouldSetResponder: (event) => own.onStartShouldSetResponder?.(event) ?? true,
|
|
236
|
+
onResponderGrant: startHold,
|
|
237
|
+
onResponderRelease: (event) => {
|
|
238
|
+
own.onResponderRelease?.(event);
|
|
239
|
+
release();
|
|
240
|
+
},
|
|
241
|
+
onResponderTerminate: (event) => {
|
|
242
|
+
own.onResponderTerminate?.(event);
|
|
243
|
+
release();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
249
|
+
element,
|
|
250
|
+
anchor && /* @__PURE__ */ jsx(OverlayPortal, { anchor: { ...anchor, side }, children: /* @__PURE__ */ jsx(
|
|
251
|
+
Text,
|
|
252
|
+
{
|
|
253
|
+
...childProps("content"),
|
|
254
|
+
role: "tooltip",
|
|
255
|
+
accessibilityLiveRegion: "polite",
|
|
256
|
+
children: label
|
|
257
|
+
}
|
|
258
|
+
) })
|
|
259
|
+
] });
|
|
260
|
+
};
|
|
261
|
+
export {
|
|
262
|
+
Tooltip
|
|
263
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export declare const tooltip: import("@behivetech/blocks.core").Block<"BHT__Tooltip", {
|
|
2
|
+
readonly children: {
|
|
3
|
+
readonly content: {
|
|
4
|
+
readonly padding: readonly [import("@behivetech/blocks.core").Token<"length">, import("@behivetech/blocks.core").Token<"length">];
|
|
5
|
+
readonly backgroundColor: import("@behivetech/blocks.core").Token<"color">;
|
|
6
|
+
readonly color: import("@behivetech/blocks.core").Token<"color">;
|
|
7
|
+
readonly borderRadius: import("@behivetech/blocks.core").Token<"length">;
|
|
8
|
+
readonly fontFamily: import("@behivetech/blocks.core").Token<"font">;
|
|
9
|
+
readonly fontSize: import("@behivetech/blocks.core").Token<"length">;
|
|
10
|
+
readonly fontWeight: import("@behivetech/blocks.core").Token<"weight">;
|
|
11
|
+
readonly lineHeight: import("@behivetech/blocks.core").Token<"length">;
|
|
12
|
+
readonly letterSpacing: import("@behivetech/blocks.core").Token<"tracking">;
|
|
13
|
+
readonly maxWidth: "16rem";
|
|
14
|
+
readonly web: {
|
|
15
|
+
readonly zIndex: "var(--z-tooltip, 600)";
|
|
16
|
+
readonly userSelect: "none";
|
|
17
|
+
readonly "&[data-state=delayed-open]": {
|
|
18
|
+
readonly animation: import("@behivetech/blocks.core").CssValue;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
readonly native: {
|
|
22
|
+
readonly elevation: 8;
|
|
23
|
+
readonly minWidth: "6rem";
|
|
24
|
+
readonly textAlign: "center";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
readonly arrow: {
|
|
28
|
+
readonly web: {
|
|
29
|
+
readonly fill: import("@behivetech/blocks.core").Token<"color">;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
readonly disabledTrigger: {
|
|
33
|
+
readonly a11y: {
|
|
34
|
+
readonly role: "group";
|
|
35
|
+
};
|
|
36
|
+
readonly display: "inline-flex";
|
|
37
|
+
readonly states: {
|
|
38
|
+
readonly focusVisible: {
|
|
39
|
+
readonly outlineWidth: 3;
|
|
40
|
+
readonly outlineStyle: "solid";
|
|
41
|
+
readonly outlineColor: import("@behivetech/blocks.core").Token<"color">;
|
|
42
|
+
readonly outlineOffset: 2;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
readonly web: {
|
|
46
|
+
readonly "& > *": {
|
|
47
|
+
readonly pointerEvents: "none";
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
readonly variants: {
|
|
53
|
+
readonly sideTop: {
|
|
54
|
+
readonly children: {
|
|
55
|
+
readonly content: {
|
|
56
|
+
readonly native: {
|
|
57
|
+
readonly marginBottom: import("@behivetech/blocks.core").Token<"length">;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
readonly sideBottom: {
|
|
63
|
+
readonly children: {
|
|
64
|
+
readonly content: {
|
|
65
|
+
readonly native: {
|
|
66
|
+
readonly marginTop: import("@behivetech/blocks.core").Token<"length">;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
readonly sideLeft: {
|
|
72
|
+
readonly children: {
|
|
73
|
+
readonly content: {
|
|
74
|
+
readonly native: {
|
|
75
|
+
readonly marginRight: import("@behivetech/blocks.core").Token<"length">;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
readonly sideRight: {
|
|
81
|
+
readonly children: {
|
|
82
|
+
readonly content: {
|
|
83
|
+
readonly native: {
|
|
84
|
+
readonly marginLeft: import("@behivetech/blocks.core").Token<"length">;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
readonly web: {
|
|
91
|
+
readonly "@keyframes tooltip-in": {
|
|
92
|
+
readonly from: {
|
|
93
|
+
readonly opacity: 0;
|
|
94
|
+
};
|
|
95
|
+
readonly to: {
|
|
96
|
+
readonly opacity: 1;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { type StylesFor } from "@behivetech/blocks.core";
|
|
3
|
+
import { tooltip } from "./tooltip.block.native";
|
|
4
|
+
export type TooltipSide = "top" | "right" | "bottom" | "left";
|
|
5
|
+
export interface TooltipProps {
|
|
6
|
+
/** Text shown in the tooltip. This is the control's name when the trigger is icon-only. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Which side of the trigger to place the tooltip on; defaults to "top" */
|
|
9
|
+
side?: TooltipSide;
|
|
10
|
+
/** The element the tooltip describes — rendered as-is via Radix's `asChild` */
|
|
11
|
+
children: ReactElement;
|
|
12
|
+
/** Additional class names to merge with the tooltip content element */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles. */
|
|
15
|
+
styles?: StylesFor<typeof tooltip>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Names a control on hover and on keyboard focus, built on Radix's `Tooltip`.
|
|
19
|
+
*
|
|
20
|
+
* Mounts its own `Tooltip.Provider`, so a caller never has to add one.
|
|
21
|
+
*
|
|
22
|
+
* Works on a disabled trigger, which a bare Radix tooltip does not: a disabled
|
|
23
|
+
* element fires no pointer events, so the trigger never sees hover or focus.
|
|
24
|
+
* When the child is disabled it is wrapped in a focusable span that carries the
|
|
25
|
+
* listeners instead, and the child is made pointer-transparent so hover lands
|
|
26
|
+
* on the wrapper. That keeps the explanation reachable at the one moment it
|
|
27
|
+
* matters most — when the control is unavailable and the user wants to know
|
|
28
|
+
* why — including by keyboard, since a disabled control is not focusable.
|
|
29
|
+
*/
|
|
30
|
+
export declare const Tooltip: ({ label, side, children, className, styles, }: TooltipProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type StylesFor } from "@behivetech/blocks.core/native";
|
|
2
|
+
import { type ReactElement } from "react";
|
|
3
|
+
import { tooltip } from "./tooltip.block.native";
|
|
4
|
+
import type { TooltipSide } from "./tooltip";
|
|
5
|
+
export type { TooltipSide } from "./tooltip";
|
|
6
|
+
export interface TooltipProps {
|
|
7
|
+
/** Text shown in the tooltip. It is also announced as the trigger's hint, so an icon-only control still needs its own `accessibilityLabel` */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Which side of the trigger to place the tooltip on; defaults to "top" */
|
|
10
|
+
side?: TooltipSide;
|
|
11
|
+
/** The element the tooltip describes, rendered as it is: it is given `onLongPress`, which shows the tooltip after its own, and a `ref`, which is how the tooltip finds it on screen */
|
|
12
|
+
children: ReactElement;
|
|
13
|
+
/** An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles. */
|
|
14
|
+
styles?: StylesFor<typeof tooltip>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The React Native renderer of Tooltip: the same block, with the same `label` and `side` props. There is no
|
|
18
|
+
* hover on a phone, so the tooltip shows on a long press of the trigger, for a few seconds, and a screen
|
|
19
|
+
* reader hears it as the trigger's hint and when it appears. There is no `className`, so restyle it with
|
|
20
|
+
* `styles`; it has no arrow and no animation.
|
|
21
|
+
*
|
|
22
|
+
* The trigger is your own element, with no wrapper around it, so its layout is what it is without the
|
|
23
|
+
* tooltip: it is given `onLongPress` (a `Pressable`, a `Text` and the registry's controls take it), the
|
|
24
|
+
* responder handlers that time the hold for an element that does not (a `View`, an `Avatar`), and a `ref`.
|
|
25
|
+
* A disabled trigger is the one exception: it is wrapped in a group that takes the long press for it.
|
|
26
|
+
*
|
|
27
|
+
* The tooltip is drawn in the app's `OverlayHost` (`@behivetech/blocks.core/native`), above everything else in
|
|
28
|
+
* the window, against the side of the trigger: no ancestor clips it and no sibling paints over it. Above and
|
|
29
|
+
* below, it is level with the trigger's start edge, or with its end edge when that leaves it more room (a
|
|
30
|
+
* control in the far corner of the screen), and a long label wraps before it reaches the edge of the screen;
|
|
31
|
+
* it does not move to another side when the one asked for has no room. Inside a dialog it is drawn in the
|
|
32
|
+
* dialog's own layer. An app that mounts no `OverlayHost` shows no tooltip (development says so); the hint and
|
|
33
|
+
* the announcement still reach a screen reader.
|
|
34
|
+
*/
|
|
35
|
+
export declare const Tooltip: ({ label, side, children, styles, }: TooltipProps) => import("react").JSX.Element;
|
package/docs.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
|
|
3
3
|
"version": 2,
|
|
4
|
-
"generatedAt": "2026-11-
|
|
4
|
+
"generatedAt": "2026-11-26T05:23:46.091Z",
|
|
5
5
|
"docs": [
|
|
6
6
|
{
|
|
7
7
|
"displayName": "Tooltip",
|
|
@@ -35,6 +35,13 @@
|
|
|
35
35
|
"required": false,
|
|
36
36
|
"defaultValue": "top",
|
|
37
37
|
"description": "Which side of the trigger to place the tooltip on; defaults to \"top\""
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "styles",
|
|
41
|
+
"type": "StylesFor<Block<\"BHT__Tooltip\", { readonly children: { readonly content: { readonly padding: readonly [Token<\"length\">, Token<\"length\">]; readonly backgroundColor: Token<\"color\">; readonly color: Token<\"color\">; ... 8 more ...; readonly native: { ...; }; }; readonly arrow: { ...; }; readonly disabledTrigger: { ...; ...",
|
|
42
|
+
"required": false,
|
|
43
|
+
"defaultValue": null,
|
|
44
|
+
"description": "An override block made with `defineBlock`, typed to this component's children and variants; it wins over the block's own styles."
|
|
38
45
|
}
|
|
39
46
|
]
|
|
40
47
|
}
|
package/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Tooltip } from "./tooltip
|
|
2
|
-
export type { TooltipProps, TooltipSide } from "./tooltip
|
|
1
|
+
export { Tooltip } from "./tooltip";
|
|
2
|
+
export type { TooltipProps, TooltipSide } from "./tooltip";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behivetech/atoms.tooltip",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Names a control on hover and on keyboard focus, built on [`@radix-ui/react-tooltip`](https://www.radix-ui.com/primitives/docs/components/tooltip).",
|
|
6
6
|
"type": "module",
|
|
@@ -10,18 +10,26 @@
|
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"react-native": {
|
|
14
|
+
"types": "./dist/native/index.d.ts",
|
|
15
|
+
"default": "./dist/index.native.js"
|
|
16
|
+
},
|
|
13
17
|
"types": "./dist/index.d.ts",
|
|
14
18
|
"import": "./dist/index.js",
|
|
15
19
|
"require": "./dist/index.cjs"
|
|
16
20
|
},
|
|
17
21
|
"./styles.css": "./dist/index.css"
|
|
18
22
|
},
|
|
23
|
+
"react-native": "./dist/index.native.js",
|
|
19
24
|
"files": [
|
|
20
25
|
"dist",
|
|
21
26
|
"README.md",
|
|
22
27
|
"index.ts",
|
|
23
28
|
"tooltip.tsx",
|
|
24
|
-
"tooltip.
|
|
29
|
+
"tooltip.native.tsx",
|
|
30
|
+
"tooltip.block.ts",
|
|
31
|
+
"tooltip.block.css",
|
|
32
|
+
"tooltip.block.native.ts",
|
|
25
33
|
"*.example.tsx",
|
|
26
34
|
"docs.json"
|
|
27
35
|
],
|
|
@@ -30,18 +38,28 @@
|
|
|
30
38
|
"tags": []
|
|
31
39
|
},
|
|
32
40
|
"dependencies": {
|
|
33
|
-
"@behivetech/
|
|
41
|
+
"@behivetech/blocks.core": "0.1.0",
|
|
34
42
|
"@radix-ui/react-tooltip": "^1.4.1"
|
|
35
43
|
},
|
|
36
44
|
"peerDependencies": {
|
|
37
45
|
"react": "^19.2.7",
|
|
38
|
-
"react-dom": "^19.2.7"
|
|
46
|
+
"react-dom": "^19.2.7",
|
|
47
|
+
"react-native": "*"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"react-native": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
39
53
|
},
|
|
40
54
|
"devDependencies": {
|
|
41
|
-
"@
|
|
55
|
+
"@behivetech/blocks.builder": "0.1.0",
|
|
56
|
+
"@behivetech/blocks.native-test": "0.0.1",
|
|
57
|
+
"@bht-component-registry/env": "0.3.0",
|
|
42
58
|
"@types/react": "19.2.17",
|
|
43
59
|
"@types/react-dom": "19.2.3",
|
|
44
60
|
"eslint": "^9.39.5",
|
|
61
|
+
"react": "19.2.8",
|
|
62
|
+
"react-dom": "19.2.8",
|
|
45
63
|
"tsup": "^8.5.1",
|
|
46
64
|
"typescript": "^6.0.3",
|
|
47
65
|
"vitest": "^4.1.10"
|
|
@@ -49,15 +67,18 @@
|
|
|
49
67
|
"repository": {
|
|
50
68
|
"type": "git",
|
|
51
69
|
"url": "https://github.com/behivetech/bht-galaxy.git",
|
|
52
|
-
"directory": "
|
|
70
|
+
"directory": "packages/atoms/tooltip"
|
|
53
71
|
},
|
|
54
72
|
"homepage": "https://platform.behivetech.com/behivetech/atoms/tooltip",
|
|
55
73
|
"publishConfig": {
|
|
56
74
|
"registry": "https://registry.npmjs.org",
|
|
57
75
|
"access": "public"
|
|
58
76
|
},
|
|
77
|
+
"blocks": {
|
|
78
|
+
"native": true
|
|
79
|
+
},
|
|
59
80
|
"scripts": {
|
|
60
|
-
"build": "tsup && bht-registry-docgen",
|
|
81
|
+
"build": "block check && tsup && bht-registry-docgen",
|
|
61
82
|
"dev": "tsup --watch",
|
|
62
83
|
"lint": "eslint . --max-warnings 0",
|
|
63
84
|
"check-types": "tsc --noEmit",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* GENERATED from tooltip.block.ts by @behivetech/blocks.builder. Do not edit by hand: run `pnpm block:build`. */
|
|
2
|
+
|
|
3
|
+
@layer bht {
|
|
4
|
+
.BHT__Tooltip__content {
|
|
5
|
+
padding: var(--spacing-1, 0.25rem) var(--spacing-2, 0.5rem);
|
|
6
|
+
background-color: var(--md-sys-color-inverse-surface, #303030);
|
|
7
|
+
color: var(--md-sys-color-inverse-on-surface, #f1f1f1);
|
|
8
|
+
border-radius: var(--md-sys-shape-corner-extra-small, 4px);
|
|
9
|
+
font-family: var(
|
|
10
|
+
--md-sys-typescale-body-small-font,
|
|
11
|
+
"Inter",
|
|
12
|
+
system-ui,
|
|
13
|
+
-apple-system,
|
|
14
|
+
sans-serif
|
|
15
|
+
);
|
|
16
|
+
font-size: var(--md-sys-typescale-body-small-size, 0.75rem);
|
|
17
|
+
font-weight: var(--md-sys-typescale-body-small-weight, 400);
|
|
18
|
+
line-height: var(--md-sys-typescale-body-small-line-height, 1rem);
|
|
19
|
+
letter-spacing: var(--md-sys-typescale-body-small-tracking, 0.0333em);
|
|
20
|
+
max-width: 16rem;
|
|
21
|
+
z-index: var(--z-tooltip, 600);
|
|
22
|
+
user-select: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.BHT__Tooltip__content[data-state="delayed-open"] {
|
|
26
|
+
animation: tooltip-in var(--md-sys-motion-duration-short-3, 150ms)
|
|
27
|
+
var(--md-sys-motion-easing-standard-decelerate, cubic-bezier(0, 0, 0, 1));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.BHT__Tooltip__arrow {
|
|
31
|
+
fill: var(--md-sys-color-inverse-surface, #303030);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.BHT__Tooltip__disabled-trigger {
|
|
35
|
+
display: inline-flex;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.BHT__Tooltip__disabled-trigger:focus-visible {
|
|
39
|
+
outline-width: 3px;
|
|
40
|
+
outline-style: solid;
|
|
41
|
+
outline-color: var(--md-sys-color-secondary, #615b71);
|
|
42
|
+
outline-offset: 2px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.BHT__Tooltip__disabled-trigger > * {
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@keyframes tooltip-in {
|
|
50
|
+
from {
|
|
51
|
+
opacity: 0;
|
|
52
|
+
}
|
|
53
|
+
to {
|
|
54
|
+
opacity: 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|