@oxy.so/bloom 2.2.0 → 2.4.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.
Files changed (144) hide show
  1. package/docs/popover.mdx +73 -19
  2. package/docs/sidebar.mdx +20 -0
  3. package/lib/commonjs/calendar/CalendarViewInboxMenu.js +4 -13
  4. package/lib/commonjs/calendar/CalendarViewInboxMenu.js.map +1 -1
  5. package/lib/commonjs/calendar/CalendarViewMonthGrid.js +6 -10
  6. package/lib/commonjs/calendar/CalendarViewMonthGrid.js.map +1 -1
  7. package/lib/commonjs/dialog/DialogHeader.js +1 -7
  8. package/lib/commonjs/dialog/DialogHeader.js.map +1 -1
  9. package/lib/commonjs/floating/FloatingPanel.js +19 -22
  10. package/lib/commonjs/floating/FloatingPanel.js.map +1 -1
  11. package/lib/commonjs/floating/constants.js +12 -56
  12. package/lib/commonjs/floating/constants.js.map +1 -1
  13. package/lib/commonjs/floating/menu-sub-flyout.js +3 -3
  14. package/lib/commonjs/popover/Popover.js +23 -3
  15. package/lib/commonjs/popover/Popover.js.map +1 -1
  16. package/lib/commonjs/popover/Popover.web.js +21 -16
  17. package/lib/commonjs/popover/Popover.web.js.map +1 -1
  18. package/lib/commonjs/popover/index.js +31 -0
  19. package/lib/commonjs/popover/index.js.map +1 -1
  20. package/lib/commonjs/popover/index.web.js +31 -0
  21. package/lib/commonjs/popover/index.web.js.map +1 -1
  22. package/lib/commonjs/popover/parts.js +164 -0
  23. package/lib/commonjs/popover/parts.js.map +1 -0
  24. package/lib/commonjs/popover/surface.js +102 -0
  25. package/lib/commonjs/popover/surface.js.map +1 -0
  26. package/lib/commonjs/sidebar/Sidebar.js +15 -2
  27. package/lib/commonjs/sidebar/Sidebar.js.map +1 -1
  28. package/lib/commonjs/sidebar/SidebarModeSwitcher.js +193 -0
  29. package/lib/commonjs/sidebar/SidebarModeSwitcher.js.map +1 -0
  30. package/lib/commonjs/sidebar/index.js +7 -0
  31. package/lib/commonjs/sidebar/index.js.map +1 -1
  32. package/lib/commonjs/sidebar/parts.js +9 -11
  33. package/lib/commonjs/sidebar/parts.js.map +1 -1
  34. package/lib/module/calendar/CalendarViewInboxMenu.js +4 -13
  35. package/lib/module/calendar/CalendarViewInboxMenu.js.map +1 -1
  36. package/lib/module/calendar/CalendarViewMonthGrid.js +6 -10
  37. package/lib/module/calendar/CalendarViewMonthGrid.js.map +1 -1
  38. package/lib/module/dialog/DialogHeader.js +1 -7
  39. package/lib/module/dialog/DialogHeader.js.map +1 -1
  40. package/lib/module/floating/FloatingPanel.js +20 -23
  41. package/lib/module/floating/FloatingPanel.js.map +1 -1
  42. package/lib/module/floating/constants.js +11 -55
  43. package/lib/module/floating/constants.js.map +1 -1
  44. package/lib/module/floating/menu-sub-flyout.js +3 -3
  45. package/lib/module/popover/Popover.js +23 -3
  46. package/lib/module/popover/Popover.js.map +1 -1
  47. package/lib/module/popover/Popover.web.js +22 -17
  48. package/lib/module/popover/Popover.web.js.map +1 -1
  49. package/lib/module/popover/index.js +1 -0
  50. package/lib/module/popover/index.js.map +1 -1
  51. package/lib/module/popover/index.web.js +1 -0
  52. package/lib/module/popover/index.web.js.map +1 -1
  53. package/lib/module/popover/parts.js +154 -0
  54. package/lib/module/popover/parts.js.map +1 -0
  55. package/lib/module/popover/surface.js +96 -0
  56. package/lib/module/popover/surface.js.map +1 -0
  57. package/lib/module/sidebar/Sidebar.js +15 -2
  58. package/lib/module/sidebar/Sidebar.js.map +1 -1
  59. package/lib/module/sidebar/SidebarModeSwitcher.js +188 -0
  60. package/lib/module/sidebar/SidebarModeSwitcher.js.map +1 -0
  61. package/lib/module/sidebar/index.js +1 -0
  62. package/lib/module/sidebar/index.js.map +1 -1
  63. package/lib/module/sidebar/parts.js +9 -11
  64. package/lib/module/sidebar/parts.js.map +1 -1
  65. package/lib/typescript/commonjs/calendar/CalendarViewInboxMenu.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/calendar/CalendarViewMonthGrid.d.ts.map +1 -1
  67. package/lib/typescript/commonjs/dialog/DialogHeader.d.ts.map +1 -1
  68. package/lib/typescript/commonjs/floating/FloatingPanel.d.ts.map +1 -1
  69. package/lib/typescript/commonjs/floating/constants.d.ts +11 -50
  70. package/lib/typescript/commonjs/floating/constants.d.ts.map +1 -1
  71. package/lib/typescript/commonjs/floating/types.d.ts +5 -4
  72. package/lib/typescript/commonjs/floating/types.d.ts.map +1 -1
  73. package/lib/typescript/commonjs/popover/Popover.d.ts +1 -1
  74. package/lib/typescript/commonjs/popover/Popover.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/popover/Popover.web.d.ts.map +1 -1
  76. package/lib/typescript/commonjs/popover/index.d.ts +2 -1
  77. package/lib/typescript/commonjs/popover/index.d.ts.map +1 -1
  78. package/lib/typescript/commonjs/popover/index.web.d.ts +2 -1
  79. package/lib/typescript/commonjs/popover/index.web.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/popover/parts.d.ts +7 -0
  81. package/lib/typescript/commonjs/popover/parts.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/popover/surface.d.ts +58 -0
  83. package/lib/typescript/commonjs/popover/surface.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/popover/types.d.ts +50 -0
  85. package/lib/typescript/commonjs/popover/types.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/sidebar/Sidebar.d.ts.map +1 -1
  87. package/lib/typescript/commonjs/sidebar/SidebarModeSwitcher.d.ts +4 -0
  88. package/lib/typescript/commonjs/sidebar/SidebarModeSwitcher.d.ts.map +1 -0
  89. package/lib/typescript/commonjs/sidebar/index.d.ts +2 -1
  90. package/lib/typescript/commonjs/sidebar/index.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/sidebar/parts.d.ts +2 -2
  92. package/lib/typescript/commonjs/sidebar/parts.d.ts.map +1 -1
  93. package/lib/typescript/commonjs/sidebar/types.d.ts +30 -0
  94. package/lib/typescript/commonjs/sidebar/types.d.ts.map +1 -1
  95. package/lib/typescript/module/calendar/CalendarViewInboxMenu.d.ts.map +1 -1
  96. package/lib/typescript/module/calendar/CalendarViewMonthGrid.d.ts.map +1 -1
  97. package/lib/typescript/module/dialog/DialogHeader.d.ts.map +1 -1
  98. package/lib/typescript/module/floating/FloatingPanel.d.ts.map +1 -1
  99. package/lib/typescript/module/floating/constants.d.ts +11 -50
  100. package/lib/typescript/module/floating/constants.d.ts.map +1 -1
  101. package/lib/typescript/module/floating/types.d.ts +5 -4
  102. package/lib/typescript/module/floating/types.d.ts.map +1 -1
  103. package/lib/typescript/module/popover/Popover.d.ts +1 -1
  104. package/lib/typescript/module/popover/Popover.d.ts.map +1 -1
  105. package/lib/typescript/module/popover/Popover.web.d.ts.map +1 -1
  106. package/lib/typescript/module/popover/index.d.ts +2 -1
  107. package/lib/typescript/module/popover/index.d.ts.map +1 -1
  108. package/lib/typescript/module/popover/index.web.d.ts +2 -1
  109. package/lib/typescript/module/popover/index.web.d.ts.map +1 -1
  110. package/lib/typescript/module/popover/parts.d.ts +7 -0
  111. package/lib/typescript/module/popover/parts.d.ts.map +1 -0
  112. package/lib/typescript/module/popover/surface.d.ts +58 -0
  113. package/lib/typescript/module/popover/surface.d.ts.map +1 -0
  114. package/lib/typescript/module/popover/types.d.ts +50 -0
  115. package/lib/typescript/module/popover/types.d.ts.map +1 -1
  116. package/lib/typescript/module/sidebar/Sidebar.d.ts.map +1 -1
  117. package/lib/typescript/module/sidebar/SidebarModeSwitcher.d.ts +4 -0
  118. package/lib/typescript/module/sidebar/SidebarModeSwitcher.d.ts.map +1 -0
  119. package/lib/typescript/module/sidebar/index.d.ts +2 -1
  120. package/lib/typescript/module/sidebar/index.d.ts.map +1 -1
  121. package/lib/typescript/module/sidebar/parts.d.ts +2 -2
  122. package/lib/typescript/module/sidebar/parts.d.ts.map +1 -1
  123. package/lib/typescript/module/sidebar/types.d.ts +30 -0
  124. package/lib/typescript/module/sidebar/types.d.ts.map +1 -1
  125. package/package.json +1 -1
  126. package/src/calendar/CalendarViewInboxMenu.tsx +3 -12
  127. package/src/calendar/CalendarViewMonthGrid.tsx +5 -9
  128. package/src/dialog/DialogHeader.tsx +1 -6
  129. package/src/floating/FloatingPanel.tsx +19 -27
  130. package/src/floating/constants.ts +11 -56
  131. package/src/floating/menu-sub-flyout.tsx +3 -3
  132. package/src/floating/types.ts +5 -4
  133. package/src/popover/Popover.tsx +32 -4
  134. package/src/popover/Popover.web.tsx +31 -17
  135. package/src/popover/index.ts +17 -1
  136. package/src/popover/index.web.ts +17 -1
  137. package/src/popover/parts.tsx +141 -0
  138. package/src/popover/surface.ts +119 -0
  139. package/src/popover/types.ts +56 -0
  140. package/src/sidebar/Sidebar.tsx +19 -0
  141. package/src/sidebar/SidebarModeSwitcher.tsx +183 -0
  142. package/src/sidebar/index.ts +3 -0
  143. package/src/sidebar/parts.tsx +8 -11
  144. package/src/sidebar/types.ts +32 -0
