@oxy.so/bloom 2.4.0 → 2.5.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/README.md +3 -3
- package/docs/avatar-group.mdx +10 -17
- package/docs/hover-card.mdx +125 -0
- package/docs/user-hover-card.mdx +29 -9
- package/lib/commonjs/avatar-group/AvatarGroup.web.js +55 -85
- package/lib/commonjs/avatar-group/AvatarGroup.web.js.map +1 -1
- package/lib/commonjs/floating/use-anchor-rect.js +1 -0
- package/lib/commonjs/floating/use-anchor-rect.js.map +1 -1
- package/lib/commonjs/hover-card/HoverCard.js +104 -0
- package/lib/commonjs/hover-card/HoverCard.js.map +1 -0
- package/lib/commonjs/hover-card/HoverCard.web.js +155 -0
- package/lib/commonjs/hover-card/HoverCard.web.js.map +1 -0
- package/lib/commonjs/hover-card/HoverCardPanel.js +101 -0
- package/lib/commonjs/hover-card/HoverCardPanel.js.map +1 -0
- package/lib/commonjs/hover-card/constants.js +25 -0
- package/lib/commonjs/hover-card/constants.js.map +1 -0
- package/lib/commonjs/hover-card/context.js +37 -0
- package/lib/commonjs/hover-card/context.js.map +1 -0
- package/lib/commonjs/hover-card/index.js +44 -0
- package/lib/commonjs/hover-card/index.js.map +1 -0
- package/lib/commonjs/hover-card/index.web.js +44 -0
- package/lib/commonjs/hover-card/index.web.js.map +1 -0
- package/lib/commonjs/hover-card/types.js +6 -0
- package/lib/commonjs/hover-card/types.js.map +1 -0
- package/lib/commonjs/hover-card/use-hover-intent.js +49 -0
- package/lib/commonjs/hover-card/use-hover-intent.js.map +1 -0
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +16 -4
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/user-hover-card/UserHoverCard.js +16 -6
- package/lib/commonjs/user-hover-card/UserHoverCard.js.map +1 -1
- package/lib/commonjs/user-hover-card/constants.js +8 -2
- package/lib/commonjs/user-hover-card/constants.js.map +1 -1
- package/lib/module/avatar-group/AvatarGroup.web.js +55 -84
- package/lib/module/avatar-group/AvatarGroup.web.js.map +1 -1
- package/lib/module/floating/use-anchor-rect.js +1 -1
- package/lib/module/floating/use-anchor-rect.js.map +1 -1
- package/lib/module/hover-card/HoverCard.js +96 -0
- package/lib/module/hover-card/HoverCard.js.map +1 -0
- package/lib/module/hover-card/HoverCard.web.js +147 -0
- package/lib/module/hover-card/HoverCard.web.js.map +1 -0
- package/lib/module/hover-card/HoverCardPanel.js +95 -0
- package/lib/module/hover-card/HoverCardPanel.js.map +1 -0
- package/lib/module/hover-card/constants.js +21 -0
- package/lib/module/hover-card/constants.js.map +1 -0
- package/lib/module/hover-card/context.js +30 -0
- package/lib/module/hover-card/context.js.map +1 -0
- package/lib/module/hover-card/index.js +5 -0
- package/lib/module/hover-card/index.js.map +1 -0
- package/lib/module/hover-card/index.web.js +5 -0
- package/lib/module/hover-card/index.web.js.map +1 -0
- package/lib/module/hover-card/types.js +4 -0
- package/lib/module/hover-card/types.js.map +1 -0
- package/lib/module/hover-card/use-hover-intent.js +46 -0
- package/lib/module/hover-card/use-hover-intent.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -0
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/user-hover-card/UserHoverCard.js +15 -5
- package/lib/module/user-hover-card/UserHoverCard.js.map +1 -1
- package/lib/module/user-hover-card/constants.js +9 -2
- package/lib/module/user-hover-card/constants.js.map +1 -1
- package/lib/typescript/commonjs/avatar-group/AvatarGroup.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/use-anchor-rect.d.ts +7 -0
- package/lib/typescript/commonjs/floating/use-anchor-rect.d.ts.map +1 -1
- package/lib/typescript/commonjs/hover-card/HoverCard.d.ts +5 -0
- package/lib/typescript/commonjs/hover-card/HoverCard.d.ts.map +1 -0
- package/lib/typescript/commonjs/hover-card/HoverCard.web.d.ts +5 -0
- package/lib/typescript/commonjs/hover-card/HoverCard.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/hover-card/HoverCardPanel.d.ts +45 -0
- package/lib/typescript/commonjs/hover-card/HoverCardPanel.d.ts.map +1 -0
- package/lib/typescript/commonjs/hover-card/constants.d.ts +16 -0
- package/lib/typescript/commonjs/hover-card/constants.d.ts.map +1 -0
- package/lib/typescript/commonjs/hover-card/context.d.ts +21 -0
- package/lib/typescript/commonjs/hover-card/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/hover-card/index.d.ts +4 -0
- package/lib/typescript/commonjs/hover-card/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/hover-card/index.web.d.ts +4 -0
- package/lib/typescript/commonjs/hover-card/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/hover-card/types.d.ts +50 -0
- package/lib/typescript/commonjs/hover-card/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/hover-card/use-hover-intent.d.ts +14 -0
- package/lib/typescript/commonjs/hover-card/use-hover-intent.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +1 -0
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/user-hover-card/UserHoverCard.d.ts.map +1 -1
- package/lib/typescript/commonjs/user-hover-card/constants.d.ts +6 -1
- package/lib/typescript/commonjs/user-hover-card/constants.d.ts.map +1 -1
- package/lib/typescript/module/avatar-group/AvatarGroup.web.d.ts.map +1 -1
- package/lib/typescript/module/floating/use-anchor-rect.d.ts +7 -0
- package/lib/typescript/module/floating/use-anchor-rect.d.ts.map +1 -1
- package/lib/typescript/module/hover-card/HoverCard.d.ts +5 -0
- package/lib/typescript/module/hover-card/HoverCard.d.ts.map +1 -0
- package/lib/typescript/module/hover-card/HoverCard.web.d.ts +5 -0
- package/lib/typescript/module/hover-card/HoverCard.web.d.ts.map +1 -0
- package/lib/typescript/module/hover-card/HoverCardPanel.d.ts +45 -0
- package/lib/typescript/module/hover-card/HoverCardPanel.d.ts.map +1 -0
- package/lib/typescript/module/hover-card/constants.d.ts +16 -0
- package/lib/typescript/module/hover-card/constants.d.ts.map +1 -0
- package/lib/typescript/module/hover-card/context.d.ts +21 -0
- package/lib/typescript/module/hover-card/context.d.ts.map +1 -0
- package/lib/typescript/module/hover-card/index.d.ts +4 -0
- package/lib/typescript/module/hover-card/index.d.ts.map +1 -0
- package/lib/typescript/module/hover-card/index.web.d.ts +4 -0
- package/lib/typescript/module/hover-card/index.web.d.ts.map +1 -0
- package/lib/typescript/module/hover-card/types.d.ts +50 -0
- package/lib/typescript/module/hover-card/types.d.ts.map +1 -0
- package/lib/typescript/module/hover-card/use-hover-intent.d.ts +14 -0
- package/lib/typescript/module/hover-card/use-hover-intent.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +1 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +1 -0
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/user-hover-card/UserHoverCard.d.ts.map +1 -1
- package/lib/typescript/module/user-hover-card/constants.d.ts +6 -1
- package/lib/typescript/module/user-hover-card/constants.d.ts.map +1 -1
- package/package.json +20 -1
- package/src/avatar-group/AvatarGroup.web.tsx +57 -126
- package/src/floating/use-anchor-rect.ts +1 -1
- package/src/hover-card/HoverCard.tsx +90 -0
- package/src/hover-card/HoverCard.web.tsx +160 -0
- package/src/hover-card/HoverCardPanel.tsx +112 -0
- package/src/hover-card/constants.ts +18 -0
- package/src/hover-card/context.ts +45 -0
- package/src/hover-card/index.ts +7 -0
- package/src/hover-card/index.web.ts +7 -0
- package/src/hover-card/types.ts +53 -0
- package/src/hover-card/use-hover-intent.ts +47 -0
- package/src/index.ts +1 -0
- package/src/index.web.ts +1 -0
- package/src/user-hover-card/UserHoverCard.tsx +30 -18
- package/src/user-hover-card/constants.ts +9 -2
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
### What it is
|
|
22
22
|
|
|
23
|
-
Components, hooks and design tokens published as `@oxy.so/bloom` across
|
|
23
|
+
Components, hooks and design tokens published as `@oxy.so/bloom` across 130 subpath exports, shipped as `src` for Metro and as compiled CommonJS and ESM for everyone else. Web builds resolve platform forks automatically through export conditions, so a `.web.tsx` fork never reaches a native bundle.
|
|
24
24
|
|
|
25
25
|
Styling is NativeWind classes throughout. There are no colour props and no wrapper components to theme a button, because a second way to set a colour is a second thing that can disagree.
|
|
26
26
|
|
|
@@ -151,7 +151,7 @@ Every palette is generated from a single seed colour by a dependency free colour
|
|
|
151
151
|
|
|
152
152
|
## Components
|
|
153
153
|
|
|
154
|
-
Bloom publishes
|
|
154
|
+
Bloom publishes 130 subpath exports. Importing from the subpath rather than the root keeps a bundle to what it actually renders.
|
|
155
155
|
|
|
156
156
|
| Group | Exports |
|
|
157
157
|
|---|---|
|
|
@@ -163,7 +163,7 @@ Bloom publishes 129 subpath exports. Importing from the subpath rather than the
|
|
|
163
163
|
| Layout and lists | `grid`, `list`, `scroll`, `settings-list`, `card`, `accordion`, `aspect-ratio`, `divider`, `item`, `carousel` |
|
|
164
164
|
| Data and charts | `table`, `data-table`, `chart-cards`, `stat-cards`, `calendar`, `composition-bar`, `dot-grid-meter`, `stat-bar`, `activity-heatmap`, `recent-hires-card`, `patient-info-card`, `important-alerts-card`, `agent-limits-card`, `ai-profile-card` |
|
|
165
165
|
| AI and agents | `agent-chat`, `ai-chat`, `composer-panel`, `composer-loader`, `agent-thinking`, `agent-log`, `agent-progress`, `task-list`, `web-search`, `questionnaire` |
|
|
166
|
-
| Identity and media | `avatar`, `avatar-group`, `user-hover-card`, `image-resolver`, `image-aspect-ratio-cache`, `zoomable-image-gallery`, `zoomable-media-gallery`, `media-flight`, `media-inset-border`, `progressive-blur`, `fill` |
|
|
166
|
+
| Identity and media | `avatar`, `avatar-group`, `hover-card`, `user-hover-card`, `image-resolver`, `image-aspect-ratio-cache`, `zoomable-image-gallery`, `zoomable-media-gallery`, `media-flight`, `media-inset-border`, `progressive-blur`, `fill` |
|
|
167
167
|
| Feedback | `toast`, `notification`, `notification-center`, `announcement`, `admonition`, `loading`, `skeleton`, `error-boundary`, `badge`, `chip`, `kbd`, `code`, `link-preview`, `connection-status`, `connection-dots` |
|
|
168
168
|
| Motion and assets | `motion`, `animated-check`, `icon-circle`, `radio-indicator`, `icons`, `typography`, `fonts` |
|
|
169
169
|
|
package/docs/avatar-group.mdx
CHANGED
|
@@ -72,20 +72,13 @@ state — the consumer passes the SDK's `FollowButton` into its `action` slot.
|
|
|
72
72
|
|
|
73
73
|
`renderItemAction` is the only slot the hover card exposes per item.
|
|
74
74
|
`UserHoverCard`'s `footer` is not forwarded: a facepile hover card is a glance at
|
|
75
|
-
who these people are, and an app that wants a fuller preview
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
The card floats
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
The card floats under a `View` with `onPointerEnter`/`onPointerLeave`, and that
|
|
86
|
-
must not become a `Pressable`. react-native-web's `Pressable` dispatches a
|
|
87
|
-
bubbling `react-gui:hover:lock` event on hover, and an ancestor `Pressable` that
|
|
88
|
-
is currently hovered ends its own hover for any lock it did not send — so a
|
|
89
|
-
`Pressable` bridge dismissed the card the moment the cursor reached the injected
|
|
90
|
-
FollowButton or the identity area. Nothing was logged; the card just went away
|
|
91
|
-
about 120ms later.
|
|
75
|
+
who these people are, and an app that wants a fuller preview wraps an avatar in a
|
|
76
|
+
[`HoverCard`](/docs/bloom/main/hover-card) with `UserHoverCard` inside.
|
|
77
|
+
|
|
78
|
+
The card floats in the same panel as [`HoverCardContent`](/docs/bloom/main/hover-card),
|
|
79
|
+
so placement (flip and clamp), motion, Escape and outside-press dismissal and the
|
|
80
|
+
pointer bridge are the hover card's — including why that bridge must never be a
|
|
81
|
+
`Pressable`. What this family adds is ONE card for the whole pile: it re-anchors
|
|
82
|
+
as the cursor moves between faces instead of closing and reopening per avatar,
|
|
83
|
+
and it opens with no delay, because a pointer on a row of people is already
|
|
84
|
+
asking who they are.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: HoverCard
|
|
3
|
+
description: Decides when and where a preview card appears — hover or focus on web, long press on native.
|
|
4
|
+
order: 22
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# HoverCard
|
|
8
|
+
|
|
9
|
+
A preview that opens while the pointer rests on something — a name, an avatar, a
|
|
10
|
+
link — and stays up while the pointer moves onto it. On native, where there is no
|
|
11
|
+
hover, a long press opens it in a bottom sheet.
|
|
12
|
+
|
|
13
|
+
Three parts, shadcn's own: `HoverCard`, `HoverCardTrigger`, `HoverCardContent`.
|
|
14
|
+
The trigger decides **when** the card appears; the content decides **where**.
|
|
15
|
+
What the card shows is up to you — for a person, that is
|
|
16
|
+
[`UserHoverCard`](/docs/bloom/main/user-hover-card).
|
|
17
|
+
|
|
18
|
+
```tsx
|
|
19
|
+
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@oxy.so/bloom/hover-card';
|
|
20
|
+
import { UserHoverCard } from '@oxy.so/bloom/user-hover-card';
|
|
21
|
+
import { FollowButton } from '@oxy.so/services';
|
|
22
|
+
|
|
23
|
+
<HoverCard>
|
|
24
|
+
<HoverCardTrigger asChild>
|
|
25
|
+
<Link href={`/@${user.username}`}>@{user.username}</Link>
|
|
26
|
+
</HoverCardTrigger>
|
|
27
|
+
<HoverCardContent label={user.name.displayName}>
|
|
28
|
+
<UserHoverCard
|
|
29
|
+
avatar={user.avatar}
|
|
30
|
+
displayName={user.name.displayName ?? user.username}
|
|
31
|
+
username={user.username}
|
|
32
|
+
bio={user.bio}
|
|
33
|
+
action={<FollowButton userId={user.id} />}
|
|
34
|
+
/>
|
|
35
|
+
</HoverCardContent>
|
|
36
|
+
</HoverCard>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`UserHoverCard` notices it is inside a `HoverCardContent` and draws only its
|
|
40
|
+
content — the panel is its surface, so there is never a card inside a card, and
|
|
41
|
+
the entrance plays once.
|
|
42
|
+
|
|
43
|
+
## When it opens
|
|
44
|
+
|
|
45
|
+
| Platform | Opens | Closes |
|
|
46
|
+
| -------- | ------------------------------------------------------- | --------------------------------------------------- |
|
|
47
|
+
| Web | pointer rests on the trigger for `openDelay` (400ms), or keyboard focus reaches it | pointer away from trigger **and** card for `closeDelay` (150ms), blur, Escape, a press outside |
|
|
48
|
+
| Native | long press on the trigger | swipe the sheet down, tap the scrim |
|
|
49
|
+
|
|
50
|
+
- **The open delay is a filter, not latency.** A pointer crossing a page of
|
|
51
|
+
names on its way somewhere else opens nothing.
|
|
52
|
+
- **The close delay is a bridge.** The card sits 8px from its trigger; the
|
|
53
|
+
pointer crosses that gap well within 150ms, so moving onto the card keeps it
|
|
54
|
+
up. Everything inside the card — a follow button, the profile link — stays
|
|
55
|
+
reachable.
|
|
56
|
+
- **Touch pointers are ignored on web.** A tap is a press, and it belongs to the
|
|
57
|
+
element under the finger.
|
|
58
|
+
- **Only keyboard focus opens it** (`:focus-visible`). A mouse click focuses what
|
|
59
|
+
it lands on too, and opening on that would reopen a card the click meant to
|
|
60
|
+
get past.
|
|
61
|
+
- **A plain press is never the card's.** On native the trigger composes a long
|
|
62
|
+
press into its child and leaves `onPress` alone, so a link or an avatar that
|
|
63
|
+
navigates still navigates.
|
|
64
|
+
|
|
65
|
+
Pass `openDelay` / `closeDelay` on the root to tune it; they do nothing on
|
|
66
|
+
native.
|
|
67
|
+
|
|
68
|
+
## `asChild` on native
|
|
69
|
+
|
|
70
|
+
When the trigger's child is itself pressable, pass `asChild`. Without it the
|
|
71
|
+
child renders inside Bloom's own `Pressable`, and the inner pressable wins the
|
|
72
|
+
responder — the outer long press never fires. With it, the long press is merged
|
|
73
|
+
into your element, composed with any `onLongPress` it already has. On web the
|
|
74
|
+
prop is ignored: the trigger listens for pointer and focus on a wrapper, so
|
|
75
|
+
there is nothing to merge.
|
|
76
|
+
|
|
77
|
+
## Load on open
|
|
78
|
+
|
|
79
|
+
`onOpenChange(true)` fires when the card is about to show, which is the moment to
|
|
80
|
+
fetch. Render `UserHoverCard` with `loading` until the profile lands — the
|
|
81
|
+
skeleton has the card's own geometry, so nothing jumps.
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
const [open, setOpen] = useState(false);
|
|
85
|
+
const { data: user } = useProfile(username, { enabled: open });
|
|
86
|
+
|
|
87
|
+
<HoverCard open={open} onOpenChange={setOpen}>
|
|
88
|
+
<HoverCardTrigger asChild>
|
|
89
|
+
<Link href={`/@${username}`}>@{username}</Link>
|
|
90
|
+
</HoverCardTrigger>
|
|
91
|
+
<HoverCardContent label={username}>
|
|
92
|
+
<UserHoverCard loading={!user} displayName={user?.name ?? username} username={username} />
|
|
93
|
+
</HoverCardContent>
|
|
94
|
+
</HoverCard>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Where it opens
|
|
98
|
+
|
|
99
|
+
`HoverCardContent` takes the anchored-surface props every Bloom floating surface
|
|
100
|
+
takes: `side` (default `'bottom'`), `align` (default `'center'`), `sideOffset`
|
|
101
|
+
(default `8`) and `alignOffset`. `side` is a preference — the card flips when it
|
|
102
|
+
does not fit and is clamped inside the viewport.
|
|
103
|
+
|
|
104
|
+
The surface is Bloom's floating panel: radius 16, 1px border, the dropdown
|
|
105
|
+
shadow, a 15px inset (`padded={false}` removes the inset) and the 150ms fade,
|
|
106
|
+
`scale-95` and 2px blur entrance, reversed on the way out. It is **not modal** —
|
|
107
|
+
nothing is laid over the page, which stays scrollable and clickable.
|
|
108
|
+
|
|
109
|
+
## The bridge must not be a `Pressable`
|
|
110
|
+
|
|
111
|
+
The pointer bridge that keeps the card open is a `View` listening to
|
|
112
|
+
`pointerenter`/`pointerleave`. react-native-web's `Pressable` dispatches a
|
|
113
|
+
bubbling `react-gui:hover:lock` event on hover, and a hovered ancestor
|
|
114
|
+
`Pressable` ends its own hover for any lock it did not send — so a `Pressable`
|
|
115
|
+
bridge dismissed the card the moment the cursor reached a button inside it, with
|
|
116
|
+
nothing logged. `pointerenter`/`pointerleave` do not bubble and do not fire
|
|
117
|
+
between descendants. Gates: `HoverCard.web.test.tsx` and
|
|
118
|
+
`UserHoverCard.web.test.tsx`, both mutation-checked against removing the bridge.
|
|
119
|
+
|
|
120
|
+
## `AvatarGroup`
|
|
121
|
+
|
|
122
|
+
`AvatarGroup`'s `hoverCard` floats its card in the same panel, so placement,
|
|
123
|
+
motion and dismissal match. It keeps ONE card for the whole pile, re-anchored as
|
|
124
|
+
the cursor moves between faces, which is the one thing a `HoverCard` per avatar
|
|
125
|
+
could not do.
|
package/docs/user-hover-card.mdx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: UserHoverCard
|
|
3
|
-
description: A
|
|
3
|
+
description: A profile card. Show it with HoverCard; Bloom holds no follow logic — the consumer passes the button in.
|
|
4
4
|
order: 23
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -29,6 +29,30 @@ import { FollowButton } from '@oxy.so/services';
|
|
|
29
29
|
/>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
## Showing it
|
|
33
|
+
|
|
34
|
+
`UserHoverCard` draws the person and nothing else — it does not decide **when**
|
|
35
|
+
or **where** it appears. That is [`HoverCard`](/docs/bloom/main/hover-card)'s
|
|
36
|
+
job: hover or keyboard focus on web, long press on native, anchored to the
|
|
37
|
+
trigger and kept open while the pointer travels onto it.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@oxy.so/bloom/hover-card';
|
|
41
|
+
|
|
42
|
+
<HoverCard>
|
|
43
|
+
<HoverCardTrigger asChild>
|
|
44
|
+
<Link href={`/@${user.username}`}>@{user.username}</Link>
|
|
45
|
+
</HoverCardTrigger>
|
|
46
|
+
<HoverCardContent label={user.name.displayName}>
|
|
47
|
+
<UserHoverCard displayName={user.name.displayName} username={user.username} />
|
|
48
|
+
</HoverCardContent>
|
|
49
|
+
</HoverCard>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Inside `HoverCardContent` the card draws no surface of its own — the panel's
|
|
53
|
+
border, background, shadow and inset are the card's, and the entrance plays
|
|
54
|
+
once. Rendered anywhere else it wears the same surface itself.
|
|
55
|
+
|
|
32
56
|
## `footer` is where your own content goes
|
|
33
57
|
|
|
34
58
|
The card renders what every Oxy app agrees a person is — photo, name, handle,
|
|
@@ -122,14 +146,10 @@ position.
|
|
|
122
146
|
|
|
123
147
|
### Inside a hover card, everything you put here stays pressable
|
|
124
148
|
|
|
125
|
-
`AvatarGroup`'s `hoverCard`
|
|
126
|
-
|
|
127
|
-
`
|
|
128
|
-
|
|
129
|
-
pressable inside it. react-native-web's `Pressable` dispatches a bubbling
|
|
130
|
-
`react-gui:hover:lock` event, and an ancestor `Pressable` that is currently
|
|
131
|
-
hovered ends its own hover for any lock it did not send. If you build your own
|
|
132
|
-
hover trigger around this card, do the same.
|
|
149
|
+
`HoverCard` (and `AvatarGroup`'s `hoverCard`) keep the card open with a pointer
|
|
150
|
+
bridge that is deliberately not a `Pressable`, so the cursor can reach a button
|
|
151
|
+
in `action` or `footer` without the card closing. Why, measured:
|
|
152
|
+
[HoverCard](/docs/bloom/main/hover-card).
|
|
133
153
|
|
|
134
154
|
## Bloom holds no follow state
|
|
135
155
|
|
|
@@ -5,35 +5,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.AvatarGroup = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
8
|
+
var _useAnchorRect = require("../floating/use-anchor-rect.js");
|
|
9
|
+
var _constants = require("../hover-card/constants.js");
|
|
10
|
+
var _HoverCardPanel = require("../hover-card/HoverCardPanel.js");
|
|
11
|
+
var _useHoverIntent = require("../hover-card/use-hover-intent.js");
|
|
12
|
+
var _index = require("../user-hover-card/index.js");
|
|
13
13
|
var _AvatarGroupBase = require("./AvatarGroupBase.js");
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
16
|
-
// `../portal/index.web`, not `../portal`: export conditions do not apply to
|
|
17
|
-
// relative specifiers, so the bare name resolves to the NATIVE barrel in any
|
|
18
|
-
// bundler that does not add web extensions to its resolution order. The native
|
|
19
|
-
// Portal renders into a `PortalOutlet`, which a web app never mounts — both are
|
|
20
|
-
// no-ops in the web fork — so the hover card would render nothing at all.
|
|
21
|
-
// `Dialog.web.tsx` and `BottomSheet.web.tsx` already name it this way.
|
|
22
|
-
|
|
23
|
-
/** Delay before dismissing the card so the cursor can travel into it. */
|
|
24
|
-
const CLOSE_DELAY_MS = 120;
|
|
25
|
-
/** Gap between the anchored avatar and the floating card. */
|
|
26
|
-
const CARD_GAP = 8;
|
|
27
|
-
// The card's own width, never a second copy of it: this file CENTRES the card
|
|
28
|
-
// on its anchor, so a private constant would mis-place it the first time
|
|
29
|
-
// either number moved, and nothing would error.
|
|
30
|
-
const CARD_WIDTH = _index2.USER_HOVER_CARD_WIDTH;
|
|
31
16
|
/**
|
|
32
17
|
* Web `AvatarGroup`. Identical layout rendering to native (stack / row /
|
|
33
18
|
* cluster) via {@link AvatarGroupBase}, plus an optional hover card: when
|
|
34
19
|
* `hoverCard` is enabled, hovering an avatar reveals a {@link UserHoverCard}
|
|
35
|
-
*
|
|
36
|
-
*
|
|
20
|
+
* beneath it. The card receives the per-item `renderItemAction` slot so the app
|
|
21
|
+
* can drop its SDK FollowButton inside.
|
|
22
|
+
*
|
|
23
|
+
* The card floats in `HoverCardPanel`, the same surface `HoverCardContent`
|
|
24
|
+
* renders — placement (flip and clamp), motion, Escape and outside-press
|
|
25
|
+
* dismissal, and the pointer bridge all come from there. What stays here is the
|
|
26
|
+
* one thing a single `HoverCard` cannot do: ONE card serving every face, which
|
|
27
|
+
* re-anchors as the cursor moves along the pile instead of closing and
|
|
28
|
+
* reopening per avatar. It opens with no delay for the same reason — the
|
|
29
|
+
* pointer is already on a row of people, and the card is what it came for.
|
|
37
30
|
*/
|
|
38
31
|
const AvatarGroupWebComponent = props => {
|
|
39
32
|
const {
|
|
@@ -41,88 +34,65 @@ const AvatarGroupWebComponent = props => {
|
|
|
41
34
|
renderItemAction,
|
|
42
35
|
onPressItem
|
|
43
36
|
} = props;
|
|
44
|
-
const [
|
|
37
|
+
const [target, setTarget] = (0, _react.useState)(null);
|
|
38
|
+
const [open, setOpen] = (0, _react.useState)(false);
|
|
45
39
|
const cellRefs = (0, _react.useRef)(new Map());
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
}, []);
|
|
53
|
-
const scheduleClose = (0, _react.useCallback)(() => {
|
|
54
|
-
cancelClose();
|
|
55
|
-
closeTimer.current = setTimeout(() => setHover(null), CLOSE_DELAY_MS);
|
|
56
|
-
}, [cancelClose]);
|
|
40
|
+
const {
|
|
41
|
+
show,
|
|
42
|
+
hide,
|
|
43
|
+
hold
|
|
44
|
+
} = (0, _useHoverIntent.useHoverIntent)(open, setOpen, 0, _constants.HOVER_CARD_CLOSE_DELAY);
|
|
57
45
|
const registerCellRef = (0, _react.useCallback)((index, node) => {
|
|
58
46
|
if (node) cellRefs.current.set(index, node);else cellRefs.current.delete(index);
|
|
59
47
|
}, []);
|
|
60
48
|
const handleHoverIn = (0, _react.useCallback)((item, index) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
let left = x + width / 2 - CARD_WIDTH / 2;
|
|
68
|
-
left = Math.max(CARD_GAP, Math.min(left, viewportWidth - CARD_WIDTH - CARD_GAP));
|
|
69
|
-
setHover({
|
|
70
|
-
item,
|
|
71
|
-
index,
|
|
72
|
-
top: y + height + CARD_GAP,
|
|
73
|
-
left
|
|
74
|
-
});
|
|
49
|
+
const anchor = (0, _useAnchorRect.rectOf)(cellRefs.current.get(index) ?? null);
|
|
50
|
+
if (!anchor) return;
|
|
51
|
+
setTarget({
|
|
52
|
+
item,
|
|
53
|
+
index,
|
|
54
|
+
anchor
|
|
75
55
|
});
|
|
76
|
-
|
|
56
|
+
show();
|
|
57
|
+
}, [show]);
|
|
58
|
+
const dismiss = (0, _react.useCallback)(() => {
|
|
59
|
+
hold();
|
|
60
|
+
setOpen(false);
|
|
61
|
+
}, [hold]);
|
|
77
62
|
const hoverHandlers = (0, _react.useMemo)(() => {
|
|
78
63
|
if (!hoverCard) return undefined;
|
|
79
64
|
return {
|
|
80
65
|
onHoverIn: handleHoverIn,
|
|
81
|
-
onHoverOut:
|
|
66
|
+
onHoverOut: hide,
|
|
82
67
|
registerCellRef
|
|
83
68
|
};
|
|
84
|
-
}, [hoverCard, handleHoverIn,
|
|
69
|
+
}, [hoverCard, handleHoverIn, hide, registerCellRef]);
|
|
85
70
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
86
71
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_AvatarGroupBase.AvatarGroupBase, {
|
|
87
72
|
...props,
|
|
88
73
|
hoverHandlers: hoverHandlers
|
|
89
|
-
}), hoverCard &&
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
displayName: (0, _AvatarGroupBase.getItemName)(hover.item) ?? '',
|
|
108
|
-
username: hover.item.username,
|
|
109
|
-
onPressProfile: onPressItem ? () => onPressItem(hover.item, hover.index) : undefined,
|
|
110
|
-
action: renderItemAction?.(hover.item, hover.index),
|
|
111
|
-
style: webStyles.card
|
|
112
|
-
})
|
|
113
|
-
})
|
|
74
|
+
}), hoverCard && target ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_HoverCardPanel.HoverCardPanel, {
|
|
75
|
+
open: open,
|
|
76
|
+
anchor: open ? target.anchor : null,
|
|
77
|
+
onDismiss: dismiss,
|
|
78
|
+
onPointerEnter: hold,
|
|
79
|
+
onPointerLeave: hide,
|
|
80
|
+
label: (0, _AvatarGroupBase.getItemName)(target.item) ?? 'Profile',
|
|
81
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.UserHoverCard, {
|
|
82
|
+
avatar: target.item.uri ?? undefined
|
|
83
|
+
// `UserHoverCardProps.displayName` is contractually an
|
|
84
|
+
// already-resolved string, and resolving it is precisely this
|
|
85
|
+
// component's job. `''` is the honest terminal case: no field on the
|
|
86
|
+
// item named the person at all, so there is nothing to show.
|
|
87
|
+
,
|
|
88
|
+
displayName: (0, _AvatarGroupBase.getItemName)(target.item) ?? '',
|
|
89
|
+
username: target.item.username,
|
|
90
|
+
onPressProfile: onPressItem ? () => onPressItem(target.item, target.index) : undefined,
|
|
91
|
+
action: renderItemAction?.(target.item, target.index)
|
|
114
92
|
})
|
|
115
|
-
})]
|
|
93
|
+
}) : null]
|
|
116
94
|
});
|
|
117
95
|
};
|
|
118
|
-
const webStyles = _reactNative.StyleSheet.create({
|
|
119
|
-
floating: {
|
|
120
|
-
position: _webViewStyle.WEB_POSITION_FIXED
|
|
121
|
-
},
|
|
122
|
-
card: {
|
|
123
|
-
width: CARD_WIDTH
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
96
|
const AvatarGroup = exports.AvatarGroup = /*#__PURE__*/(0, _react.memo)(AvatarGroupWebComponent);
|
|
127
97
|
AvatarGroup.displayName = 'AvatarGroup';
|
|
128
98
|
//# sourceMappingURL=AvatarGroup.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_useAnchorRect","_constants","_HoverCardPanel","_useHoverIntent","_index","_AvatarGroupBase","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","AvatarGroupWebComponent","props","hoverCard","renderItemAction","onPressItem","target","setTarget","useState","open","setOpen","cellRefs","useRef","Map","show","hide","hold","useHoverIntent","HOVER_CARD_CLOSE_DELAY","registerCellRef","useCallback","index","node","current","delete","handleHoverIn","item","anchor","rectOf","dismiss","hoverHandlers","useMemo","undefined","onHoverIn","onHoverOut","jsxs","Fragment","children","jsx","AvatarGroupBase","HoverCardPanel","onDismiss","onPointerEnter","onPointerLeave","label","getItemName","UserHoverCard","avatar","uri","displayName","username","onPressProfile","action","AvatarGroup","exports","memo"],"sourceRoot":"../../../src","sources":["avatar-group/AvatarGroup.web.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAIA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AAI2B,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAD,wB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gC,WAAW,GAAAC,OAAA,CAAAD,WAAA,gBAAG,IAAAE,WAAI,EAACtD,uBAAuB,CAAC;AACxDoD,WAAW,CAACJ,WAAW,GAAG,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","rectOf","node","element","getBoundingClientRect","box","top","bottom","left","right","useAnchorRect","ref","open","anchor","setAnchor","useState","measure","useCallback","current","useLayoutEffect","useEffect","window","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["floating/use-anchor-rect.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_react","require","rectOf","node","element","getBoundingClientRect","box","top","bottom","left","right","useAnchorRect","ref","open","anchor","setAnchor","useState","measure","useCallback","current","useLayoutEffect","useEffect","window","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["floating/use-anchor-rect.ts"],"mappings":";;;;;;;AAUA,IAAAA,MAAA,GAAAC,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,MAAMA,CAACC,IAAiB,EAAyB;EAC/D,MAAMC,OAAO,GAAGD,IAAmE;EACnF,IAAI,OAAOC,OAAO,EAAEC,qBAAqB,KAAK,UAAU,EAAE,OAAO,IAAI;EACrE,MAAMC,GAAG,GAAGF,OAAO,CAACC,qBAAqB,CAAC,CAAC;EAC3C,OAAO;IAAEE,GAAG,EAAED,GAAG,CAACC,GAAG;IAAEC,MAAM,EAAEF,GAAG,CAACE,MAAM;IAAEC,IAAI,EAAEH,GAAG,CAACG,IAAI;IAAEC,KAAK,EAAEJ,GAAG,CAACI;EAAM,CAAC;AAC/E;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAC3BC,GAAiC,EACjCC,IAAa,EACU;EACvB,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAwB,IAAI,CAAC;EAEjE,MAAMC,OAAO,GAAG,IAAAC,kBAAW,EAAC,MAAM;IAChCH,SAAS,CAACb,MAAM,CAACU,GAAG,CAACO,OAAO,CAAC,CAAC;EAChC,CAAC,EAAE,CAACP,GAAG,CAAC,CAAC;EAET,IAAAQ,sBAAe,EAAC,MAAM;IACpB,IAAI,CAACP,IAAI,EAAE;MACTE,SAAS,CAAC,IAAI,CAAC;MACf;IACF;IACAE,OAAO,CAAC,CAAC;EACX,CAAC,EAAE,CAACJ,IAAI,EAAEI,OAAO,CAAC,CAAC;EAEnB,IAAAI,gBAAS,EAAC,MAAM;IACd,IAAI,CAACR,IAAI,IAAI,OAAOS,MAAM,KAAK,WAAW,EAAE;IAC5C;IACA;IACAA,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAEN,OAAO,CAAC;IAC1CK,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAEN,OAAO,EAAE,IAAI,CAAC;IAChD,OAAO,MAAM;MACXK,MAAM,CAACE,mBAAmB,CAAC,QAAQ,EAAEP,OAAO,CAAC;MAC7CK,MAAM,CAACE,mBAAmB,CAAC,QAAQ,EAAEP,OAAO,EAAE,IAAI,CAAC;IACrD,CAAC;EACH,CAAC,EAAE,CAACJ,IAAI,EAAEI,OAAO,CAAC,CAAC;EAEnB,OAAOH,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.HoverCard = HoverCard;
|
|
7
|
+
exports.HoverCardContent = HoverCardContent;
|
|
8
|
+
exports.HoverCardTrigger = HoverCardTrigger;
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _SheetShell = require("../dialog/SheetShell.js");
|
|
11
|
+
var _TriggerSlot = require("../floating/TriggerSlot.js");
|
|
12
|
+
var _useSheetOpenBridge = require("../floating/use-sheet-open-bridge.js");
|
|
13
|
+
var _useControllableState = require("../hooks/use-controllable-state.js");
|
|
14
|
+
var _constants = require("./constants.js");
|
|
15
|
+
var _context = require("./context.js");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
+
/**
|
|
19
|
+
* `HoverCard` — NATIVE. There is no hover on a touch screen, so the card opens
|
|
20
|
+
* on a LONG PRESS of the trigger and presents as a bottom sheet — the shell
|
|
21
|
+
* `Popover`, `DropdownMenu` and `Select` use. A plain press stays with the
|
|
22
|
+
* element under the finger, which is what makes a hover card safe to put on a
|
|
23
|
+
* link or an avatar that already navigates.
|
|
24
|
+
*
|
|
25
|
+
* `openDelay` / `closeDelay` do nothing here: a long press is its own intent.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const noop = () => {};
|
|
29
|
+
function HoverCard({
|
|
30
|
+
children,
|
|
31
|
+
open,
|
|
32
|
+
defaultOpen = false,
|
|
33
|
+
onOpenChange
|
|
34
|
+
}) {
|
|
35
|
+
const [isOpen, setOpen] = (0, _useControllableState.useControllableState)({
|
|
36
|
+
value: open,
|
|
37
|
+
defaultValue: defaultOpen,
|
|
38
|
+
onChange: onOpenChange
|
|
39
|
+
});
|
|
40
|
+
const anchorRef = (0, _react.useRef)(null);
|
|
41
|
+
const value = (0, _react.useMemo)(() => ({
|
|
42
|
+
open: isOpen,
|
|
43
|
+
setOpen,
|
|
44
|
+
anchorRef,
|
|
45
|
+
show: () => setOpen(true),
|
|
46
|
+
hide: () => setOpen(false),
|
|
47
|
+
hold: noop
|
|
48
|
+
}), [isOpen, setOpen]);
|
|
49
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.HoverCardProvider, {
|
|
50
|
+
value: value,
|
|
51
|
+
children: children
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function HoverCardTrigger({
|
|
55
|
+
children,
|
|
56
|
+
asChild,
|
|
57
|
+
disabled,
|
|
58
|
+
className,
|
|
59
|
+
style,
|
|
60
|
+
testID
|
|
61
|
+
}) {
|
|
62
|
+
const card = (0, _context.useHoverCard)();
|
|
63
|
+
const {
|
|
64
|
+
setOpen
|
|
65
|
+
} = card;
|
|
66
|
+
const openCard = (0, _react.useCallback)(() => setOpen(true), [setOpen]);
|
|
67
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TriggerSlot.TriggerSlot, {
|
|
68
|
+
asChild: asChild,
|
|
69
|
+
anchorRef: card.anchorRef,
|
|
70
|
+
className: className,
|
|
71
|
+
style: style,
|
|
72
|
+
testID: testID,
|
|
73
|
+
handle: {
|
|
74
|
+
// The press belongs to the child; composing a no-op keeps its own.
|
|
75
|
+
onPress: noop,
|
|
76
|
+
onLongPress: openCard,
|
|
77
|
+
disabled,
|
|
78
|
+
'aria-haspopup': _constants.HOVER_CARD_TRIGGER_POPUP,
|
|
79
|
+
'aria-expanded': card.open
|
|
80
|
+
},
|
|
81
|
+
children: children
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function HoverCardContent({
|
|
85
|
+
children,
|
|
86
|
+
label = 'Hover card',
|
|
87
|
+
style
|
|
88
|
+
}) {
|
|
89
|
+
const card = (0, _context.useHoverCard)();
|
|
90
|
+
const {
|
|
91
|
+
control,
|
|
92
|
+
onSheetClose
|
|
93
|
+
} = (0, _useSheetOpenBridge.useSheetOpenBridge)(card.open, card.setOpen);
|
|
94
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SheetShell.SheetShell, {
|
|
95
|
+
control: control,
|
|
96
|
+
label: label,
|
|
97
|
+
onClose: onSheetClose,
|
|
98
|
+
contentStyle: [{
|
|
99
|
+
alignItems: 'center'
|
|
100
|
+
}, style],
|
|
101
|
+
children: children
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=HoverCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_SheetShell","_TriggerSlot","_useSheetOpenBridge","_useControllableState","_constants","_context","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","noop","HoverCard","children","open","defaultOpen","onOpenChange","isOpen","setOpen","useControllableState","value","defaultValue","onChange","anchorRef","useRef","useMemo","show","hide","hold","jsx","HoverCardProvider","HoverCardTrigger","asChild","disabled","className","style","testID","card","useHoverCard","openCard","useCallback","TriggerSlot","handle","onPress","onLongPress","HOVER_CARD_TRIGGER_POPUP","HoverCardContent","label","control","onSheetClose","useSheetOpenBridge","SheetShell","onClose","contentStyle","alignItems"],"sourceRoot":"../../../src","sources":["hover-card/HoverCard.tsx"],"mappings":";;;;;;;;AASA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,qBAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAA4D,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAD,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,CAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAA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