@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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Delayed open/close for a hover surface. One timer, so a pending open and a
|
|
5
|
+
* pending close can never both fire: every call replaces what was scheduled.
|
|
6
|
+
*
|
|
7
|
+
* `setOpen` is only called when the value would CHANGE — a controlled
|
|
8
|
+
* `onOpenChange` is not told "false" every time the pointer brushes past a
|
|
9
|
+
* trigger whose card never opened.
|
|
10
|
+
*/
|
|
11
|
+
export function useHoverIntent(
|
|
12
|
+
open: boolean,
|
|
13
|
+
setOpen: (open: boolean) => void,
|
|
14
|
+
openDelay: number,
|
|
15
|
+
closeDelay: number,
|
|
16
|
+
) {
|
|
17
|
+
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
18
|
+
const latest = useRef({ open, setOpen });
|
|
19
|
+
latest.current = { open, setOpen };
|
|
20
|
+
|
|
21
|
+
const hold = useCallback(() => {
|
|
22
|
+
if (timer.current !== null) {
|
|
23
|
+
clearTimeout(timer.current);
|
|
24
|
+
timer.current = null;
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
|
|
28
|
+
const schedule = useCallback(
|
|
29
|
+
(next: boolean, delay: number) => {
|
|
30
|
+
hold();
|
|
31
|
+
const apply = () => {
|
|
32
|
+
timer.current = null;
|
|
33
|
+
if (latest.current.open !== next) latest.current.setOpen(next);
|
|
34
|
+
};
|
|
35
|
+
if (delay <= 0) apply();
|
|
36
|
+
else timer.current = setTimeout(apply, delay);
|
|
37
|
+
},
|
|
38
|
+
[hold],
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const show = useCallback(() => schedule(true, openDelay), [schedule, openDelay]);
|
|
42
|
+
const hide = useCallback(() => schedule(false, closeDelay), [schedule, closeDelay]);
|
|
43
|
+
|
|
44
|
+
useEffect(() => hold, [hold]);
|
|
45
|
+
|
|
46
|
+
return useMemo(() => ({ show, hide, hold }), [show, hide, hold]);
|
|
47
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -328,6 +328,7 @@ export * from './select';
|
|
|
328
328
|
export * from './context-menu';
|
|
329
329
|
export * from './menubar';
|
|
330
330
|
export * from './popover';
|
|
331
|
+
export * from './hover-card';
|
|
331
332
|
export { AlertDialog } from './alert-dialog';
|
|
332
333
|
export type { AlertDialogProps, AlertDialogActionStyle } from './alert-dialog';
|
|
333
334
|
export { Command } from './command';
|
package/src/index.web.ts
CHANGED
|
@@ -333,6 +333,7 @@ export * from './select/index.web';
|
|
|
333
333
|
export * from './context-menu/index.web';
|
|
334
334
|
export * from './menubar/index.web';
|
|
335
335
|
export * from './popover/index.web';
|
|
336
|
+
export * from './hover-card/index.web';
|
|
336
337
|
export { AlertDialog } from './alert-dialog/index.web';
|
|
337
338
|
export type { AlertDialogProps, AlertDialogActionStyle } from './alert-dialog/index.web';
|
|
338
339
|
export { Command } from './command/index.web';
|
package/src/popover/Popover.tsx
CHANGED
|
@@ -6,10 +6,17 @@
|
|
|
6
6
|
*
|
|
7
7
|
* The public API is Radix/shadcn's — `open` / `defaultOpen` / `onOpenChange` on
|
|
8
8
|
* the root, `asChild` on the trigger. Unlike the menus, a popover's body is
|
|
9
|
-
* arbitrary content, so this family publishes no rows
|
|
9
|
+
* arbitrary content, so this family publishes no rows — only the panel
|
|
10
|
+
* parts (`parts.tsx`).
|
|
11
|
+
*
|
|
12
|
+
* The sheet is the chrome here (its surface, corner and drag handle belong to
|
|
13
|
+
* `SheetShell`), so only the BODY takes the panel geometry: the `p-2.5`
|
|
14
|
+
* inset on the sides and bottom — the same 10px the web panel has, which is what
|
|
15
|
+
* `PopoverSeparator`'s full-bleed rule and `PopoverHeader`/`PopoverFooter`'s
|
|
16
|
+
* `px-2` are measured against — below the handle's own 20px clearance.
|
|
10
17
|
*/
|
|
11
18
|
import React, { useMemo, useRef } from 'react';
|
|
12
|
-
import type
|
|
19
|
+
import { StyleSheet, type View } from 'react-native';
|
|
13
20
|
|
|
14
21
|
import { SheetShell } from '../dialog/SheetShell';
|
|
15
22
|
import { POPOVER_TRIGGER_POPUP } from '../floating/constants';
|
|
@@ -17,6 +24,7 @@ import { TriggerSlot } from '../floating/TriggerSlot';
|
|
|
17
24
|
import { useSheetOpenBridge } from '../floating/use-sheet-open-bridge';
|
|
18
25
|
import { useControllableState } from '../hooks/use-controllable-state';
|
|
19
26
|
import { PopoverProvider, usePopover } from './context';
|
|
27
|
+
import { POPOVER_PADDING } from './surface';
|
|
20
28
|
import type { PopoverContentProps, PopoverProps, PopoverTriggerProps } from './types';
|
|
21
29
|
|
|
22
30
|
export function Popover({ children, open, defaultOpen = false, onOpenChange }: PopoverProps) {
|
|
@@ -62,13 +70,33 @@ export function PopoverTrigger({
|
|
|
62
70
|
);
|
|
63
71
|
}
|
|
64
72
|
|
|
65
|
-
export function PopoverContent({
|
|
73
|
+
export function PopoverContent({
|
|
74
|
+
children,
|
|
75
|
+
label = 'Popover',
|
|
76
|
+
className,
|
|
77
|
+
style,
|
|
78
|
+
testID,
|
|
79
|
+
}: PopoverContentProps) {
|
|
66
80
|
const popover = usePopover();
|
|
67
81
|
const { control, onSheetClose } = useSheetOpenBridge(popover.open, popover.setOpen);
|
|
68
82
|
|
|
69
83
|
return (
|
|
70
|
-
<SheetShell
|
|
84
|
+
<SheetShell
|
|
85
|
+
control={control}
|
|
86
|
+
label={label}
|
|
87
|
+
onClose={onSheetClose}
|
|
88
|
+
contentClassName={className}
|
|
89
|
+
contentStyle={[styles.body, style]}
|
|
90
|
+
contentTestID={testID}>
|
|
71
91
|
{children}
|
|
72
92
|
</SheetShell>
|
|
73
93
|
);
|
|
74
94
|
}
|
|
95
|
+
|
|
96
|
+
const styles = StyleSheet.create({
|
|
97
|
+
body: {
|
|
98
|
+
paddingLeft: POPOVER_PADDING,
|
|
99
|
+
paddingRight: POPOVER_PADDING,
|
|
100
|
+
paddingBottom: POPOVER_PADDING,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `Popover` — WEB. An anchored panel positioned, portaled, ranked and dismissed
|
|
3
3
|
* by `floating/FloatingPanel`, which is also what the three menu families
|
|
4
|
-
* render. The popover's own contribution is its
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* render. The popover's own contribution is its panel: the floating
|
|
5
|
+
* surface (`surface.ts` — 266px, `rounded-2xl`, 1px `border-button-default`,
|
|
6
|
+
* `bg-background-primary-default`, `p-2.5`, `shadow-dropdown`), resolved from
|
|
7
|
+
* the theme ramps and applied inline ahead of the caller's `style`. It centres
|
|
8
|
+
* on its trigger by default (shadcn's `align="center"`) and does not take the
|
|
9
|
+
* trigger's width as a floor.
|
|
9
10
|
*/
|
|
10
11
|
import React, { useCallback, useMemo, useRef } from 'react';
|
|
11
|
-
import type
|
|
12
|
+
import { useWindowDimensions, type View } from 'react-native';
|
|
12
13
|
|
|
13
|
-
import {
|
|
14
|
+
import { POPOVER_TRIGGER_POPUP } from '../floating/constants';
|
|
14
15
|
import { FloatingPanel } from '../floating/FloatingPanel';
|
|
15
|
-
import {
|
|
16
|
+
import { useMenuPalette } from '../floating/menu-palette';
|
|
16
17
|
import { TriggerSlot } from '../floating/TriggerSlot';
|
|
17
18
|
import { useAnchorRect } from '../floating/use-anchor-rect';
|
|
18
19
|
import { useControllableState } from '../hooks/use-controllable-state';
|
|
19
20
|
import { PopoverProvider, usePopover } from './context';
|
|
21
|
+
import {
|
|
22
|
+
classChromeOverrides,
|
|
23
|
+
POPOVER_SIDE_OFFSET,
|
|
24
|
+
resolvePopoverSurfaceStyle,
|
|
25
|
+
} from './surface';
|
|
20
26
|
import type { PopoverContentProps, PopoverProps, PopoverTriggerProps } from './types';
|
|
21
27
|
|
|
22
28
|
export function Popover({ children, open, defaultOpen = false, onOpenChange }: PopoverProps) {
|
|
@@ -67,7 +73,7 @@ export function PopoverContent({
|
|
|
67
73
|
label = 'Popover',
|
|
68
74
|
side,
|
|
69
75
|
align = 'center',
|
|
70
|
-
sideOffset,
|
|
76
|
+
sideOffset = POPOVER_SIDE_OFFSET,
|
|
71
77
|
alignOffset,
|
|
72
78
|
dismissible,
|
|
73
79
|
minWidth,
|
|
@@ -79,6 +85,18 @@ export function PopoverContent({
|
|
|
79
85
|
const popover = usePopover();
|
|
80
86
|
const anchor = useAnchorRect(popover.anchorRef, popover.open);
|
|
81
87
|
const close = useCallback(() => popover.setOpen(false), [popover]);
|
|
88
|
+
const palette = useMenuPalette();
|
|
89
|
+
const { width: viewportWidth } = useWindowDimensions();
|
|
90
|
+
const overridden = useMemo(() => classChromeOverrides(className), [className]);
|
|
91
|
+
const chrome = useMemo(
|
|
92
|
+
() =>
|
|
93
|
+
resolvePopoverSurfaceStyle(
|
|
94
|
+
palette,
|
|
95
|
+
overridden,
|
|
96
|
+
maxWidth === undefined ? viewportWidth : undefined,
|
|
97
|
+
),
|
|
98
|
+
[palette, overridden, maxWidth, viewportWidth],
|
|
99
|
+
);
|
|
82
100
|
|
|
83
101
|
return (
|
|
84
102
|
<FloatingPanel
|
|
@@ -94,14 +112,10 @@ export function PopoverContent({
|
|
|
94
112
|
minWidth={minWidth}
|
|
95
113
|
maxWidth={maxWidth}
|
|
96
114
|
onDismiss={close}
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
// `DialogHeader` does here — its rows have to reach the panel edge to show
|
|
102
|
-
// a full-width highlight.
|
|
103
|
-
className={cx(POPOVER_CLASS, className)}
|
|
104
|
-
style={style}
|
|
115
|
+
className={className}
|
|
116
|
+
// The resolved panel FIRST, so the caller's `style` overrides any of it;
|
|
117
|
+
// properties the caller's `className` names were already left out.
|
|
118
|
+
style={[chrome, style]}
|
|
105
119
|
testID={testID}>
|
|
106
120
|
{children}
|
|
107
121
|
</FloatingPanel>
|
package/src/popover/index.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
export { Popover, PopoverTrigger, PopoverContent } from './Popover';
|
|
2
|
-
export
|
|
2
|
+
export {
|
|
3
|
+
PopoverHeader,
|
|
4
|
+
PopoverTitle,
|
|
5
|
+
PopoverDescription,
|
|
6
|
+
PopoverFooter,
|
|
7
|
+
PopoverSeparator,
|
|
8
|
+
} from './parts';
|
|
9
|
+
export type {
|
|
10
|
+
PopoverProps,
|
|
11
|
+
PopoverTriggerProps,
|
|
12
|
+
PopoverContentProps,
|
|
13
|
+
PopoverHeaderProps,
|
|
14
|
+
PopoverTitleProps,
|
|
15
|
+
PopoverDescriptionProps,
|
|
16
|
+
PopoverFooterProps,
|
|
17
|
+
PopoverSeparatorProps,
|
|
18
|
+
} from './types';
|
package/src/popover/index.web.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
export { Popover, PopoverTrigger, PopoverContent } from './Popover.web';
|
|
2
|
-
export
|
|
2
|
+
export {
|
|
3
|
+
PopoverHeader,
|
|
4
|
+
PopoverTitle,
|
|
5
|
+
PopoverDescription,
|
|
6
|
+
PopoverFooter,
|
|
7
|
+
PopoverSeparator,
|
|
8
|
+
} from './parts';
|
|
9
|
+
export type {
|
|
10
|
+
PopoverProps,
|
|
11
|
+
PopoverTriggerProps,
|
|
12
|
+
PopoverContentProps,
|
|
13
|
+
PopoverHeaderProps,
|
|
14
|
+
PopoverTitleProps,
|
|
15
|
+
PopoverDescriptionProps,
|
|
16
|
+
PopoverFooterProps,
|
|
17
|
+
PopoverSeparatorProps,
|
|
18
|
+
} from './types';
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The structures the floating panels repeat, published as parts so a
|
|
3
|
+
* popover body is composed rather than hand-measured. Platform-neutral: the web
|
|
4
|
+
* panel and the native sheet body both inset their content by `p-2.5`
|
|
5
|
+
* (`surface.ts`), which is what the separator bleeds through and what the
|
|
6
|
+
* header/footer `px-2` is measured against — 18px from the panel edge on every
|
|
7
|
+
* side ("panel p-2.5 + row px-2").
|
|
8
|
+
*
|
|
9
|
+
* PopoverHeader flex items-center gap-2 px-2 pt-1 (dashboard team menu)
|
|
10
|
+
* PopoverTitle text-body-medium text-text-primary (secondary: group label)
|
|
11
|
+
* PopoverDescription text-body-regular text-text-secondary
|
|
12
|
+
* PopoverFooter flex items-center gap-3 px-2 pb-2 (user menu actions)
|
|
13
|
+
* PopoverSeparator -mx-2.5 my-2.5 h-px bg-border-button-default
|
|
14
|
+
*
|
|
15
|
+
* Popovers have no close button and no arrow, so neither is a part.
|
|
16
|
+
*
|
|
17
|
+
* Colours are resolved inline from `menu-palette.ts`; a text colour default is
|
|
18
|
+
* applied only when the caller passes no `className`, so a `text-*` utility is
|
|
19
|
+
* never outranked (AGENTS.md, "Style and `className`").
|
|
20
|
+
*/
|
|
21
|
+
import React from 'react';
|
|
22
|
+
import { StyleSheet, View } from 'react-native';
|
|
23
|
+
|
|
24
|
+
import { useMenuPalette } from '../floating/menu-palette';
|
|
25
|
+
import { StyledView } from '../styles/styled-primitives';
|
|
26
|
+
import { Text } from '../typography';
|
|
27
|
+
import { POPOVER_PADDING } from './surface';
|
|
28
|
+
import type {
|
|
29
|
+
PopoverDescriptionProps,
|
|
30
|
+
PopoverFooterProps,
|
|
31
|
+
PopoverHeaderProps,
|
|
32
|
+
PopoverSeparatorProps,
|
|
33
|
+
PopoverTitleProps,
|
|
34
|
+
} from './types';
|
|
35
|
+
|
|
36
|
+
export function PopoverHeader({ leading, children, className, style, testID }: PopoverHeaderProps) {
|
|
37
|
+
return (
|
|
38
|
+
<StyledView className={className} style={[styles.header, style]} testID={testID}>
|
|
39
|
+
{leading ? <View style={styles.leading}>{leading}</View> : null}
|
|
40
|
+
<View style={styles.headerText}>{children}</View>
|
|
41
|
+
</StyledView>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function PopoverTitle({
|
|
46
|
+
children,
|
|
47
|
+
tone = 'primary',
|
|
48
|
+
numberOfLines = 1,
|
|
49
|
+
className,
|
|
50
|
+
style,
|
|
51
|
+
testID,
|
|
52
|
+
}: PopoverTitleProps) {
|
|
53
|
+
const palette = useMenuPalette();
|
|
54
|
+
const color = tone === 'secondary' ? palette.textSecondary : palette.text;
|
|
55
|
+
return (
|
|
56
|
+
<Text
|
|
57
|
+
variant="body-medium"
|
|
58
|
+
numberOfLines={numberOfLines}
|
|
59
|
+
className={className}
|
|
60
|
+
style={[className ? null : { color }, style]}
|
|
61
|
+
testID={testID}>
|
|
62
|
+
{children}
|
|
63
|
+
</Text>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function PopoverDescription({
|
|
68
|
+
children,
|
|
69
|
+
numberOfLines = 1,
|
|
70
|
+
className,
|
|
71
|
+
style,
|
|
72
|
+
testID,
|
|
73
|
+
}: PopoverDescriptionProps) {
|
|
74
|
+
const palette = useMenuPalette();
|
|
75
|
+
return (
|
|
76
|
+
<Text
|
|
77
|
+
variant="body-regular"
|
|
78
|
+
numberOfLines={numberOfLines}
|
|
79
|
+
className={className}
|
|
80
|
+
style={[className ? null : { color: palette.textSecondary }, style]}
|
|
81
|
+
testID={testID}>
|
|
82
|
+
{children}
|
|
83
|
+
</Text>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function PopoverFooter({ children, className, style, testID }: PopoverFooterProps) {
|
|
88
|
+
return (
|
|
89
|
+
<StyledView className={className} style={[styles.footer, style]} testID={testID}>
|
|
90
|
+
{children}
|
|
91
|
+
</StyledView>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function PopoverSeparator({ className, style, testID }: PopoverSeparatorProps) {
|
|
96
|
+
const palette = useMenuPalette();
|
|
97
|
+
return (
|
|
98
|
+
<StyledView
|
|
99
|
+
// Decorative: the sections it divides are announced on their own.
|
|
100
|
+
aria-hidden
|
|
101
|
+
className={className}
|
|
102
|
+
style={[styles.separator, { backgroundColor: palette.border }, style]}
|
|
103
|
+
testID={testID}
|
|
104
|
+
/>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const styles = StyleSheet.create({
|
|
109
|
+
header: {
|
|
110
|
+
flexDirection: 'row',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
gap: 8,
|
|
113
|
+
paddingLeft: 8,
|
|
114
|
+
paddingRight: 8,
|
|
115
|
+
paddingTop: 4,
|
|
116
|
+
},
|
|
117
|
+
leading: {
|
|
118
|
+
flexShrink: 0,
|
|
119
|
+
},
|
|
120
|
+
headerText: {
|
|
121
|
+
minWidth: 0,
|
|
122
|
+
flexShrink: 1,
|
|
123
|
+
alignItems: 'flex-start',
|
|
124
|
+
justifyContent: 'center',
|
|
125
|
+
},
|
|
126
|
+
footer: {
|
|
127
|
+
flexDirection: 'row',
|
|
128
|
+
alignItems: 'center',
|
|
129
|
+
gap: 12,
|
|
130
|
+
paddingLeft: 8,
|
|
131
|
+
paddingRight: 8,
|
|
132
|
+
paddingBottom: 8,
|
|
133
|
+
},
|
|
134
|
+
separator: {
|
|
135
|
+
height: 1,
|
|
136
|
+
marginLeft: -POPOVER_PADDING,
|
|
137
|
+
marginRight: -POPOVER_PADDING,
|
|
138
|
+
marginTop: 10,
|
|
139
|
+
marginBottom: 10,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The popover PANEL — Bloom's one floating surface, resolved to inline style.
|
|
3
|
+
*
|
|
4
|
+
* Every floating panel (`dropdown/menu-styles.ts`'s `MENU_POPOVER_SURFACE`, the
|
|
5
|
+
* dashboard team/user menus, the calendar inbox menu, the ai-chat menus) spells
|
|
6
|
+
* the same class string:
|
|
7
|
+
*
|
|
8
|
+
* w-[266px] max-w-[calc(100vw-32px)] overflow-y-auto
|
|
9
|
+
* rounded-2xl border border-border-button-default
|
|
10
|
+
* bg-background-primary-default p-2.5 shadow-dropdown
|
|
11
|
+
* transition duration-150 ease-out, entering/exiting opacity-0 scale-95 blur-[2px]
|
|
12
|
+
* origin at the placement side, offset 8 (4 on the select / date pickers)
|
|
13
|
+
*
|
|
14
|
+
* The motion is `FloatingPanel`'s; everything else is resolved here.
|
|
15
|
+
*
|
|
16
|
+
* ── WHY INLINE, AND HOW A CALLER'S `className` STILL WINS ────────────────────
|
|
17
|
+
*
|
|
18
|
+
* The colours are ramp stops (`menu-palette.ts`) that exist as no CSS variable,
|
|
19
|
+
* so they cannot be classes. The geometry is inline too, because a default CLASS
|
|
20
|
+
* competes with the caller's class by Tailwind's emission order, not by the order
|
|
21
|
+
* in the attribute — measured on this very family: `DialogHeader`'s
|
|
22
|
+
* `className="w-auto p-space-4"` rendered 16px of padding, because the old
|
|
23
|
+
* `p-space-16` default was emitted later and won.
|
|
24
|
+
*
|
|
25
|
+
* But an inline style beats ANY class on web, so a naive inline default would
|
|
26
|
+
* silently outrank every `className` a caller passes. {@link classChromeOverrides}
|
|
27
|
+
* closes that: it reads which chrome PROPERTIES the caller's utilities name
|
|
28
|
+
* (`w-*`, `p-*`, `rounded-*`, `bg-*`, …) and the matching inline default is left
|
|
29
|
+
* out, so the caller's class is the only rule for that property. A caller's
|
|
30
|
+
* `style` still comes last and overrides everything.
|
|
31
|
+
*/
|
|
32
|
+
import type { MenuPalette } from '../floating/menu-palette';
|
|
33
|
+
import type { WebCssStyle } from '../styles/web-view-style';
|
|
34
|
+
|
|
35
|
+
/** `w-[266px]` — `MENU_POPOVER_WIDTH`. */
|
|
36
|
+
export const POPOVER_WIDTH = 266;
|
|
37
|
+
/** `rounded-2xl`. */
|
|
38
|
+
export const POPOVER_RADIUS = 16;
|
|
39
|
+
/** `p-2.5` — also what `PopoverSeparator` bleeds back through. */
|
|
40
|
+
export const POPOVER_PADDING = 10;
|
|
41
|
+
/** `max-w-[calc(100vw-32px)]`, as the 32px it subtracts. */
|
|
42
|
+
export const POPOVER_VIEWPORT_INSET = 32;
|
|
43
|
+
/** Popovers sit `offset={8}` from their trigger. */
|
|
44
|
+
export const POPOVER_SIDE_OFFSET = 8;
|
|
45
|
+
|
|
46
|
+
export type PopoverChromeKey =
|
|
47
|
+
| 'width'
|
|
48
|
+
| 'maxWidth'
|
|
49
|
+
| 'padding'
|
|
50
|
+
| 'radius'
|
|
51
|
+
| 'borderWidth'
|
|
52
|
+
| 'borderColor'
|
|
53
|
+
| 'background'
|
|
54
|
+
| 'shadow'
|
|
55
|
+
| 'overflow';
|
|
56
|
+
|
|
57
|
+
const BORDER_WIDTH = /^border(-[xytrblse])?(-\d+(\.\d+)?|-\[[^\]]+px\])?$/;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Which chrome properties a caller's utility classes set. Variants (`dark:`,
|
|
61
|
+
* `md:`, `hover:`), the important `!` and a negative `-` are stripped first, so
|
|
62
|
+
* `md:!p-0` counts as padding.
|
|
63
|
+
*/
|
|
64
|
+
export function classChromeOverrides(className?: string): ReadonlySet<PopoverChromeKey> {
|
|
65
|
+
const keys = new Set<PopoverChromeKey>();
|
|
66
|
+
if (!className) return keys;
|
|
67
|
+
for (const raw of className.split(/\s+/)) {
|
|
68
|
+
if (!raw) continue;
|
|
69
|
+
const token = raw.slice(raw.lastIndexOf(':') + 1).replace(/^!/, '').replace(/^-/, '');
|
|
70
|
+
if (/^(w|size)-/.test(token)) keys.add('width');
|
|
71
|
+
else if (/^max-w-/.test(token)) keys.add('maxWidth');
|
|
72
|
+
else if (/^p[xytrblse]?-/.test(token)) keys.add('padding');
|
|
73
|
+
else if (/^rounded(-|$)/.test(token)) keys.add('radius');
|
|
74
|
+
else if (BORDER_WIDTH.test(token)) keys.add('borderWidth');
|
|
75
|
+
else if (/^border-/.test(token)) keys.add('borderColor');
|
|
76
|
+
else if (/^bg-/.test(token)) keys.add('background');
|
|
77
|
+
else if (/^shadow(-|$)/.test(token)) keys.add('shadow');
|
|
78
|
+
else if (/^overflow-/.test(token)) keys.add('overflow');
|
|
79
|
+
}
|
|
80
|
+
return keys;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The panel's inline chrome, minus every property the caller's `className`
|
|
85
|
+
* names. `maxWidth` is only the default: a numeric `maxWidth` PROP is applied by
|
|
86
|
+
* `FloatingPanel` and must not be overwritten, so the caller passes
|
|
87
|
+
* `viewportWidth` only when no prop was given.
|
|
88
|
+
*/
|
|
89
|
+
export function resolvePopoverSurfaceStyle(
|
|
90
|
+
palette: MenuPalette,
|
|
91
|
+
overridden: ReadonlySet<PopoverChromeKey>,
|
|
92
|
+
viewportWidth?: number,
|
|
93
|
+
): WebCssStyle {
|
|
94
|
+
const style: WebCssStyle = {};
|
|
95
|
+
if (!overridden.has('width')) style.width = POPOVER_WIDTH;
|
|
96
|
+
if (!overridden.has('maxWidth') && viewportWidth !== undefined) {
|
|
97
|
+
style.maxWidth = Math.max(0, viewportWidth - POPOVER_VIEWPORT_INSET);
|
|
98
|
+
}
|
|
99
|
+
if (!overridden.has('padding')) {
|
|
100
|
+
// Longhands: a caller's `style` override of one side must not lose to a
|
|
101
|
+
// shorthand react-native-web ranks above it (AGENTS.md, "Style").
|
|
102
|
+
style.paddingTop = POPOVER_PADDING;
|
|
103
|
+
style.paddingBottom = POPOVER_PADDING;
|
|
104
|
+
style.paddingLeft = POPOVER_PADDING;
|
|
105
|
+
style.paddingRight = POPOVER_PADDING;
|
|
106
|
+
}
|
|
107
|
+
if (!overridden.has('radius')) style.borderRadius = POPOVER_RADIUS;
|
|
108
|
+
if (!overridden.has('borderWidth')) style.borderWidth = 1;
|
|
109
|
+
if (!overridden.has('borderColor')) style.borderColor = palette.border;
|
|
110
|
+
if (!overridden.has('background')) style.backgroundColor = palette.surface;
|
|
111
|
+
if (!overridden.has('shadow')) style.boxShadow = palette.shadow;
|
|
112
|
+
// The panel's `overflow-y-auto` clips a full-bleed child to the 16px corner and
|
|
113
|
+
// scrolls once something bounds the height. React Native types no
|
|
114
|
+
// `overflowY`, and the panel has no default height bound for `auto` to act
|
|
115
|
+
// on, so the default is the clip; a caller that sets `maxHeight` wraps its
|
|
116
|
+
// body in a `ScrollView` (the calendar inbox menu does).
|
|
117
|
+
if (!overridden.has('overflow')) style.overflow = 'hidden';
|
|
118
|
+
return style;
|
|
119
|
+
}
|
package/src/popover/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
|
|
1
3
|
import type {
|
|
2
4
|
OverlayOpenProps,
|
|
3
5
|
OverlaySurfaceProps,
|
|
@@ -7,3 +9,57 @@ import type {
|
|
|
7
9
|
export type PopoverProps = React.PropsWithChildren<OverlayOpenProps>;
|
|
8
10
|
export type PopoverTriggerProps = OverlayTriggerProps;
|
|
9
11
|
export type PopoverContentProps = OverlaySurfaceProps;
|
|
12
|
+
|
|
13
|
+
/** Shared by the panel's layout parts. */
|
|
14
|
+
interface PopoverPartProps {
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
/** Utility classes on the part's own node. */
|
|
17
|
+
className?: string;
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
testID?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The panel's heading row — `flex items-center gap-2 px-2 pt-1`:
|
|
24
|
+
* an optional `leading` (avatar, icon) beside a column of
|
|
25
|
+
* `PopoverTitle` / `PopoverDescription`.
|
|
26
|
+
*/
|
|
27
|
+
export interface PopoverHeaderProps extends PopoverPartProps {
|
|
28
|
+
leading?: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `text-body-medium text-text-primary`, or `text-secondary` for a group label. */
|
|
32
|
+
export interface PopoverTitleProps {
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* `'secondary'` is the group-label colour panels use above a list
|
|
36
|
+
* ("Users with access", "Local Folders"). Defaults to `'primary'`.
|
|
37
|
+
*/
|
|
38
|
+
tone?: 'primary' | 'secondary';
|
|
39
|
+
numberOfLines?: number;
|
|
40
|
+
className?: string;
|
|
41
|
+
style?: StyleProp<TextStyle>;
|
|
42
|
+
testID?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** `text-body-regular text-text-secondary`. */
|
|
46
|
+
export interface PopoverDescriptionProps {
|
|
47
|
+
children?: React.ReactNode;
|
|
48
|
+
numberOfLines?: number;
|
|
49
|
+
className?: string;
|
|
50
|
+
style?: StyleProp<TextStyle>;
|
|
51
|
+
testID?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The panel's closing row — `flex items-center gap-3 px-2 pb-2`. */
|
|
55
|
+
export type PopoverFooterProps = PopoverPartProps;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The full-bleed rule between a panel's sections —
|
|
59
|
+
* `-mx-2.5 my-2.5 h-px bg-border-button-default`.
|
|
60
|
+
*/
|
|
61
|
+
export interface PopoverSeparatorProps {
|
|
62
|
+
className?: string;
|
|
63
|
+
style?: StyleProp<ViewStyle>;
|
|
64
|
+
testID?: string;
|
|
65
|
+
}
|
package/src/sidebar/parts.tsx
CHANGED
|
@@ -225,19 +225,16 @@ export function ChevronUpDownSmall({ color, size = 16 }: { color: string; size?:
|
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
/**
|
|
229
|
-
export function menuPanelStyle(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
borderWidth: 1,
|
|
235
|
-
borderColor: palette.menu.border,
|
|
236
|
-
backgroundColor: palette.menu.surface,
|
|
237
|
-
boxShadow: palette.menu.shadow,
|
|
238
|
-
};
|
|
228
|
+
/** The width both sidebar menus give their popover: `w-[265px]`. */
|
|
229
|
+
export function menuPanelStyle(_palette?: SidebarPalette): ViewStyle {
|
|
230
|
+
// `w-[265px]` is the only thing these menus say differently from the popover
|
|
231
|
+
// panel itself — radius, border, surface, `p-2.5` and `shadow-dropdown` are
|
|
232
|
+
// `Popover`'s own defaults now (`popover/surface.ts`).
|
|
233
|
+
return MENU_PANEL;
|
|
239
234
|
}
|
|
240
235
|
|
|
236
|
+
const MENU_PANEL: ViewStyle = { width: 265 };
|
|
237
|
+
|
|
241
238
|
/** Full-bleed menu divider: `-mx-2.5 h-px bg-border-button-default`. */
|
|
242
239
|
export function MenuDivider({ palette, spacing }: { palette: SidebarPalette; spacing: number }) {
|
|
243
240
|
return (
|