@@ -18,10 +18,12 @@
18
18
  * `pointer-events: none` and the property inherits.
19
19
  * - Placement goes through `overlay/dropdown-placement`, which fits, flips and
20
20
  * clamps on the axis `side` names and aligns-then-clamps on the other one.
21
- * - The chrome — radius, border, background, inset, elevation — is a class
22
- * string (`PANEL_CLASS`), so a consumer can restyle a surface with utilities.
23
- * Only what is COMPUTED stays inline: the resolved position, the caller's
24
- * numeric `minWidth`/`maxWidth`, the transform origin and the motion.
21
+ * - The menu surfaces' geometry — radius, border width, inset — is a class
22
+ * string (`MENU_PANEL_CLASS`, `LISTBOX_PANEL_CLASS`) and their colours are
23
+ * inline from `menu-palette.ts`. The `popover` surface carries NO chrome of
24
+ * its own here: `popover/surface.ts` resolves the whole panel inline and
25
+ * hands it over as `style`, so a caller's `className` can still override
26
+ * any one piece of it (see that module).
25
27
  *
26
28
  * `alignOffset` is applied by SHIFTING THE ANCHOR before resolving, not by
27
29
  * nudging the result: the resolver's own clamp then still owns the align axis,
@@ -32,12 +34,9 @@
32
34
  *
