@glasshome/ui 1.33.1 → 1.34.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/dist/lib/shadow-layer.d.ts +45 -0
- package/dist/solid/context-menu.d.ts +1 -20
- package/dist/solid/index.d.ts +1 -0
- package/dist/solid/index.js +3298 -2969
- package/dist/solid/media-store.d.ts +2 -1
- package/dist/solid/portal-mount.d.ts +7 -0
- package/package.json +5 -4
- package/scripts/check-gallery.ts +1 -1
- package/src/lib/shadow-layer.ts +136 -0
- package/src/solid/alert-dialog.tsx +39 -6
- package/src/solid/bottom-sheet/bottom-sheet.tsx +37 -16
- package/src/solid/bottom-sheet/focus-trap.ts +8 -5
- package/src/solid/context-menu.tsx +42 -4
- package/src/solid/dialog.tsx +20 -4
- package/src/solid/docked-panel.tsx +2 -1
- package/src/solid/dropdown-menu.tsx +45 -7
- package/src/solid/hover-card.tsx +13 -3
- package/src/solid/index.ts +1 -0
- package/src/solid/media-store.ts +4 -2
- package/src/solid/menu-parts.tsx +40 -2
- package/src/solid/popover.tsx +29 -3
- package/src/solid/portal-mount.ts +10 -0
- package/src/solid/select.tsx +34 -4
- package/src/solid/sheet.tsx +33 -5
- package/src/solid/spotlight.tsx +2 -1
- package/src/solid/tooltip.tsx +13 -3
package/src/solid/hover-card.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { HoverCard as HoverCardPrimitive } from "@kobalte/core/hover-card";
|
|
2
|
-
import {
|
|
2
|
+
import { usePortalMount } from "./portal-mount.js";
|
|
3
|
+
import { type Component, type ComponentProps, createSignal, splitProps } from "solid-js";
|
|
3
4
|
import { OVERLAY_MOTION } from "../lib/motion-classes.js";
|
|
5
|
+
import { shadowLayer } from "../lib/shadow-layer.js";
|
|
4
6
|
import { FLOATING_PANEL } from "../lib/overlay-classes.js";
|
|
5
7
|
import { cn } from "../lib/utils.js";
|
|
6
8
|
|
|
@@ -11,10 +13,18 @@ const HoverCardTrigger: Component<ComponentProps<typeof HoverCardPrimitive.Trigg
|
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
const HoverCardContent: Component<ComponentProps<typeof HoverCardPrimitive.Content>> = (props) => {
|
|
14
|
-
const [local, rest] = splitProps(props, ["class"]);
|
|
16
|
+
const [local, rest] = splitProps(props, ["class", "ref", "onInteractOutside"]);
|
|
17
|
+
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
18
|
+
// A hover card closes as the pointer leaves; inside a shadow root it only must not close on its own presses.
|
|
19
|
+
const { onInteractOutside } = shadowLayer({ content: panel, open: () => true, consumer: local });
|
|
15
20
|
return (
|
|
16
|
-
<HoverCardPrimitive.Portal data-slot="hover-card-portal">
|
|
21
|
+
<HoverCardPrimitive.Portal data-slot="hover-card-portal" mount={usePortalMount()}>
|
|
17
22
|
<HoverCardPrimitive.Content
|
|
23
|
+
ref={(el: HTMLElement) => {
|
|
24
|
+
setPanel(el);
|
|
25
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
26
|
+
}}
|
|
27
|
+
onInteractOutside={onInteractOutside}
|
|
18
28
|
data-slot="hover-card-content"
|
|
19
29
|
class={cn(FLOATING_PANEL, OVERLAY_MOTION, "w-64 p-4", local.class)}
|
|
20
30
|
{...rest}
|
package/src/solid/index.ts
CHANGED
|
@@ -298,6 +298,7 @@ export { PICKER_ROW_HEIGHT, PickerRow } from "./picker-row.js";
|
|
|
298
298
|
export { PickerSearch, type PickerSearchProps } from "./picker-search.js";
|
|
299
299
|
export { PickerTrigger, type PickerTriggerProps } from "./picker-trigger.js";
|
|
300
300
|
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
301
|
+
export { PortalMountContext, usePortalMount } from "./portal-mount.js";
|
|
301
302
|
export { PreviewTile, PreviewTileGroup } from "./preview-tile.js";
|
|
302
303
|
export { Progress } from "./progress.js";
|
|
303
304
|
export { RadioGroup, RadioGroupItem } from "./radio-group.js";
|
package/src/solid/media-store.ts
CHANGED
|
@@ -56,7 +56,8 @@ export interface MediaStore {
|
|
|
56
56
|
url(id: string, variant?: MediaVariant): string;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
/** `null` withholds the store from a tree, even where the host registered one. */
|
|
60
|
+
export const MediaStoreContext = createContext<MediaStore | null>();
|
|
60
61
|
|
|
61
62
|
let defaultStore: MediaStore | undefined;
|
|
62
63
|
|
|
@@ -66,7 +67,8 @@ export function provideMediaStore(store: MediaStore): void {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
export function useMediaStore(): MediaStore | undefined {
|
|
69
|
-
|
|
70
|
+
const scoped = useContext(MediaStoreContext);
|
|
71
|
+
return scoped === null ? undefined : (scoped ?? defaultStore);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/** One grid page. The picker and the library both slice by this, so neither can
|
package/src/solid/menu-parts.tsx
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { DropdownMenu as MenuPrimitive } from "@kobalte/core/dropdown-menu";
|
|
2
|
-
import {
|
|
2
|
+
import { useMenuContext } from "@kobalte/core/menu";
|
|
3
|
+
import {
|
|
4
|
+
type Component,
|
|
5
|
+
type ComponentProps,
|
|
6
|
+
createSignal,
|
|
7
|
+
type ParentComponent,
|
|
8
|
+
splitProps,
|
|
9
|
+
} from "solid-js";
|
|
3
10
|
import { glassToneText } from "../lib/glass-tone.js";
|
|
11
|
+
import { shadowLayer } from "../lib/shadow-layer.js";
|
|
4
12
|
import { MENU_ITEM, MENU_ITEM_BASE, MENU_LABEL, MENU_SEPARATOR } from "../lib/menu-classes.js";
|
|
5
13
|
import { STAGGER } from "../lib/motion-classes.js";
|
|
6
14
|
import { ignoreOpeningRelease } from "../lib/opening-release.js";
|
|
@@ -149,9 +157,39 @@ export const MenuSubTriggerPart: ParentComponent<MenuSubTriggerProps> = (props)
|
|
|
149
157
|
type MenuSubContentProps = ComponentProps<typeof MenuPrimitive.SubContent> & { slotName: string };
|
|
150
158
|
|
|
151
159
|
export const MenuSubContentPart: ParentComponent<MenuSubContentProps> = (props) => {
|
|
152
|
-
const [local, rest] = splitProps(props, [
|
|
160
|
+
const [local, rest] = splitProps(props, [
|
|
161
|
+
"class",
|
|
162
|
+
"children",
|
|
163
|
+
"slotName",
|
|
164
|
+
"ref",
|
|
165
|
+
"onInteractOutside",
|
|
166
|
+
"onCloseAutoFocus",
|
|
167
|
+
]);
|
|
168
|
+
const menu = useMenuContext();
|
|
169
|
+
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
170
|
+
const layer = shadowLayer({
|
|
171
|
+
content: panel,
|
|
172
|
+
open: () => menu.isOpen(),
|
|
173
|
+
dismiss: () => menu.close(),
|
|
174
|
+
trigger: () => menu.triggerRef(),
|
|
175
|
+
tree: true,
|
|
176
|
+
consumer: local,
|
|
177
|
+
});
|
|
153
178
|
return (
|
|
154
179
|
<MenuPrimitive.SubContent
|
|
180
|
+
ref={(el: HTMLElement) => {
|
|
181
|
+
setPanel(el);
|
|
182
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
183
|
+
}}
|
|
184
|
+
onInteractOutside={layer.onInteractOutside}
|
|
185
|
+
onCloseAutoFocus={(e: Event) => {
|
|
186
|
+
layer.onCloseAutoFocus(e);
|
|
187
|
+
// As Kobalte's own submenu: closing one never moves focus.
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
}}
|
|
190
|
+
// Kobalte's submenu closes on any focus outside it, past preventDefault; in a shadow root every
|
|
191
|
+
// focus inside reaches the page as one on the host, so the host is excluded instead.
|
|
192
|
+
excludedElements={[() => menu.triggerRef(), layer.host]}
|
|
155
193
|
data-slot={local.slotName}
|
|
156
194
|
class={cn(MENU_CONTENT_CLASS, local.class)}
|
|
157
195
|
{...rest}
|
package/src/solid/popover.tsx
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Popover as PopoverPrimitive, usePopoverContext } from "@kobalte/core/popover";
|
|
2
|
+
import { usePortalMount } from "./portal-mount.js";
|
|
2
3
|
import {
|
|
3
4
|
type Component,
|
|
4
5
|
type ComponentProps,
|
|
5
6
|
createContext,
|
|
7
|
+
createSignal,
|
|
6
8
|
splitProps,
|
|
7
9
|
useContext,
|
|
8
10
|
} from "solid-js";
|
|
9
11
|
import { INPUT_SURFACE } from "../lib/input-classes.js";
|
|
12
|
+
import { inShadowRoot, shadowLayer } from "../lib/shadow-layer.js";
|
|
10
13
|
import { Z_CLASS } from "../lib/layers.js";
|
|
11
14
|
import { FIELD_MOTION, MORPH_MOTION, STAGGER } from "../lib/motion-classes.js";
|
|
12
15
|
import { anchorToTriggerTop, FLOATING_PANEL } from "../lib/overlay-classes.js";
|
|
@@ -34,6 +37,8 @@ type PopoverProps = ComponentProps<typeof PopoverPrimitive> & {
|
|
|
34
37
|
const PopoverRoot: Component<PopoverProps> = (props) => {
|
|
35
38
|
const [local, rest] = splitProps(props, ["surface", "gutter", "getAnchorRect"]);
|
|
36
39
|
const surface = () => local.surface ?? "overlay";
|
|
40
|
+
// Modal in a shadow root, Kobalte would aria-hide the realm's host, popover included.
|
|
41
|
+
const inShadow = inShadowRoot(usePortalMount());
|
|
37
42
|
return (
|
|
38
43
|
<PopoverSurfaceContext.Provider value={surface}>
|
|
39
44
|
<PopoverPrimitive
|
|
@@ -42,6 +47,7 @@ const PopoverRoot: Component<PopoverProps> = (props) => {
|
|
|
42
47
|
flip={false}
|
|
43
48
|
overlap
|
|
44
49
|
{...rest}
|
|
50
|
+
modal={inShadow ? false : rest.modal}
|
|
45
51
|
/>
|
|
46
52
|
</PopoverSurfaceContext.Provider>
|
|
47
53
|
);
|
|
@@ -66,10 +72,24 @@ type PopoverContentProps = ComponentProps<typeof PopoverPrimitive.Content> & {
|
|
|
66
72
|
};
|
|
67
73
|
|
|
68
74
|
const PopoverContent: Component<PopoverContentProps> = (props) => {
|
|
69
|
-
const [local, rest] = splitProps(props, [
|
|
75
|
+
const [local, rest] = splitProps(props, [
|
|
76
|
+
"class",
|
|
77
|
+
"surface",
|
|
78
|
+
"ref",
|
|
79
|
+
"onInteractOutside",
|
|
80
|
+
"onCloseAutoFocus",
|
|
81
|
+
]);
|
|
70
82
|
const fromRoot = useContext(PopoverSurfaceContext);
|
|
71
83
|
const surface = () => local.surface ?? fromRoot();
|
|
72
84
|
const popover = usePopoverContext();
|
|
85
|
+
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
86
|
+
const layer = shadowLayer({
|
|
87
|
+
content: panel,
|
|
88
|
+
open: () => popover.isOpen(),
|
|
89
|
+
dismiss: () => popover.close(),
|
|
90
|
+
trigger: () => popover.triggerRef(),
|
|
91
|
+
consumer: local,
|
|
92
|
+
});
|
|
73
93
|
// The morph starts as the trigger's box (pill radius clamped to h/2). A
|
|
74
94
|
// field picker has an Anchor, not a Trigger, and keeps its clip reveal.
|
|
75
95
|
const writeMorphStart = (el: HTMLElement) => {
|
|
@@ -84,9 +104,15 @@ const PopoverContent: Component<PopoverContentProps> = (props) => {
|
|
|
84
104
|
el.style.setProperty("--morph-radius", `${radius}px`);
|
|
85
105
|
};
|
|
86
106
|
return (
|
|
87
|
-
<PopoverPrimitive.Portal>
|
|
107
|
+
<PopoverPrimitive.Portal mount={usePortalMount()}>
|
|
88
108
|
<PopoverPrimitive.Content
|
|
89
|
-
ref={
|
|
109
|
+
ref={(el: HTMLElement) => {
|
|
110
|
+
setPanel(el);
|
|
111
|
+
writeMorphStart(el);
|
|
112
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
113
|
+
}}
|
|
114
|
+
onInteractOutside={layer.onInteractOutside}
|
|
115
|
+
onCloseAutoFocus={layer.onCloseAutoFocus}
|
|
90
116
|
data-slot="popover-content"
|
|
91
117
|
data-surface={surface()}
|
|
92
118
|
class={cn(surface() === "field" ? FIELD_PANEL : OVERLAY_PANEL, local.class)}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from "solid-js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where overlays (dialogs, sheets, popovers, menus, tooltips) portal to. Unset, they portal to
|
|
5
|
+
* `document.body`; a host that renders a tree inside a shadow root sets it to a node in that root,
|
|
6
|
+
* so the overlay keeps the root's styles and never reaches the page.
|
|
7
|
+
*/
|
|
8
|
+
export const PortalMountContext = createContext<Node>();
|
|
9
|
+
|
|
10
|
+
export const usePortalMount = (): Node | undefined => useContext(PortalMountContext);
|
package/src/solid/select.tsx
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
import { Select as SelectPrimitive } from "@kobalte/core/select";
|
|
2
|
-
import {
|
|
1
|
+
import { Select as SelectPrimitive, useSelectContext } from "@kobalte/core/select";
|
|
2
|
+
import { usePortalMount } from "./portal-mount.js";
|
|
3
|
+
import {
|
|
4
|
+
type Component,
|
|
5
|
+
type ComponentProps,
|
|
6
|
+
createSignal,
|
|
7
|
+
type ParentComponent,
|
|
8
|
+
splitProps,
|
|
9
|
+
} from "solid-js";
|
|
10
|
+
import { shadowLayer } from "../lib/shadow-layer.js";
|
|
3
11
|
import { CONTROL_H, INPUT_SURFACE } from "../lib/input-classes.js";
|
|
4
12
|
import { Z_CLASS } from "../lib/layers.js";
|
|
5
13
|
import { MENU_ITEM, MENU_LABEL, MENU_SEPARATOR } from "../lib/menu-classes.js";
|
|
@@ -51,10 +59,32 @@ const SelectTrigger: ParentComponent<
|
|
|
51
59
|
const SelectContent: ParentComponent<
|
|
52
60
|
ComponentProps<typeof SelectPrimitive.Content> & { listboxClass?: string }
|
|
53
61
|
> = (props) => {
|
|
54
|
-
const [local, rest] = splitProps(props, [
|
|
62
|
+
const [local, rest] = splitProps(props, [
|
|
63
|
+
"class",
|
|
64
|
+
"children",
|
|
65
|
+
"listboxClass",
|
|
66
|
+
"ref",
|
|
67
|
+
"onInteractOutside",
|
|
68
|
+
"onCloseAutoFocus",
|
|
69
|
+
]);
|
|
70
|
+
const select = useSelectContext();
|
|
71
|
+
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
72
|
+
const layer = shadowLayer({
|
|
73
|
+
content: panel,
|
|
74
|
+
open: () => select.isOpen(),
|
|
75
|
+
dismiss: () => select.close(),
|
|
76
|
+
trigger: () => select.triggerRef(),
|
|
77
|
+
consumer: local,
|
|
78
|
+
});
|
|
55
79
|
return (
|
|
56
|
-
<SelectPrimitive.Portal>
|
|
80
|
+
<SelectPrimitive.Portal mount={usePortalMount()}>
|
|
57
81
|
<SelectPrimitive.Content
|
|
82
|
+
ref={(el: HTMLElement) => {
|
|
83
|
+
setPanel(el);
|
|
84
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
85
|
+
}}
|
|
86
|
+
onInteractOutside={layer.onInteractOutside}
|
|
87
|
+
onCloseAutoFocus={layer.onCloseAutoFocus}
|
|
58
88
|
data-slot="select-content"
|
|
59
89
|
class={cn(
|
|
60
90
|
// Same concave surface as the trigger: opening reads as the input
|
package/src/solid/sheet.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Dialog as DialogPrimitive, useDialogContext } from "@kobalte/core/dialog";
|
|
2
|
+
import { usePortalMount } from "./portal-mount.js";
|
|
2
3
|
import type { VariantProps } from "cva";
|
|
3
4
|
import {
|
|
4
5
|
type Component,
|
|
@@ -6,9 +7,11 @@ import {
|
|
|
6
7
|
type JSX,
|
|
7
8
|
type ParentComponent,
|
|
8
9
|
Show,
|
|
10
|
+
createSignal,
|
|
9
11
|
splitProps,
|
|
10
12
|
} from "solid-js";
|
|
11
13
|
import { buttonVariants } from "../lib/button-variants.js";
|
|
14
|
+
import { inShadowRoot, shadowLayer } from "../lib/shadow-layer.js";
|
|
12
15
|
import { Z_CLASS } from "../lib/layers.js";
|
|
13
16
|
import { SCRIM_MOTION } from "../lib/motion-classes.js";
|
|
14
17
|
import { OVERLAY_SURFACE, SCRIM_CLASS } from "../lib/overlay-classes.js";
|
|
@@ -25,9 +28,10 @@ import {
|
|
|
25
28
|
|
|
26
29
|
/* Kobalte's own scroll lock is off here too: ModalScrollLock is the one
|
|
27
30
|
* refcounted page lock every modal family shares. */
|
|
28
|
-
const Sheet: ParentComponent<ComponentProps<typeof DialogPrimitive>> = (props) =>
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
+
const Sheet: ParentComponent<ComponentProps<typeof DialogPrimitive>> = (props) => {
|
|
32
|
+
const mount = usePortalMount();
|
|
33
|
+
return <DialogPrimitive modal={!inShadowRoot(mount)} {...props} preventScroll={false} />;
|
|
34
|
+
};
|
|
31
35
|
|
|
32
36
|
const SheetTrigger: Component<ComponentProps<typeof DialogPrimitive.Trigger>> = (props) => (
|
|
33
37
|
<DialogPrimitive.Trigger data-slot="sheet-trigger" {...props} />
|
|
@@ -102,14 +106,38 @@ const SheetAbove: Component<{ above?: JSX.Element }> = (props) => (
|
|
|
102
106
|
);
|
|
103
107
|
|
|
104
108
|
const SheetContent: ParentComponent<SheetContentProps> = (props) => {
|
|
105
|
-
const [local, rest] = splitProps(props, [
|
|
109
|
+
const [local, rest] = splitProps(props, [
|
|
110
|
+
"class",
|
|
111
|
+
"children",
|
|
112
|
+
"side",
|
|
113
|
+
"above",
|
|
114
|
+
"ariaLabel",
|
|
115
|
+
"ref",
|
|
116
|
+
"onInteractOutside",
|
|
117
|
+
"onCloseAutoFocus",
|
|
118
|
+
]);
|
|
106
119
|
const context = useDialogContext();
|
|
120
|
+
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
121
|
+
const layer = shadowLayer({
|
|
122
|
+
content: panel,
|
|
123
|
+
open: () => context.isOpen(),
|
|
124
|
+
dismiss: () => context.close(),
|
|
125
|
+
trapsFocus: true,
|
|
126
|
+
initialFocus: "container",
|
|
127
|
+
consumer: local,
|
|
128
|
+
});
|
|
107
129
|
|
|
108
130
|
return (
|
|
109
|
-
<DialogPrimitive.Portal>
|
|
131
|
+
<DialogPrimitive.Portal mount={usePortalMount()}>
|
|
110
132
|
<ModalScrollLock />
|
|
111
133
|
<SheetOverlay />
|
|
112
134
|
<DialogPrimitive.Content
|
|
135
|
+
ref={(el: HTMLElement) => {
|
|
136
|
+
setPanel(el);
|
|
137
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
138
|
+
}}
|
|
139
|
+
onInteractOutside={layer.onInteractOutside}
|
|
140
|
+
onCloseAutoFocus={layer.onCloseAutoFocus}
|
|
113
141
|
data-slot="sheet-content"
|
|
114
142
|
role="dialog"
|
|
115
143
|
aria-label={context.titleId() ? undefined : local.ariaLabel}
|
package/src/solid/spotlight.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Show,
|
|
9
9
|
} from "solid-js";
|
|
10
10
|
import { Portal } from "solid-js/web";
|
|
11
|
+
import { usePortalMount } from "./portal-mount.js";
|
|
11
12
|
import { Z_CLASS } from "../lib/layers.js";
|
|
12
13
|
import { SCRIM_MOTION, TRAVEL_MOTION } from "../lib/motion-classes.js";
|
|
13
14
|
import { OVERLAY_SURFACE_OPAQUE, PANEL_TAIL, SCRIM_CLASS } from "../lib/overlay-classes.js";
|
|
@@ -121,7 +122,7 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
121
122
|
placeBubble(viewport(), anchorBox(), bubbleSize(), BUBBLE_GAP_WITH_TAIL, VIEWPORT_MARGIN);
|
|
122
123
|
|
|
123
124
|
return (
|
|
124
|
-
<Portal>
|
|
125
|
+
<Portal mount={usePortalMount()}>
|
|
125
126
|
<Show when={props.scrim}>
|
|
126
127
|
<div
|
|
127
128
|
data-slot="spotlight-scrim"
|
package/src/solid/tooltip.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Tooltip as TooltipPrimitive } from "@kobalte/core/tooltip";
|
|
2
|
-
import {
|
|
2
|
+
import { usePortalMount } from "./portal-mount.js";
|
|
3
|
+
import { type Component, type ComponentProps, createSignal, splitProps } from "solid-js";
|
|
3
4
|
import { OVERLAY_MOTION } from "../lib/motion-classes.js";
|
|
5
|
+
import { shadowLayer } from "../lib/shadow-layer.js";
|
|
4
6
|
import { FLOATING_PANEL } from "../lib/overlay-classes.js";
|
|
5
7
|
import { cn } from "../lib/utils.js";
|
|
6
8
|
|
|
@@ -18,10 +20,18 @@ const Tooltip = Object.assign(TooltipRoot, TooltipPrimitive);
|
|
|
18
20
|
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
19
21
|
|
|
20
22
|
const TooltipContent: Component<ComponentProps<typeof TooltipPrimitive.Content>> = (props) => {
|
|
21
|
-
const [local, others] = splitProps(props, ["class"]);
|
|
23
|
+
const [local, others] = splitProps(props, ["class", "ref", "onInteractOutside"]);
|
|
24
|
+
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
25
|
+
// A tooltip closes as the pointer leaves; inside a shadow root it only must not close on its own presses.
|
|
26
|
+
const { onInteractOutside } = shadowLayer({ content: panel, open: () => true, consumer: local });
|
|
22
27
|
return (
|
|
23
|
-
<TooltipPrimitive.Portal>
|
|
28
|
+
<TooltipPrimitive.Portal mount={usePortalMount()}>
|
|
24
29
|
<TooltipPrimitive.Content
|
|
30
|
+
ref={(el: HTMLElement) => {
|
|
31
|
+
setPanel(el);
|
|
32
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
33
|
+
}}
|
|
34
|
+
onInteractOutside={onInteractOutside}
|
|
25
35
|
data-slot="tooltip-content"
|
|
26
36
|
class={cn(
|
|
27
37
|
FLOATING_PANEL,
|