@oxy.so/bloom 2.3.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/popover.mdx +73 -19
- 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/calendar/CalendarViewInboxMenu.js +4 -13
- package/lib/commonjs/calendar/CalendarViewInboxMenu.js.map +1 -1
- package/lib/commonjs/calendar/CalendarViewMonthGrid.js +6 -10
- package/lib/commonjs/calendar/CalendarViewMonthGrid.js.map +1 -1
- package/lib/commonjs/dialog/DialogHeader.js +1 -7
- package/lib/commonjs/dialog/DialogHeader.js.map +1 -1
- package/lib/commonjs/floating/FloatingPanel.js +19 -22
- package/lib/commonjs/floating/FloatingPanel.js.map +1 -1
- package/lib/commonjs/floating/constants.js +12 -56
- package/lib/commonjs/floating/constants.js.map +1 -1
- package/lib/commonjs/floating/menu-sub-flyout.js +3 -3
- 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/popover/Popover.js +23 -3
- package/lib/commonjs/popover/Popover.js.map +1 -1
- package/lib/commonjs/popover/Popover.web.js +21 -16
- package/lib/commonjs/popover/Popover.web.js.map +1 -1
- package/lib/commonjs/popover/index.js +31 -0
- package/lib/commonjs/popover/index.js.map +1 -1
- package/lib/commonjs/popover/index.web.js +31 -0
- package/lib/commonjs/popover/index.web.js.map +1 -1
- package/lib/commonjs/popover/parts.js +164 -0
- package/lib/commonjs/popover/parts.js.map +1 -0
- package/lib/commonjs/popover/surface.js +102 -0
- package/lib/commonjs/popover/surface.js.map +1 -0
- package/lib/commonjs/sidebar/parts.js +9 -11
- package/lib/commonjs/sidebar/parts.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/calendar/CalendarViewInboxMenu.js +4 -13
- package/lib/module/calendar/CalendarViewInboxMenu.js.map +1 -1
- package/lib/module/calendar/CalendarViewMonthGrid.js +6 -10
- package/lib/module/calendar/CalendarViewMonthGrid.js.map +1 -1
- package/lib/module/dialog/DialogHeader.js +1 -7
- package/lib/module/dialog/DialogHeader.js.map +1 -1
- package/lib/module/floating/FloatingPanel.js +20 -23
- package/lib/module/floating/FloatingPanel.js.map +1 -1
- package/lib/module/floating/constants.js +11 -55
- package/lib/module/floating/constants.js.map +1 -1
- package/lib/module/floating/menu-sub-flyout.js +3 -3
- 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/popover/Popover.js +23 -3
- package/lib/module/popover/Popover.js.map +1 -1
- package/lib/module/popover/Popover.web.js +22 -17
- package/lib/module/popover/Popover.web.js.map +1 -1
- package/lib/module/popover/index.js +1 -0
- package/lib/module/popover/index.js.map +1 -1
- package/lib/module/popover/index.web.js +1 -0
- package/lib/module/popover/index.web.js.map +1 -1
- package/lib/module/popover/parts.js +154 -0
- package/lib/module/popover/parts.js.map +1 -0
- package/lib/module/popover/surface.js +96 -0
- package/lib/module/popover/surface.js.map +1 -0
- package/lib/module/sidebar/parts.js +9 -11
- package/lib/module/sidebar/parts.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/calendar/CalendarViewInboxMenu.d.ts.map +1 -1
- package/lib/typescript/commonjs/calendar/CalendarViewMonthGrid.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/DialogHeader.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/FloatingPanel.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/constants.d.ts +11 -50
- package/lib/typescript/commonjs/floating/constants.d.ts.map +1 -1
- package/lib/typescript/commonjs/floating/types.d.ts +5 -4
- package/lib/typescript/commonjs/floating/types.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/popover/Popover.d.ts +1 -1
- package/lib/typescript/commonjs/popover/Popover.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/index.d.ts +2 -1
- package/lib/typescript/commonjs/popover/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/index.web.d.ts +2 -1
- package/lib/typescript/commonjs/popover/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/parts.d.ts +7 -0
- package/lib/typescript/commonjs/popover/parts.d.ts.map +1 -0
- package/lib/typescript/commonjs/popover/surface.d.ts +58 -0
- package/lib/typescript/commonjs/popover/surface.d.ts.map +1 -0
- package/lib/typescript/commonjs/popover/types.d.ts +50 -0
- package/lib/typescript/commonjs/popover/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/sidebar/parts.d.ts +2 -2
- package/lib/typescript/commonjs/sidebar/parts.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/calendar/CalendarViewInboxMenu.d.ts.map +1 -1
- package/lib/typescript/module/calendar/CalendarViewMonthGrid.d.ts.map +1 -1
- package/lib/typescript/module/dialog/DialogHeader.d.ts.map +1 -1
- package/lib/typescript/module/floating/FloatingPanel.d.ts.map +1 -1
- package/lib/typescript/module/floating/constants.d.ts +11 -50
- package/lib/typescript/module/floating/constants.d.ts.map +1 -1
- package/lib/typescript/module/floating/types.d.ts +5 -4
- package/lib/typescript/module/floating/types.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/popover/Popover.d.ts +1 -1
- package/lib/typescript/module/popover/Popover.d.ts.map +1 -1
- package/lib/typescript/module/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/index.d.ts +2 -1
- package/lib/typescript/module/popover/index.d.ts.map +1 -1
- package/lib/typescript/module/popover/index.web.d.ts +2 -1
- package/lib/typescript/module/popover/index.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/parts.d.ts +7 -0
- package/lib/typescript/module/popover/parts.d.ts.map +1 -0
- package/lib/typescript/module/popover/surface.d.ts +58 -0
- package/lib/typescript/module/popover/surface.d.ts.map +1 -0
- package/lib/typescript/module/popover/types.d.ts +50 -0
- package/lib/typescript/module/popover/types.d.ts.map +1 -1
- package/lib/typescript/module/sidebar/parts.d.ts +2 -2
- package/lib/typescript/module/sidebar/parts.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/calendar/CalendarViewInboxMenu.tsx +3 -12
- package/src/calendar/CalendarViewMonthGrid.tsx +5 -9
- package/src/dialog/DialogHeader.tsx +1 -6
- package/src/floating/FloatingPanel.tsx +19 -27
- package/src/floating/constants.ts +11 -56
- package/src/floating/menu-sub-flyout.tsx +3 -3
- package/src/floating/types.ts +5 -4
- 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/popover/Popover.tsx +32 -4
- package/src/popover/Popover.web.tsx +31 -17
- package/src/popover/index.ts +17 -1
- package/src/popover/index.web.ts +17 -1
- package/src/popover/parts.tsx +141 -0
- package/src/popover/surface.ts +119 -0
- package/src/popover/types.ts +56 -0
- package/src/sidebar/parts.tsx +8 -11
- package/src/user-hover-card/UserHoverCard.tsx +30 -18
- package/src/user-hover-card/constants.ts +9 -2
|
@@ -34,30 +34,15 @@
|
|
|
34
34
|
* vocabulary rather than rounded onto a Bloom rung — rounding is exactly the
|
|
35
35
|
* substitution that stops a port looking like its original.
|
|
36
36
|
*
|
|
37
|
-
* ── COLOUR
|
|
37
|
+
* ── COLOUR ──────────────────────────────────────────────────────────────────
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* | ------------------------ | ---------------------- | --- |
|
|
47
|
-
* | `bg-surface-elevated` | `bg-popover` | `--popover` is `surfaceContainer`, which sits one step off the page in BOTH schemes (light 249,233,247 vs background 255,239,253; dark 37,29,38 vs 19,12,20). One token, so the panel needs no `dark:` fork — and a `dark:` fork would not be portable anyway, since the fleet disagrees about what `dark:` matches (the website and this harness use the `.dark` class, Mention's build uses the OS scheme) |
|
|
48
|
-
* | `text-primary` (its body colour) | `text-foreground` | same role, same contrast target. NOT Bloom's `--primary`, which is a brand accent |
|
|
49
|
-
* | `border-border-l1` | `border-border` | the hairline between surfaces. `--border` and `--input` are the same expression (`outlineVariant`) in every preset |
|
|
50
|
-
* | `bg-button-ghost-hover` | `bg-accent` | the row highlight wash — already what every other Bloom row paints |
|
|
51
|
-
* | `text-fg-secondary` | `text-muted-foreground`| the single de-emphasis step. Bloom has a third, `textTertiary`, that the target has no name for; using it for a shortcut would be a step further out than the original |
|
|
52
|
-
* | destructive row | `text-error` | Bloom's themed negative, legible in both modes |
|
|
53
|
-
* | `shadow-md shadow-black/5` | `shadow-m` | Bloom's overlay elevation role |
|
|
54
|
-
* | `shadow-sm shadow-black/5` | `shadow-s` | Bloom's control-raise role |
|
|
55
|
-
*
|
|
56
|
-
* That table is now the POPOVER's (`PANEL_CLASS`). The three menu families and
|
|
57
|
-
* the select paint a separate menu recipe instead — geometry still as classes
|
|
58
|
-
* here (`MENU_PANEL_CLASS`, `ROW_CLASS`, …), but colours resolved from the theme
|
|
59
|
-
* ramps by `menu-palette.ts` and applied inline, because those stops exist as no
|
|
60
|
-
* CSS variable a class could name.
|
|
39
|
+
* No colour lives here. Every anchored surface — the three menus, the select
|
|
40
|
+
* and the popover — paints `bg-background-primary-default
|
|
41
|
+
* border-border-button-default shadow-dropdown`, resolved from the theme ramps
|
|
42
|
+
* by `menu-palette.ts` and applied INLINE, because those stops exist as no CSS
|
|
43
|
+
* variable a class could name. (The retired shadcn popover chrome —
|
|
44
|
+
* `bg-popover`, `shadow-m`, `w-72 p-4` — is gone; its geometry now lives in
|
|
45
|
+
* `popover/surface.ts`, also inline.)
|
|
61
46
|
*/
|
|
62
47
|
|
|
63
48
|
/* -------------------------------------------------------------------------- */
|
|
@@ -132,27 +117,11 @@ export const ROW_ICON_SIZE = 16;
|
|
|
132
117
|
export const SELECT_MAX_HEIGHT = 240;
|
|
133
118
|
|
|
134
119
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* `200ms` and `--ease-out-quint` = `cubic-bezier(0.22, 1, 0.36, 1)` are the
|
|
138
|
-
* target's own. Both directions take the same duration, as the target does; the
|
|
139
|
-
* exit's value is also what `FloatingPanel` waits before it unmounts, so the two
|
|
140
|
-
* cannot drift apart.
|
|
141
|
-
*/
|
|
142
|
-
export const PANEL_MOTION_DURATION = 200;
|
|
143
|
-
export const PANEL_MOTION_EASING = [0.22, 1, 0.36, 1] as const;
|
|
144
|
-
|
|
145
|
-
/** `zoom-in-95` / `zoom-out-95`. */
|
|
146
|
-
export const PANEL_MOTION_SCALE_FROM = 0.95;
|
|
147
|
-
|
|
148
|
-
/** `slide-in-from-<side>-2` — 8px along the axis the surface sits on. */
|
|
149
|
-
export const PANEL_MOTION_SLIDE = 8;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* The MENU surfaces' own motion: `transition
|
|
120
|
+
* The motion EVERY anchored surface runs — menus, the listbox and the popover
|
|
121
|
+
* alike, because every popover class string carries it: `transition
|
|
153
122
|
* duration-150 ease-out` between the resting panel and `opacity-0 scale-95
|
|
154
123
|
* blur-[2px]`, the same shape in and out, with no slide. `ease-out` is Tailwind
|
|
155
|
-
* v4's `cubic-bezier(0, 0, 0.2, 1)`.
|
|
124
|
+
* v4's `cubic-bezier(0, 0, 0.2, 1)`.
|
|
156
125
|
*/
|
|
157
126
|
export const MENU_MOTION_DURATION = 150;
|
|
158
127
|
export const MENU_MOTION_EASING = [0, 0, 0.2, 1] as const;
|
|
@@ -164,17 +133,6 @@ export const MENU_MOTION_BLUR = 2;
|
|
|
164
133
|
/* The floating panel */
|
|
165
134
|
/* -------------------------------------------------------------------------- */
|
|
166
135
|
|
|
167
|
-
/**
|
|
168
|
-
* `rounded-2xl border bg-surface-elevated p-1 shadow-md text-primary`.
|
|
169
|
-
*
|
|
170
|
-
* `p-space-4` is FOUR-sided: the rows sit 4px in from the border on every edge,
|
|
171
|
-
* which is also what gives the separator's `-mx-space-4` something to bleed back
|
|
172
|
-
* through. `overflow-hidden` keeps a row's 12px highlight inside the panel's own
|
|
173
|
-
* 16px corner.
|
|
174
|
-
*/
|
|
175
|
-
export const PANEL_CLASS =
|
|
176
|
-
'overflow-hidden rounded-radius-16 border border-border bg-popover p-space-4 shadow-m';
|
|
177
|
-
|
|
178
136
|
/**
|
|
179
137
|
* The menu panel: `rounded-2xl border p-2.5
|
|
180
138
|
* max-w-[calc(100vw-32px)]`, with the rows 4px apart (`gap-1` on the panel's
|
|
@@ -223,9 +181,6 @@ export const MENU_SUB_PANEL_CLASS = 'w-[266px]';
|
|
|
223
181
|
export const MENU_SUB_SCROLL_CLASS =
|
|
224
182
|
'-mx-[10px] px-[10px] gap-space-4 max-h-96 overflow-y-auto overflow-x-hidden';
|
|
225
183
|
|
|
226
|
-
/** `w-72 p-4` — a popover holds prose, so it is a fixed card with a real inset. */
|
|
227
|
-
export const POPOVER_CLASS = 'w-72 p-space-16';
|
|
228
|
-
|
|
229
184
|
/* -------------------------------------------------------------------------- */
|
|
230
185
|
/* The menu row vocabulary */
|
|
231
186
|
/* -------------------------------------------------------------------------- */
|
|
@@ -77,8 +77,8 @@ const CLOSE_DELAY_MS = 300;
|
|
|
77
77
|
* How many animation frames `useFlyoutAnchor` keeps re-measuring after a flyout
|
|
78
78
|
* opens.
|
|
79
79
|
*
|
|
80
|
-
* Long enough to outlast the parent panel's own enter (`
|
|
81
|
-
* ~
|
|
80
|
+
* Long enough to outlast the parent panel's own enter (`MENU_MOTION_DURATION`,
|
|
81
|
+
* ~9 frames at 60Hz) with room for a slower machine, and cheap because a
|
|
82
82
|
* settled box re-measures to the identical value and sets no state.
|
|
83
83
|
*/
|
|
84
84
|
const SETTLE_FRAMES = 20;
|
|
@@ -184,7 +184,7 @@ function focusFirstItem(node: DomNode | null): void {
|
|
|
184
184
|
*
|
|
185
185
|
* Taking the horizontal axis off the panel also makes {@link MENU_SUB_SIDE_OFFSET}
|
|
186
186
|
* mean the gap you actually see, with no dependence on the panel's inset: change
|
|
187
|
-
* `
|
|
187
|
+
* `MENU_PANEL_CLASS`'s padding and the gap does not move.
|
|
188
188
|
*
|
|
189
189
|
* The panel is found with `closest`, so a sub-menu nested inside a sub-menu
|
|
190
190
|
* anchors to ITS parent rather than to the root. If there is no panel ancestor
|
package/src/floating/types.ts
CHANGED
|
@@ -122,10 +122,11 @@ export interface FloatingPanelProps extends FloatingPositionProps {
|
|
|
122
122
|
testID?: string;
|
|
123
123
|
children?: React.ReactNode;
|
|
124
124
|
/**
|
|
125
|
-
* Which chrome
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
* `
|
|
125
|
+
* Which chrome the panel wears; all three run the same 150ms fade + scale +
|
|
126
|
+
* blur. `'menu'` and `'listbox'` are the menu recipe — the `p-2.5` action
|
|
127
|
+
* menu and the `p-2` select listbox — painted from `menu-palette.ts`.
|
|
128
|
+
* `'popover'` (the default) paints NOTHING itself: `Popover` resolves its
|
|
129
|
+
* panel inline (`popover/surface.ts`) and passes it as `style`.
|
|
129
130
|
*/
|
|
130
131
|
surface?: 'popover' | 'menu' | 'listbox';
|
|
131
132
|
}
|
|
@@ -19,7 +19,7 @@ import type { FloatingAnchor } from './types';
|
|
|
19
19
|
* interface, so a ref that is NOT a DOM node (a jsdom stub, a native build that
|
|
20
20
|
* reached this file by accident) answers `null` instead of throwing.
|
|
21
21
|
*/
|
|
22
|
-
function rectOf(node: View | null): FloatingAnchor | null {
|
|
22
|
+
export function rectOf(node: View | null): FloatingAnchor | null {
|
|
23
23
|
const element = node as unknown as { getBoundingClientRect?: () => DOMRect } | null;
|
|
24
24
|
if (typeof element?.getBoundingClientRect !== 'function') return null;
|
|
25
25
|
const box = element.getBoundingClientRect();
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `HoverCard` — NATIVE. There is no hover on a touch screen, so the card opens
|
|
3
|
+
* on a LONG PRESS of the trigger and presents as a bottom sheet — the shell
|
|
4
|
+
* `Popover`, `DropdownMenu` and `Select` use. A plain press stays with the
|
|
5
|
+
* element under the finger, which is what makes a hover card safe to put on a
|
|
6
|
+
* link or an avatar that already navigates.
|
|
7
|
+
*
|
|
8
|
+
* `openDelay` / `closeDelay` do nothing here: a long press is its own intent.
|
|
9
|
+
*/
|
|
10
|
+
import React, { useCallback, useMemo, useRef } from 'react';
|
|
11
|
+
import type { View } from 'react-native';
|
|
12
|
+
|
|
13
|
+
import { SheetShell } from '../dialog/SheetShell';
|
|
14
|
+
import { TriggerSlot } from '../floating/TriggerSlot';
|
|
15
|
+
import { useSheetOpenBridge } from '../floating/use-sheet-open-bridge';
|
|
16
|
+
import { useControllableState } from '../hooks/use-controllable-state';
|
|
17
|
+
import { HOVER_CARD_TRIGGER_POPUP } from './constants';
|
|
18
|
+
import { HoverCardProvider, useHoverCard } from './context';
|
|
19
|
+
import type { HoverCardContentProps, HoverCardProps, HoverCardTriggerProps } from './types';
|
|
20
|
+
|
|
21
|
+
const noop = () => {};
|
|
22
|
+
|
|
23
|
+
export function HoverCard({ children, open, defaultOpen = false, onOpenChange }: HoverCardProps) {
|
|
24
|
+
const [isOpen, setOpen] = useControllableState<boolean>({
|
|
25
|
+
value: open,
|
|
26
|
+
defaultValue: defaultOpen,
|
|
27
|
+
onChange: onOpenChange,
|
|
28
|
+
});
|
|
29
|
+
const anchorRef = useRef<View | null>(null);
|
|
30
|
+
const value = useMemo(
|
|
31
|
+
() => ({
|
|
32
|
+
open: isOpen,
|
|
33
|
+
setOpen,
|
|
34
|
+
anchorRef,
|
|
35
|
+
show: () => setOpen(true),
|
|
36
|
+
hide: () => setOpen(false),
|
|
37
|
+
hold: noop,
|
|
38
|
+
}),
|
|
39
|
+
[isOpen, setOpen],
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return <HoverCardProvider value={value}>{children}</HoverCardProvider>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function HoverCardTrigger({
|
|
46
|
+
children,
|
|
47
|
+
asChild,
|
|
48
|
+
disabled,
|
|
49
|
+
className,
|
|
50
|
+
style,
|
|
51
|
+
testID,
|
|
52
|
+
}: HoverCardTriggerProps) {
|
|
53
|
+
const card = useHoverCard();
|
|
54
|
+
const { setOpen } = card;
|
|
55
|
+
const openCard = useCallback(() => setOpen(true), [setOpen]);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<TriggerSlot
|
|
59
|
+
asChild={asChild}
|
|
60
|
+
anchorRef={card.anchorRef}
|
|
61
|
+
className={className}
|
|
62
|
+
style={style}
|
|
63
|
+
testID={testID}
|
|
64
|
+
handle={{
|
|
65
|
+
// The press belongs to the child; composing a no-op keeps its own.
|
|
66
|
+
onPress: noop,
|
|
67
|
+
onLongPress: openCard,
|
|
68
|
+
disabled,
|
|
69
|
+
'aria-haspopup': HOVER_CARD_TRIGGER_POPUP,
|
|
70
|
+
'aria-expanded': card.open,
|
|
71
|
+
}}>
|
|
72
|
+
{children}
|
|
73
|
+
</TriggerSlot>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function HoverCardContent({ children, label = 'Hover card', style }: HoverCardContentProps) {
|
|
78
|
+
const card = useHoverCard();
|
|
79
|
+
const { control, onSheetClose } = useSheetOpenBridge(card.open, card.setOpen);
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<SheetShell
|
|
83
|
+
control={control}
|
|
84
|
+
label={label}
|
|
85
|
+
onClose={onSheetClose}
|
|
86
|
+
contentStyle={[{ alignItems: 'center' }, style]}>
|
|
87
|
+
{children}
|
|
88
|
+
</SheetShell>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `HoverCard` — WEB. A card that opens while the pointer rests on its trigger
|
|
3
|
+
* (or keyboard focus lands on it) and stays up while the pointer travels onto
|
|
4
|
+
* it. Positioned, portaled, ranked and dismissed by `floating/FloatingPanel`
|
|
5
|
+
* through `HoverCardPanel`.
|
|
6
|
+
*
|
|
7
|
+
* Touch pointers are ignored on purpose: a tap on a touch screen is a press, and
|
|
8
|
+
* the element under it (a link, an avatar) owns that. A touch device reaches the
|
|
9
|
+
* card the way native does — see `HoverCard.tsx`.
|
|
10
|
+
*/
|
|
11
|
+
import React, { useCallback, useMemo, useRef } from 'react';
|
|
12
|
+
import type { NativeSyntheticEvent, View } from 'react-native';
|
|
13
|
+
|
|
14
|
+
import { useAnchorRect } from '../floating/use-anchor-rect';
|
|
15
|
+
import { useControllableState } from '../hooks/use-controllable-state';
|
|
16
|
+
import { StyledView } from '../styles/styled-primitives';
|
|
17
|
+
import {
|
|
18
|
+
HOVER_CARD_CLOSE_DELAY,
|
|
19
|
+
HOVER_CARD_OPEN_DELAY,
|
|
20
|
+
HOVER_CARD_TRIGGER_POPUP,
|
|
21
|
+
} from './constants';
|
|
22
|
+
import { HoverCardProvider, useHoverCard } from './context';
|
|
23
|
+
import { HoverCardPanel } from './HoverCardPanel';
|
|
24
|
+
import type { HoverCardContentProps, HoverCardProps, HoverCardTriggerProps } from './types';
|
|
25
|
+
import { useHoverIntent } from './use-hover-intent';
|
|
26
|
+
|
|
27
|
+
export function HoverCard({
|
|
28
|
+
children,
|
|
29
|
+
open,
|
|
30
|
+
defaultOpen = false,
|
|
31
|
+
onOpenChange,
|
|
32
|
+
openDelay = HOVER_CARD_OPEN_DELAY,
|
|
33
|
+
closeDelay = HOVER_CARD_CLOSE_DELAY,
|
|
34
|
+
}: HoverCardProps) {
|
|
35
|
+
const [isOpen, setOpen] = useControllableState<boolean>({
|
|
36
|
+
value: open,
|
|
37
|
+
defaultValue: defaultOpen,
|
|
38
|
+
onChange: onOpenChange,
|
|
39
|
+
});
|
|
40
|
+
const anchorRef = useRef<View | null>(null);
|
|
41
|
+
const intent = useHoverIntent(isOpen, setOpen, openDelay, closeDelay);
|
|
42
|
+
const value = useMemo(
|
|
43
|
+
() => ({ open: isOpen, setOpen, anchorRef, ...intent }),
|
|
44
|
+
[isOpen, setOpen, intent],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return <HoverCardProvider value={value}>{children}</HoverCardProvider>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
type PointerLike = NativeSyntheticEvent<{ pointerType?: string }>;
|
|
51
|
+
type FocusLike = { target?: unknown };
|
|
52
|
+
|
|
53
|
+
/** Mouse and pen hover; a touch "hover" is the first half of a tap. */
|
|
54
|
+
function isHoverPointer(event: PointerLike): boolean {
|
|
55
|
+
return event.nativeEvent?.pointerType !== 'touch';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Keyboard focus only. A mouse click focuses the element it lands on too, and
|
|
60
|
+
* opening on that would reopen a card the click just meant to get past.
|
|
61
|
+
*/
|
|
62
|
+
function isFocusVisible(event: FocusLike): boolean {
|
|
63
|
+
const target = event.target as { matches?: (selector: string) => boolean } | null;
|
|
64
|
+
try {
|
|
65
|
+
return target?.matches?.(':focus-visible') ?? false;
|
|
66
|
+
} catch {
|
|
67
|
+
// An engine without `:focus-visible` throws on the selector.
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function HoverCardTrigger({
|
|
73
|
+
children,
|
|
74
|
+
disabled,
|
|
75
|
+
className,
|
|
76
|
+
style,
|
|
77
|
+
testID,
|
|
78
|
+
}: HoverCardTriggerProps) {
|
|
79
|
+
const card = useHoverCard();
|
|
80
|
+
const { show, hide } = card;
|
|
81
|
+
|
|
82
|
+
const onPointerEnter = useCallback(
|
|
83
|
+
(event: PointerLike) => {
|
|
84
|
+
if (!disabled && isHoverPointer(event)) show();
|
|
85
|
+
},
|
|
86
|
+
[disabled, show],
|
|
87
|
+
);
|
|
88
|
+
const onPointerLeave = useCallback(
|
|
89
|
+
(event: PointerLike) => {
|
|
90
|
+
if (isHoverPointer(event)) hide();
|
|
91
|
+
},
|
|
92
|
+
[hide],
|
|
93
|
+
);
|
|
94
|
+
const onFocus = useCallback(
|
|
95
|
+
(event: FocusLike) => {
|
|
96
|
+
if (!disabled && isFocusVisible(event)) show();
|
|
97
|
+
},
|
|
98
|
+
[disabled, show],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<StyledView
|
|
104
|
+
ref={card.anchorRef}
|
|
105
|
+
className={className}
|
|
106
|
+
style={[{ alignSelf: 'flex-start' }, style]}
|
|
107
|
+
testID={testID}
|
|
108
|
+
onPointerEnter={onPointerEnter}
|
|
109
|
+
onPointerLeave={onPointerLeave}
|
|
110
|
+
aria-haspopup={HOVER_CARD_TRIGGER_POPUP}
|
|
111
|
+
aria-expanded={card.open}
|
|
112
|
+
// Focus and blur BUBBLE here from the focusable child (React's `onFocus`
|
|
113
|
+
// is `focusin`), so the wrapper needs no tab stop of its own.
|
|
114
|
+
onFocus={onFocus}
|
|
115
|
+
onBlur={hide}>
|
|
116
|
+
{children}
|
|
117
|
+
</StyledView>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function HoverCardContent({
|
|
122
|
+
children,
|
|
123
|
+
label = 'Hover card',
|
|
124
|
+
padded,
|
|
125
|
+
side,
|
|
126
|
+
align,
|
|
127
|
+
sideOffset,
|
|
128
|
+
alignOffset,
|
|
129
|
+
className,
|
|
130
|
+
style,
|
|
131
|
+
testID,
|
|
132
|
+
}: HoverCardContentProps) {
|
|
133
|
+
const card = useHoverCard();
|
|
134
|
+
const anchor = useAnchorRect(card.anchorRef, card.open);
|
|
135
|
+
const { setOpen, hold, hide } = card;
|
|
136
|
+
const dismiss = useCallback(() => {
|
|
137
|
+
hold();
|
|
138
|
+
setOpen(false);
|
|
139
|
+
}, [hold, setOpen]);
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<HoverCardPanel
|
|
143
|
+
open={card.open}
|
|
144
|
+
anchor={anchor}
|
|
145
|
+
onDismiss={dismiss}
|
|
146
|
+
onPointerEnter={hold}
|
|
147
|
+
onPointerLeave={hide}
|
|
148
|
+
label={label}
|
|
149
|
+
padded={padded}
|
|
150
|
+
side={side}
|
|
151
|
+
align={align}
|
|
152
|
+
sideOffset={sideOffset}
|
|
153
|
+
alignOffset={alignOffset}
|
|
154
|
+
className={className}
|
|
155
|
+
style={style}
|
|
156
|
+
testID={testID}>
|
|
157
|
+
{children}
|
|
158
|
+
</HoverCardPanel>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The floating hover-card surface — WEB ONLY, imported by `.web.tsx` files and
|
|
3
|
+
* nothing else (it renders `floating/FloatingPanel`, which portals through
|
|
4
|
+
* `../portal/index.web`).
|
|
5
|
+
*
|
|
6
|
+
* Shared by `HoverCardContent` and `AvatarGroup`'s web hover card, so the two
|
|
7
|
+
* agree on placement, motion, dismissal and the pointer bridge by construction.
|
|
8
|
+
*
|
|
9
|
+
* What it adds to `FloatingPanel`:
|
|
10
|
+
*
|
|
11
|
+
* - The MENU surface (radius 16, 1px border, dropdown shadow, 150ms fade +
|
|
12
|
+
* `scale-95` + 2px blur), NON-modal: nothing is laid over the app, so the
|
|
13
|
+
* page under a hover card stays scrollable and clickable, and an outside
|
|
14
|
+
* press or Escape dismisses it.
|
|
15
|
+
* - `overflow: visible` and its own inset. The menu panel clips and pads for
|
|
16
|
+
* rows; a hover card's content is arbitrary, and `UserHoverCard`'s `footer`
|
|
17
|
+
* is documented as unclipped.
|
|
18
|
+
* - The pointer BRIDGE, on a `View` inside the panel that fills it. It listens
|
|
19
|
+
* to `pointerenter`/`pointerleave`, never to a `Pressable`'s hover: RNW's
|
|
20
|
+
* `Pressable` dispatches a bubbling `react-gui:hover:lock` on itself, and a
|
|
21
|
+
* hovered ancestor `Pressable` ends its own hover for any lock it did not
|
|
22
|
+
* send — so a `Pressable` bridge dismissed the card the moment the cursor
|
|
23
|
+
* reached a button inside it. Pointer enter/leave do not bubble and do not
|
|
24
|
+
* fire between descendants.
|
|
25
|
+
*/
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { StyleSheet, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
28
|
+
|
|
29
|
+
import { FloatingPanel } from '../floating/FloatingPanel';
|
|
30
|
+
import type { FloatingAnchor, FloatingPositionProps } from '../floating/types';
|
|
31
|
+
import type { WebCssStyle } from '../styles/web-view-style';
|
|
32
|
+
import { HOVER_CARD_INSET, HOVER_CARD_SIDE_OFFSET } from './constants';
|
|
33
|
+
import { HoverCardSurfaceProvider } from './context';
|
|
34
|
+
|
|
35
|
+
export interface HoverCardPanelProps extends FloatingPositionProps {
|
|
36
|
+
open: boolean;
|
|
37
|
+
anchor: FloatingAnchor | null;
|
|
38
|
+
onDismiss: () => void;
|
|
39
|
+
/** The pointer reached the card. */
|
|
40
|
+
onPointerEnter: () => void;
|
|
41
|
+
/** The pointer left the card. */
|
|
42
|
+
onPointerLeave: () => void;
|
|
43
|
+
label: string;
|
|
44
|
+
padded?: boolean;
|
|
45
|
+
className?: string;
|
|
46
|
+
style?: StyleProp<ViewStyle>;
|
|
47
|
+
testID?: string;
|
|
48
|
+
children?: React.ReactNode;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function HoverCardPanel({
|
|
52
|
+
open,
|
|
53
|
+
anchor,
|
|
54
|
+
onDismiss,
|
|
55
|
+
onPointerEnter,
|
|
56
|
+
onPointerLeave,
|
|
57
|
+
label,
|
|
58
|
+
padded = true,
|
|
59
|
+
side = 'bottom',
|
|
60
|
+
align = 'center',
|
|
61
|
+
sideOffset = HOVER_CARD_SIDE_OFFSET,
|
|
62
|
+
alignOffset,
|
|
63
|
+
className,
|
|
64
|
+
style,
|
|
65
|
+
testID,
|
|
66
|
+
children,
|
|
67
|
+
}: HoverCardPanelProps) {
|
|
68
|
+
return (
|
|
69
|
+
<FloatingPanel
|
|
70
|
+
open={open}
|
|
71
|
+
anchor={anchor}
|
|
72
|
+
surface="menu"
|
|
73
|
+
modal={false}
|
|
74
|
+
role="dialog"
|
|
75
|
+
label={label}
|
|
76
|
+
side={side}
|
|
77
|
+
align={align}
|
|
78
|
+
sideOffset={sideOffset}
|
|
79
|
+
alignOffset={alignOffset}
|
|
80
|
+
onDismiss={onDismiss}
|
|
81
|
+
className={className}
|
|
82
|
+
style={[styles.panel, style]}
|
|
83
|
+
testID={testID}>
|
|
84
|
+
<View
|
|
85
|
+
onPointerEnter={onPointerEnter}
|
|
86
|
+
onPointerLeave={onPointerLeave}
|
|
87
|
+
style={padded ? styles.padded : null}>
|
|
88
|
+
<HoverCardSurfaceProvider value>{children}</HoverCardSurfaceProvider>
|
|
89
|
+
</View>
|
|
90
|
+
</FloatingPanel>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const panel: WebCssStyle = {
|
|
95
|
+
// The menu class pads and clips for ROWS; the bridge has to cover the whole
|
|
96
|
+
// panel, so the inset moves onto it.
|
|
97
|
+
paddingTop: 0,
|
|
98
|
+
paddingBottom: 0,
|
|
99
|
+
paddingLeft: 0,
|
|
100
|
+
paddingRight: 0,
|
|
101
|
+
overflow: 'visible',
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const styles = StyleSheet.create({
|
|
105
|
+
panel,
|
|
106
|
+
padded: {
|
|
107
|
+
paddingTop: HOVER_CARD_INSET,
|
|
108
|
+
paddingBottom: HOVER_CARD_INSET,
|
|
109
|
+
paddingLeft: HOVER_CARD_INSET,
|
|
110
|
+
paddingRight: HOVER_CARD_INSET,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hover intent timings. A card that opens the instant a cursor crosses a name
|
|
3
|
+
* flashes across every link the pointer travels over on its way somewhere else;
|
|
4
|
+
* one that closes the instant the cursor leaves the trigger can never be
|
|
5
|
+
* reached. The open delay filters the first, the close delay bridges the second
|
|
6
|
+
* — the cursor crosses the `HOVER_CARD_SIDE_OFFSET` gap well inside it.
|
|
7
|
+
*/
|
|
8
|
+
export const HOVER_CARD_OPEN_DELAY = 400;
|
|
9
|
+
export const HOVER_CARD_CLOSE_DELAY = 150;
|
|
10
|
+
|
|
11
|
+
/** Gap between the trigger and the card. */
|
|
12
|
+
export const HOVER_CARD_SIDE_OFFSET = 8;
|
|
13
|
+
|
|
14
|
+
/** Panel inset, the same one `UserHoverCard` draws on its own. */
|
|
15
|
+
export const HOVER_CARD_INSET = 15;
|
|
16
|
+
|
|
17
|
+
/** What a trigger announces it opens. */
|
|
18
|
+
export const HOVER_CARD_TRIGGER_POPUP = 'dialog';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `HoverCard`'s own state, plus the one fact a child card needs to know.
|
|
3
|
+
*/
|
|
4
|
+
import { createContext, useContext, type RefObject } from 'react';
|
|
5
|
+
import type { View } from 'react-native';
|
|
6
|
+
|
|
7
|
+
export interface HoverCardContextValue {
|
|
8
|
+
open: boolean;
|
|
9
|
+
setOpen: (open: boolean) => void;
|
|
10
|
+
anchorRef: RefObject<View | null>;
|
|
11
|
+
/** Open after the open delay (restarts nothing if already pending). */
|
|
12
|
+
show: () => void;
|
|
13
|
+
/** Close after the close delay. */
|
|
14
|
+
hide: () => void;
|
|
15
|
+
/** Cancel whatever is pending — the pointer arrived where it was headed. */
|
|
16
|
+
hold: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const HoverCardContext = createContext<HoverCardContextValue | null>(null);
|
|
20
|
+
HoverCardContext.displayName = 'BloomHoverCardContext';
|
|
21
|
+
|
|
22
|
+
export const HoverCardProvider = HoverCardContext.Provider;
|
|
23
|
+
|
|
24
|
+
export function useHoverCard(): HoverCardContextValue {
|
|
25
|
+
const value = useContext(HoverCardContext);
|
|
26
|
+
if (!value) {
|
|
27
|
+
throw new Error('HoverCard parts must be rendered inside a <HoverCard>.');
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `true` inside a floating hover-card panel that ALREADY draws the surface
|
|
34
|
+
* (border, background, shadow, inset) and runs the entrance. `UserHoverCard`
|
|
35
|
+
* reads it to paint only its content, so the card never renders a surface
|
|
36
|
+
* inside a surface.
|
|
37
|
+
*/
|
|
38
|
+
const HoverCardSurfaceContext = createContext(false);
|
|
39
|
+
HoverCardSurfaceContext.displayName = 'BloomHoverCardSurfaceContext';
|
|
40
|
+
|
|
41
|
+
export const HoverCardSurfaceProvider = HoverCardSurfaceContext.Provider;
|
|
42
|
+
|
|
43
|
+
export function useInsideHoverCardSurface(): boolean {
|
|
44
|
+
return useContext(HoverCardSurfaceContext);
|
|
45
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent } from './HoverCard';
|
|
2
|
+
export {
|
|
3
|
+
HOVER_CARD_CLOSE_DELAY,
|
|
4
|
+
HOVER_CARD_OPEN_DELAY,
|
|
5
|
+
HOVER_CARD_SIDE_OFFSET,
|
|
6
|
+
} from './constants';
|
|
7
|
+
export type { HoverCardProps, HoverCardTriggerProps, HoverCardContentProps } from './types';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent } from './HoverCard.web';
|
|
2
|
+
export {
|
|
3
|
+
HOVER_CARD_CLOSE_DELAY,
|
|
4
|
+
HOVER_CARD_OPEN_DELAY,
|
|
5
|
+
HOVER_CARD_SIDE_OFFSET,
|
|
6
|
+
} from './constants';
|
|
7
|
+
export type { HoverCardProps, HoverCardTriggerProps, HoverCardContentProps } from './types';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { FloatingPositionProps, OverlayOpenProps } from '../floating/types';
|
|
4
|
+
|
|
5
|
+
export interface HoverCardProps extends OverlayOpenProps {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Milliseconds the pointer (or keyboard focus) has to rest on the trigger
|
|
9
|
+
* before the card opens. Web only. Defaults to `400`.
|
|
10
|
+
*/
|
|
11
|
+
openDelay?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Milliseconds the card stays up after the pointer leaves the trigger or the
|
|
14
|
+
* card — long enough to cross the gap between them. Web only. Defaults to
|
|
15
|
+
* `150`.
|
|
16
|
+
*/
|
|
17
|
+
closeDelay?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface HoverCardTriggerProps {
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* NATIVE: merge the long-press into the single element child instead of
|
|
24
|
+
* wrapping it in Bloom's own `Pressable`. Use it whenever the child is itself
|
|
25
|
+
* pressable (a link, an avatar that opens a profile) — a wrapping `Pressable`
|
|
26
|
+
* never receives the long press, because the inner one wins the responder.
|
|
27
|
+
* WEB: ignored; the trigger listens for pointer and focus on a wrapper, so
|
|
28
|
+
* there is nothing to merge.
|
|
29
|
+
*/
|
|
30
|
+
asChild?: boolean;
|
|
31
|
+
/** A disabled trigger never opens the card. */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
className?: string;
|
|
34
|
+
style?: StyleProp<ViewStyle>;
|
|
35
|
+
testID?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface HoverCardContentProps extends FloatingPositionProps {
|
|
39
|
+
children?: React.ReactNode;
|
|
40
|
+
/** Accessible name of the card. Defaults to `'Hover card'`. */
|
|
41
|
+
label?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Draw Bloom's floating surface around the content (radius 16, 1px border,
|
|
44
|
+
* dropdown shadow, 15px inset). Defaults to `true`. A child that paints its
|
|
45
|
+
* own surface — `UserHoverCard` does, and detects this panel by itself — does
|
|
46
|
+
* not need `false`.
|
|
47
|
+
*/
|
|
48
|
+
padded?: boolean;
|
|
49
|
+
/** Appended to the panel's own classes. */
|
|
50
|
+
className?: string;
|
|
51
|
+
style?: StyleProp<ViewStyle>;
|
|
52
|
+
testID?: string;
|
|
53
|
+
}
|