33
35
  * ── MOTION ───────────────────────────────────────────────────────────────────
34
36
  *
35
- * Fade + `zoom-95` + an 8px slide from the side it landed on, 200ms on
36
- * `--ease-out-quint`, scaling from the corner nearest the trigger — the target's
37
- * own enter, and the same shape reversed on the way out. That is the `popover`
38
- * surface; the `menu` and `listbox` surfaces run a separate menu motion instead
39
- * (150ms `ease-out`, fade + `scale-95` + 2px blur, no slide) and wear matching
40
- * chrome, coloured inline from `menu-palette.ts`.
37
+ * The one popover motion, on every surface: 150ms `ease-out`, fade +
38
+ * `scale-95` + 2px blur, no slide, scaling from the corner nearest the trigger
39
+ * — and the same shape reversed on the way out.
41
40
  *
42
41
  * Driven IMPERATIVELY from one shared value, which is the only mechanism
43
42
  * available here and is what both platform rules point at:
@@ -86,11 +85,6 @@ import {
86
85
  MENU_MOTION_EASING,
87
86
  MENU_MOTION_SCALE_FROM,
88
87
  MENU_PANEL_CLASS,
89
- PANEL_CLASS,
90
- PANEL_MOTION_DURATION,
91
- PANEL_MOTION_EASING,
92
- PANEL_MOTION_SCALE_FROM,
93
- PANEL_MOTION_SLIDE,
94
88
  VIEWPORT_GUTTER,
95
89
  } from './constants';
96
90
  import { useMenuPalette } from './menu-palette';
@@ -105,25 +99,23 @@ import type { FloatingPanelProps, FloatingSide } from './types';
105
99
  */
106
100
  const AnimatedPanel = Animated.createAnimatedComponent(StyledView);
107
101
 
108
- /** `cubic-bezier(0.22, 1, 0.36, 1)`, the target's `--ease-out-quint`. */
109
- const EASING = Easing.bezier(...PANEL_MOTION_EASING);
110
-
111
102
  /** Tailwind v4 `ease-out`, the menu curve. */
