@mlola-ui/registry 1.0.12 → 1.0.13
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/components/accordion.json +2 -2
- package/components/alert.json +1 -1
- package/components/app-shell.json +1 -1
- package/components/badge.json +1 -1
- package/components/breadcrumb.json +1 -1
- package/components/button.json +1 -1
- package/components/calendar.json +1 -1
- package/components/carousel.json +2 -2
- package/components/checkbox.json +1 -1
- package/components/color-picker.json +1 -1
- package/components/combobox.json +1 -1
- package/components/command-menu.json +1 -1
- package/components/context-menu.json +3 -3
- package/components/copy-button.json +1 -1
- package/components/date-picker.json +1 -1
- package/components/dropdown-menu.json +2 -2
- package/components/dropzone.json +1 -1
- package/components/hover-card.json +2 -2
- package/components/modal.json +2 -2
- package/components/number-input.json +1 -1
- package/components/pagination.json +1 -1
- package/components/password-input.json +2 -2
- package/components/popover.json +2 -2
- package/components/segmented-control.json +1 -1
- package/components/select.json +3 -3
- package/components/sheet.json +2 -2
- package/components/slider.json +1 -1
- package/components/stepper.json +1 -1
- package/components/tabs.json +1 -1
- package/components/tag-input.json +1 -1
- package/components/time-picker.json +1 -1
- package/components/timeline.json +1 -1
- package/components/toast.json +1 -1
- package/components/tooltip.json +10 -2
- package/components/tour.json +3 -3
- package/generated/catalog.js +51 -44
- package/index.json +1 -1
- package/package.json +1 -1
- package/snapshot/index.json +59 -51
- package/snapshot/items/components/accordion.json +2 -2
- package/snapshot/items/components/alert.json +1 -1
- package/snapshot/items/components/app-shell.json +1 -1
- package/snapshot/items/components/badge.json +1 -1
- package/snapshot/items/components/breadcrumb.json +1 -1
- package/snapshot/items/components/button.json +1 -1
- package/snapshot/items/components/calendar.json +1 -1
- package/snapshot/items/components/carousel.json +2 -2
- package/snapshot/items/components/checkbox.json +1 -1
- package/snapshot/items/components/color-picker.json +1 -1
- package/snapshot/items/components/combobox.json +1 -1
- package/snapshot/items/components/command-menu.json +1 -1
- package/snapshot/items/components/context-menu.json +3 -3
- package/snapshot/items/components/copy-button.json +1 -1
- package/snapshot/items/components/date-picker.json +1 -1
- package/snapshot/items/components/dropdown-menu.json +2 -2
- package/snapshot/items/components/dropzone.json +1 -1
- package/snapshot/items/components/hover-card.json +2 -2
- package/snapshot/items/components/modal.json +2 -2
- package/snapshot/items/components/number-input.json +1 -1
- package/snapshot/items/components/pagination.json +1 -1
- package/snapshot/items/components/password-input.json +2 -2
- package/snapshot/items/components/popover.json +2 -2
- package/snapshot/items/components/segmented-control.json +1 -1
- package/snapshot/items/components/select.json +3 -3
- package/snapshot/items/components/sheet.json +2 -2
- package/snapshot/items/components/slider.json +1 -1
- package/snapshot/items/components/stepper.json +1 -1
- package/snapshot/items/components/tabs.json +1 -1
- package/snapshot/items/components/tag-input.json +1 -1
- package/snapshot/items/components/time-picker.json +1 -1
- package/snapshot/items/components/timeline.json +1 -1
- package/snapshot/items/components/toast.json +1 -1
- package/snapshot/items/components/tooltip.json +10 -2
- package/snapshot/items/components/tour.json +3 -3
- package/snapshot/source/packages/components/_internal/anchor.ts +1 -1
- package/snapshot/source/packages/components/tooltip/tooltip.tsx +26 -2
- package/snapshot/source-manifest.json +2 -2
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"registryDependencies": [],
|
|
20
20
|
"engineDependencies": {
|
|
21
|
-
"@mlola-ui/behavior": "^1.0.
|
|
22
|
-
"@mlola-ui/icons": "^1.0.
|
|
21
|
+
"@mlola-ui/behavior": "^1.0.13",
|
|
22
|
+
"@mlola-ui/icons": "^1.0.13"
|
|
23
23
|
},
|
|
24
24
|
"options": [
|
|
25
25
|
{
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"path": "packages/components/_internal/anchor.ts",
|
|
44
44
|
"target": "{{aliases.components}}/_internal/anchor.ts",
|
|
45
45
|
"type": "registry:ui",
|
|
46
|
-
"integrity": "sha256
|
|
46
|
+
"integrity": "sha256-/yW3RVjoY6QfTWnUYSeZ9rFkC9W4WGB1qop8Jp/H1r8="
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"path": "packages/components/_internal/floating.ts",
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"isDefault": false
|
|
24
24
|
},
|
|
25
25
|
"registryDependencies": [],
|
|
26
|
-
"engineDependencies": {
|
|
26
|
+
"engineDependencies": {
|
|
27
|
+
"@mlola-ui/behavior": "^1.0.13"
|
|
28
|
+
},
|
|
27
29
|
"options": [
|
|
28
30
|
{
|
|
29
31
|
"component": "Tooltip",
|
|
@@ -40,6 +42,12 @@
|
|
|
40
42
|
"variants": [],
|
|
41
43
|
"sizes": [],
|
|
42
44
|
"files": [
|
|
45
|
+
{
|
|
46
|
+
"path": "packages/components/_internal/anchor.ts",
|
|
47
|
+
"target": "{{aliases.components}}/_internal/anchor.ts",
|
|
48
|
+
"type": "registry:ui",
|
|
49
|
+
"integrity": "sha256-/yW3RVjoY6QfTWnUYSeZ9rFkC9W4WGB1qop8Jp/H1r8="
|
|
50
|
+
},
|
|
43
51
|
{
|
|
44
52
|
"path": "packages/components/_internal/react.ts",
|
|
45
53
|
"target": "{{aliases.components}}/_internal/react.ts",
|
|
@@ -50,7 +58,7 @@
|
|
|
50
58
|
"path": "packages/components/tooltip/tooltip.tsx",
|
|
51
59
|
"target": "{{aliases.components}}/tooltip.tsx",
|
|
52
60
|
"type": "registry:ui",
|
|
53
|
-
"integrity": "sha256-
|
|
61
|
+
"integrity": "sha256-hplqwWF/ZqQQ9oyoErrOA3VjkRCDCbqwt5xgZOdsFcA="
|
|
54
62
|
}
|
|
55
63
|
],
|
|
56
64
|
"themeContract": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"registryDependencies": [],
|
|
22
22
|
"engineDependencies": {
|
|
23
|
-
"@mlola-ui/behavior": "^1.0.
|
|
24
|
-
"@mlola-ui/icons": "^1.0.
|
|
23
|
+
"@mlola-ui/behavior": "^1.0.13",
|
|
24
|
+
"@mlola-ui/icons": "^1.0.13"
|
|
25
25
|
},
|
|
26
26
|
"options": [],
|
|
27
27
|
"variants": [],
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"path": "packages/components/_internal/anchor.ts",
|
|
32
32
|
"target": "{{aliases.components}}/_internal/anchor.ts",
|
|
33
33
|
"type": "registry:ui",
|
|
34
|
-
"integrity": "sha256
|
|
34
|
+
"integrity": "sha256-/yW3RVjoY6QfTWnUYSeZ9rFkC9W4WGB1qop8Jp/H1r8="
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
"path": "packages/components/_internal/floating.ts",
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* Where a floating layer goes next to its anchor. The math is shared with the
|
|
3
3
|
* framework-free runtime, so it lives in @mlola-ui/behavior/logic.
|
|
4
4
|
*/
|
|
5
|
-
export { placeFloating, type Align, type Placement, type Rect, type Side } from "@mlola-ui/behavior/logic";
|
|
5
|
+
export { fitTooltip, placeFloating, type Align, type Placement, type Rect, type Side } from "@mlola-ui/behavior/logic";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { fitTooltip, type Side } from "../_internal/anchor";
|
|
4
5
|
import { cx } from "../_internal/react";
|
|
5
6
|
|
|
6
7
|
export type TooltipPlacement = "top" | "bottom" | "left" | "right";
|
|
@@ -14,6 +15,10 @@ interface TooltipProps {
|
|
|
14
15
|
|
|
15
16
|
function Tooltip({ content, placement = "top", delay = 200, children, className }: TooltipProps) {
|
|
16
17
|
const [open, setOpen] = React.useState(false);
|
|
18
|
+
// Where it actually opens: the asked side, flipped or slid to stay on screen.
|
|
19
|
+
const [fit, setFit] = React.useState<{ side: Side; shift: number }>({ side: placement, shift: 0 });
|
|
20
|
+
const root = React.useRef<HTMLSpanElement>(null);
|
|
21
|
+
const tip = React.useRef<HTMLSpanElement>(null);
|
|
17
22
|
const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
18
23
|
const id = React.useId();
|
|
19
24
|
const clear = () => {
|
|
@@ -29,6 +34,17 @@ function Tooltip({ content, placement = "top", delay = 200, children, className
|
|
|
29
34
|
setOpen(false);
|
|
30
35
|
};
|
|
31
36
|
React.useEffect(() => clear, []);
|
|
37
|
+
React.useLayoutEffect(() => {
|
|
38
|
+
const anchor = root.current?.firstElementChild ?? root.current;
|
|
39
|
+
if (!open || !anchor || !tip.current) {
|
|
40
|
+
setFit({ side: placement, shift: 0 });
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const a = anchor.getBoundingClientRect();
|
|
44
|
+
// Layout size, not the painted box: the pop-in animation starts scaled down.
|
|
45
|
+
const t = { width: tip.current.offsetWidth, height: tip.current.offsetHeight };
|
|
46
|
+
setFit(fitTooltip({ x: a.left, y: a.top, width: a.width, height: a.height }, t, { width: document.documentElement.clientWidth, height: window.innerHeight }, placement));
|
|
47
|
+
}, [open, placement]);
|
|
32
48
|
React.useEffect(() => {
|
|
33
49
|
if (!open) return;
|
|
34
50
|
const onKeyDown = (event: KeyboardEvent) => {
|
|
@@ -55,10 +71,18 @@ function Tooltip({ content, placement = "top", delay = 200, children, className
|
|
|
55
71
|
: childProps["aria-describedby"],
|
|
56
72
|
} as Record<string, unknown>);
|
|
57
73
|
return (
|
|
58
|
-
<span className="ml-tooltip-root" onMouseEnter={clear} onMouseLeave={hide}>
|
|
74
|
+
<span ref={root} className="ml-tooltip-root" onMouseEnter={clear} onMouseLeave={hide}>
|
|
59
75
|
{trigger}
|
|
60
76
|
{open ? (
|
|
61
|
-
<span
|
|
77
|
+
<span
|
|
78
|
+
ref={tip}
|
|
79
|
+
id={id}
|
|
80
|
+
role="tooltip"
|
|
81
|
+
data-side={fit.side}
|
|
82
|
+
data-state="open"
|
|
83
|
+
className={cx("ml-tooltip", className)}
|
|
84
|
+
style={{ "--ml-tooltip-shift": `${fit.shift}px` } as React.CSSProperties}
|
|
85
|
+
>
|
|
62
86
|
{content}
|
|
63
87
|
<span aria-hidden="true" className="ml-tooltip-arrow" />
|
|
64
88
|
</span>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"packages/components/_internal/anchor.ts": "sha256
|
|
2
|
+
"packages/components/_internal/anchor.ts": "sha256-/yW3RVjoY6QfTWnUYSeZ9rFkC9W4WGB1qop8Jp/H1r8=",
|
|
3
3
|
"packages/components/_internal/clipboard.ts": "sha256-0y5p88CTXWuOrUYlC5J4XP1VCrOwkx9jYWVHmD2LouQ=",
|
|
4
4
|
"packages/components/_internal/dialog.ts": "sha256-796y3oNOVWarLvICTdi+d0/2axqSrzLVJiyBeh9X7bU=",
|
|
5
5
|
"packages/components/_internal/floating.ts": "sha256-+WxgC4CtAlSr2qA1EkoDTgto535XLIPsvtOfdOK6CHk=",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"packages/components/timeline/timeline.tsx": "sha256-nVg7lBcAUAzqEb0YrHagJXSaHE2aWWE9bUbQMWQY6PU=",
|
|
65
65
|
"packages/components/toast/toast.tsx": "sha256-f0DwN0XuV46fSsQf3i9RJcfQbAs2mSz7A8UJoIIICHg=",
|
|
66
66
|
"packages/components/toggle/toggle.tsx": "sha256-8qPHeSliHNdzQS7OLJ47BrvRR75MYyUGJlK4s21XS/U=",
|
|
67
|
-
"packages/components/tooltip/tooltip.tsx": "sha256-
|
|
67
|
+
"packages/components/tooltip/tooltip.tsx": "sha256-hplqwWF/ZqQQ9oyoErrOA3VjkRCDCbqwt5xgZOdsFcA=",
|
|
68
68
|
"packages/components/tour/tour.tsx": "sha256-mrAE8aVDBVIibGvQah9Gh3mzIiWDFxB6aObzqFo5xXU=",
|
|
69
69
|
"packages/components/virtual-list/virtual-list.tsx": "sha256-raGEFn4HlAOIohqZcy0DgptsnUIPS/6bWLYeTe+M9E8=",
|
|
70
70
|
"packages/components/virtual-list/virtual.ts": "sha256-PyDIj3C2Vwb1i4ZssxSlYjgKmZPBIFLZFNq8YCW2Z78="
|