112
103
  const MENU_EASING = Easing.bezier(...MENU_MOTION_EASING);
113
104
 
114
105
  /**
115
- * The per-surface chrome and motion. `popover` is the original Radix-derived
116
- * panel; `menu` and `listbox` use the menu recipe (`menu-styles.ts`), whose
117
- * colours come from `menu-palette.ts`.
106
+ * The per-surface chrome and motion. All three share the one popover motion;
107
+ * `menu` and `listbox` use the menu recipe (`menu-styles.ts`) with colours from
108
+ * `menu-palette.ts`, while `popover` leaves the whole panel to its caller's
109
+ * resolved `style` (`popover/surface.ts`).
118
110
  */
119
111
  const SURFACE = {
120
112
  popover: {
121
- className: PANEL_CLASS,
122
- duration: PANEL_MOTION_DURATION,
123
- easing: EASING,
124
- scaleFrom: PANEL_MOTION_SCALE_FROM,
125
- slide: PANEL_MOTION_SLIDE,
126
- blur: 0,
113
+ className: '',
114
+ duration: MENU_MOTION_DURATION,
115
+ easing: MENU_EASING,
116
+ scaleFrom: MENU_MOTION_SCALE_FROM,
117
+ slide: 0,
118
+ blur: MENU_MOTION_BLUR,
127
119
  },
128
120
  menu: {
129
121
  className: MENU_PANEL_CLASS,
@@ -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 ROLES ─────────────────────────────────────────────────────────────
37
+ * ── COLOUR ──────────────────────────────────────────────────────────────────
38
38
  *
39
- * The target's tokens are its own app's (`bg-surface-elevated`, `border-border-l1`,
40
- * `bg-button-ghost-hover`, `text-fg-secondary`) and are not portable. They map
41
- * onto Bloom's like this. Nothing below is a literal colour, and no token is
42
- * ever alpha-suffixed (Bloom tokens resolve to `rgb(...)`, so appending hex
43
- * alpha parses back OPAQUE).
44
- *
45
- * | target | Bloom class | why |
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
- * How long the enter and the exit run, and the curve they run on.
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)`. A popover keeps the `PANEL_MOTION_*` above.
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 (`PANEL_MOTION_DURATION`,
81
- * ~12 frames at 60Hz) with room for a slower machine, and cheap because a
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
- * `PANEL_CLASS`'s padding and the gap does not move.
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
@@ -122,10 +122,11 @@ export interface FloatingPanelProps extends FloatingPositionProps {
122
122
  testID?: string;
123
123
  children?: React.ReactNode;
124
124
  /**
125
- * Which chrome and motion the panel wears. `'popover'` (the default) is the
126
- * original panel; `'menu'` and `'listbox'` are the menu recipe — the
127
- * `p-2.5` action menu and the `p-2` select listbox — painted from
128
- * `menu-palette.ts`, on a 150ms fade + scale + blur with no slide.
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
  }
@@ -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 { View } from 'react-native';
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({ children, label = 'Popover', style }: PopoverContentProps) {
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 control={control} label={label} onClose={onSheetClose} contentStyle={style}>
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 defaults: it centres on its
5
- * trigger (shadcn's `align="center"`), it is padded because its body is
6
- * arbitrary content rather than rows, and it does not take the trigger's width
7
- * as a floor — a menu wants to be at least as wide as what opened it, a popover
8
- * wants to be as wide as its content.
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 { View } from 'react-native';
12
+ import { useWindowDimensions, type View } from 'react-native';
12
13
 
13
- import { POPOVER_CLASS, POPOVER_TRIGGER_POPUP } from '../floating/constants';
14
+ import { POPOVER_TRIGGER_POPUP } from '../floating/constants';
14
15
  import { FloatingPanel } from '../floating/FloatingPanel';
15
- import { cx } from '../floating/shared';
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
- // `w-72 p-4` — shadcn's popover is a FIXED 288px card with a 16px inset,
98
- // not a shrink-wrap around its content. A caller whose body is a row list
99
- // rather than prose overrides them, which is exactly what a shadcn call
100
- // site does with `className="w-[200px] p-0"` and what
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>
@@ -1,2 +1,18 @@
1
1
  export { Popover, PopoverTrigger, PopoverContent } from './Popover';
2
- export type { PopoverProps, PopoverTriggerProps, PopoverContentProps } from './types';
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';
@@ -1,2 +1,18 @@
1
1
  export { Popover, PopoverTrigger, PopoverContent } from './Popover.web';
2
- export type { PopoverProps, PopoverTriggerProps, PopoverContentProps } from './types';
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
+ }