@oxy.so/bloom 7.19.1 → 7.19.2
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/docs/adoption-matrix.mdx +5 -5
- package/docs/popover.mdx +2 -0
- package/lib/commonjs/popover/Popover.web.js +11 -1
- package/lib/commonjs/popover/Popover.web.js.map +1 -1
- package/lib/commonjs/popover/context.js.map +1 -1
- package/lib/module/popover/Popover.web.js +11 -1
- package/lib/module/popover/Popover.web.js.map +1 -1
- package/lib/module/popover/context.js.map +1 -1
- package/lib/typescript/commonjs/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/context.d.ts +16 -2
- package/lib/typescript/commonjs/popover/context.d.ts.map +1 -1
- package/lib/typescript/module/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/context.d.ts +16 -2
- package/lib/typescript/module/popover/context.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/popover/Popover.web.tsx +12 -1
- package/src/popover/context.ts +9 -3
package/docs/adoption-matrix.mdx
CHANGED
|
@@ -136,7 +136,7 @@ The classification is an EQUALITY in `src/__tests__/adoption-matrix.test.ts`, no
|
|
|
136
136
|
| `bottom-bar` | `@oxy.so/bloom/bottom-bar` + barrel | web fork | `bottom-bar.mdx` | yes | 2 | | | | |
|
|
137
137
|
| `bottom-sheet` | `@oxy.so/bloom/bottom-sheet` + barrel | web fork | `bottom-sheet.mdx` | yes | 8 | | | | |
|
|
138
138
|
| `breadcrumb` | `@oxy.so/bloom/breadcrumb` + barrel | universal | `breadcrumb.mdx` | yes | 2 | | | | |
|
|
139
|
-
| `button` | `@oxy.so/bloom/button` + barrel | web fork | `button.mdx` | yes |
|
|
139
|
+
| `button` | `@oxy.so/bloom/button` + barrel | web fork | `button.mdx` | yes | 44 | | reads | n/a¹ | |
|
|
140
140
|
| `button-group` | `@oxy.so/bloom/button-group` + barrel | web fork | `button-group.mdx` | yes | 8 | | reads | | |
|
|
141
141
|
| `calendar` | `@oxy.so/bloom/calendar` + barrel | universal | `calendar.mdx` | yes | 3 | | | | reads |
|
|
142
142
|
| `call-ui` | `@oxy.so/bloom/call-ui` + barrel | universal | `call-ui.mdx` | yes | 2 | | reads | | |
|
|
@@ -171,7 +171,7 @@ The classification is an EQUALITY in `src/__tests__/adoption-matrix.test.ts`, no
|
|
|
171
171
|
| `date-picker` | `@oxy.so/bloom/date-picker` + barrel | universal | `date-picker.mdx` | yes | 5 | reads | reads | | reads |
|
|
172
172
|
| `delivery-slot` | `@oxy.so/bloom/delivery-slot` + barrel | universal | `delivery-slot.mdx` | yes | 2 | reads | | | |
|
|
173
173
|
| `design-tokens` | `@oxy.so/bloom/design-tokens` + barrel | universal | `design-tokens.mdx` | yes | 6 | | | | |
|
|
174
|
-
| `dialog` | `@oxy.so/bloom/dialog` + barrel | web fork | `dialog.mdx` | yes |
|
|
174
|
+
| `dialog` | `@oxy.so/bloom/dialog` + barrel | web fork | `dialog.mdx` | yes | 25 | | | | |
|
|
175
175
|
| `directions` | `@oxy.so/bloom/directions` + barrel | universal | `directions.mdx` | yes | 3 | | | | |
|
|
176
176
|
| `divider` | `@oxy.so/bloom/divider` + barrel | universal | `divider.mdx` | yes | 1 | | | | |
|
|
177
177
|
| `dropdown-menu` | `@oxy.so/bloom/dropdown-menu` + barrel | web fork | `dropdown-menu.mdx` | yes | 5 | | | reads | reads |
|
|
@@ -243,7 +243,7 @@ The classification is an EQUALITY in `src/__tests__/adoption-matrix.test.ts`, no
|
|
|
243
243
|
| `order-confirmation` | `@oxy.so/bloom/order-confirmation` + barrel | universal | `order-confirmation.mdx` | yes | 1 | | | | |
|
|
244
244
|
| `order-status` | `@oxy.so/bloom/order-status` + barrel | universal | `order-status.mdx` | yes | 1 | | | | |
|
|
245
245
|
| `outline-nav` | `@oxy.so/bloom/outline-nav` + barrel | universal | `outline-nav.mdx` | yes | 2 | | | | |
|
|
246
|
-
| `overlay` | `@oxy.so/bloom/overlay` + barrel | universal | `overlay.mdx` | yes |
|
|
246
|
+
| `overlay` | `@oxy.so/bloom/overlay` + barrel | universal | `overlay.mdx` | yes | 21 | | | | |
|
|
247
247
|
| `page-footer` | `@oxy.so/bloom/page-footer` + barrel | universal | `page-footer.mdx` | yes | 3 | | | | |
|
|
248
248
|
| `page-header` | `@oxy.so/bloom/page-header` + barrel | universal | `page-header.mdx` | yes | 8 | | | | |
|
|
249
249
|
| `pagination` | `@oxy.so/bloom/pagination` + barrel | universal | `pagination.mdx` | yes | 2 | | | | |
|
|
@@ -256,7 +256,7 @@ The classification is an EQUALITY in `src/__tests__/adoption-matrix.test.ts`, no
|
|
|
256
256
|
| `place-details` | `@oxy.so/bloom/place-details` + barrel | universal | `place-details.mdx` | yes | 2 | | | | reads |
|
|
257
257
|
| `place-list` | `@oxy.so/bloom/place-list` + barrel | universal | `place-list.mdx` | yes | 2 | | | | |
|
|
258
258
|
| `place-reviews` | `@oxy.so/bloom/place-reviews` + barrel | universal | `place-reviews.mdx` | yes | 2 | | | | reads |
|
|
259
|
-
| `popover` | `@oxy.so/bloom/popover` + barrel | web fork | `popover.mdx` | yes |
|
|
259
|
+
| `popover` | `@oxy.so/bloom/popover` + barrel | web fork | `popover.mdx` | yes | 10 | | | reads | reads |
|
|
260
260
|
| `portal` | `@oxy.so/bloom/portal` + barrel | web fork | `portal.mdx` | yes | 24 | | | | |
|
|
261
261
|
| `pressable-scale` | `@oxy.so/bloom/pressable-scale` + barrel | universal | `pressable-scale.mdx` | yes | 1 | | | | |
|
|
262
262
|
| `price-breakdown` | `@oxy.so/bloom/price-breakdown` + barrel | universal | `price-breakdown.mdx` | yes | 3 | | | | reads |
|
|
@@ -308,7 +308,7 @@ The classification is an EQUALITY in `src/__tests__/adoption-matrix.test.ts`, no
|
|
|
308
308
|
| `tenancy` | `@oxy.so/bloom/tenancy` + barrel | universal | `tenancy.mdx` | yes | 5 | | reads | | |
|
|
309
309
|
| `text-field` | `@oxy.so/bloom/text-field` + barrel | universal | `text-field.mdx` | yes | 17 | reads | reads | | |
|
|
310
310
|
| `textarea` | `@oxy.so/bloom/textarea` + barrel | universal | `textarea.mdx` | yes | 4 | reads | reads | | n/a¹ |
|
|
311
|
-
| `theme` | `@oxy.so/bloom/theme` + barrel | web fork | `theme.mdx` | yes |
|
|
311
|
+
| `theme` | `@oxy.so/bloom/theme` + barrel | web fork | `theme.mdx` | yes | 373 | | | n/a¹ | reads |
|
|
312
312
|
| `theme-toggle` | `@oxy.so/bloom/theme-toggle` + barrel | universal | `theme-toggle.mdx` | yes | 2 | n/a¹ | | | |
|
|
313
313
|
| `toast` | `@oxy.so/bloom/toast` + barrel | universal | `toast.mdx` | yes | 17 | | | | |
|
|
314
314
|
| `tooltip` | `@oxy.so/bloom/tooltip` + barrel | web fork | `tooltip.mdx` | yes | 1 | | | | |
|
package/docs/popover.mdx
CHANGED
|
@@ -150,3 +150,5 @@ rim and refraction. Its authored `style.backgroundColor` paints directly and is
|
|
|
150
150
|
published as the descendant surface backing. On native the owning bottom sheet
|
|
151
151
|
uses the same flat fill. Padding, radius, shadow and keyboard/placement behavior
|
|
152
152
|
are unchanged; the default `material="surface"` preserves the standard treatment.
|
|
153
|
+
|
|
154
|
+
On web, closing with Escape or an action inside the panel returns focus to its trigger without scrolling. Focus deliberately moved to another control is preserved. This also applies when the caller conditionally unmounts `PopoverContent` on close; the native sheet retains its existing focus lifecycle.
|
|
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _reactNative = require("react-native");
|
|
11
11
|
var _constants = require("../floating/constants.js");
|
|
12
12
|
var _FloatingPanel = require("../floating/FloatingPanel.js");
|
|
13
|
+
var _menuKeyboard = require("../floating/menu-keyboard.js");
|
|
13
14
|
var _menuPalette = require("../floating/menu-palette.js");
|
|
14
15
|
var _TriggerSlot = require("../floating/TriggerSlot.js");
|
|
15
16
|
var _useAnchorRect = require("../floating/use-anchor-rect.js");
|
|
@@ -43,10 +44,15 @@ function Popover({
|
|
|
43
44
|
onChange: onOpenChange
|
|
44
45
|
});
|
|
45
46
|
const anchorRef = (0, _react.useRef)(null);
|
|
47
|
+
const panelRef = (0, _react.useRef)(null);
|
|
48
|
+
// The root survives conditionally mounted content, so a caller removing the
|
|
49
|
+
// panel on close still gets the same focus return as an animated exit.
|
|
50
|
+
(0, _menuKeyboard.useReturnFocusOnClose)(anchorRef, isOpen, element => (0, _menuKeyboard.hostElement)(panelRef.current)?.contains(element) ?? false);
|
|
46
51
|
const value = (0, _react.useMemo)(() => ({
|
|
47
52
|
open: isOpen,
|
|
48
53
|
setOpen,
|
|
49
|
-
anchorRef
|
|
54
|
+
anchorRef,
|
|
55
|
+
panelRef
|
|
50
56
|
}), [isOpen, setOpen]);
|
|
51
57
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.PopoverProvider, {
|
|
52
58
|
value: value,
|
|
@@ -101,6 +107,9 @@ function PopoverContent({
|
|
|
101
107
|
const label = labelProp ?? messages.popover;
|
|
102
108
|
const popover = (0, _context.usePopover)();
|
|
103
109
|
const anchor = (0, _useAnchorRect.useAnchorRect)(popover.anchorRef, popover.open);
|
|
110
|
+
const attachPanel = (0, _react.useCallback)(node => {
|
|
111
|
+
if (popover.panelRef) popover.panelRef.current = node;
|
|
112
|
+
}, [popover.panelRef]);
|
|
104
113
|
const close = (0, _react.useCallback)(() => popover.setOpen(false), [popover]);
|
|
105
114
|
const palette = (0, _menuPalette.useMenuPalette)();
|
|
106
115
|
const {
|
|
@@ -110,6 +119,7 @@ function PopoverContent({
|
|
|
110
119
|
const chrome = (0, _react.useMemo)(() => (0, _surface.resolvePopoverSurfaceStyle)(palette, overridden, maxWidth === undefined ? viewportWidth : undefined), [palette, overridden, maxWidth, viewportWidth]);
|
|
111
120
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FloatingPanel.FloatingPanel, {
|
|
112
121
|
material: material,
|
|
122
|
+
panelRef: attachPanel,
|
|
113
123
|
open: popover.open,
|
|
114
124
|
anchor: anchor,
|
|
115
125
|
role: "dialog",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_constants","_FloatingPanel","_menuPalette","_TriggerSlot","_useAnchorRect","_useControllableState","_context","_surface","_messages","_messages2","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Popover","children","open","defaultOpen","onOpenChange","isOpen","setOpen","useControllableState","value","defaultValue","onChange","anchorRef","useRef","useMemo","jsx","PopoverProvider","PopoverTrigger","asChild","disabled","label","className","style","testID","popover","usePopover","TriggerSlot","handle","onPress","accessibilityLabel","accessibilityRole","POPOVER_TRIGGER_POPUP","PopoverContent","material","labelProp","side","align","sideOffset","POPOVER_SIDE_OFFSET","alignOffset","dismissible","minWidth","maxWidth","messages","useMessages","POPOVER_MESSAGES","anchor","useAnchorRect","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_constants","_FloatingPanel","_menuKeyboard","_menuPalette","_TriggerSlot","_useAnchorRect","_useControllableState","_context","_surface","_messages","_messages2","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Popover","children","open","defaultOpen","onOpenChange","isOpen","setOpen","useControllableState","value","defaultValue","onChange","anchorRef","useRef","panelRef","useReturnFocusOnClose","element","hostElement","current","contains","useMemo","jsx","PopoverProvider","PopoverTrigger","asChild","disabled","label","className","style","testID","popover","usePopover","TriggerSlot","handle","onPress","accessibilityLabel","accessibilityRole","POPOVER_TRIGGER_POPUP","PopoverContent","material","labelProp","side","align","sideOffset","POPOVER_SIDE_OFFSET","alignOffset","dismissible","minWidth","maxWidth","messages","useMessages","POPOVER_MESSAGES","anchor","useAnchorRect","attachPanel","useCallback","node","close","palette","useMenuPalette","width","viewportWidth","useWindowDimensions","overridden","classChromeOverrides","chrome","resolvePopoverSurfaceStyle","undef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AEb,KAAM;IACjB9B,SAAS,EAAEA;IACX;IACA;IAAA;IACAC,KAAK,EAAE,CAACqC,MAAM,EAAErC,KAAK,CAAE;IACvBC,MAAM,EAAEA,MAAO;IAAA3B,QAAA,EACdA;EAAQ,CACI,CAAC;AAEpB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","PopoverContext","createContext","displayName","PopoverProvider","exports","Provider","usePopover","value","useContext","Error"],"sourceRoot":"../../../src","sources":["popover/context.ts"],"mappings":";;;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AAPA;AACA;AACA;AACA;AACA;AACA;AACA;;
|
|
1
|
+
{"version":3,"names":["_react","require","PopoverContext","createContext","displayName","PopoverProvider","exports","Provider","usePopover","value","useContext","Error"],"sourceRoot":"../../../src","sources":["popover/context.ts"],"mappings":";;;;;;;AAOA,IAAAA,MAAA,GAAAC,OAAA;AAPA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,MAAMC,cAAc,gBAAG,IAAAC,oBAAa,EAA6B,IAAI,CAAC;AACtED,cAAc,CAACE,WAAW,GAAG,qBAAqB;AAE3C,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAGH,cAAc,CAACK,QAAQ;AAE/C,SAASC,UAAUA,CAAA,EAAwB;EAChD,MAAMC,KAAK,GAAG,IAAAC,iBAAU,EAACR,cAAc,CAAC;EACxC,IAAI,CAACO,KAAK,EAAE;IACV,MAAM,IAAIE,KAAK,CAAC,oDAAoD,CAAC;EACvE;EACA,OAAOF,KAAK;AACd","ignoreList":[]}
|
|
@@ -14,6 +14,7 @@ import React, { useCallback, useMemo, useRef } from 'react';
|
|
|
14
14
|
import { useWindowDimensions } from 'react-native';
|
|
15
15
|
import { POPOVER_TRIGGER_POPUP } from "../floating/constants.js";
|
|
16
16
|
import { FloatingPanel } from "../floating/FloatingPanel.js";
|
|
17
|
+
import { hostElement, useReturnFocusOnClose } from "../floating/menu-keyboard.js";
|
|
17
18
|
import { useMenuPalette } from "../floating/menu-palette.js";
|
|
18
19
|
import { TriggerSlot } from "../floating/TriggerSlot.js";
|
|
19
20
|
import { useAnchorRect } from "../floating/use-anchor-rect.js";
|
|
@@ -35,10 +36,15 @@ export function Popover({
|
|
|
35
36
|
onChange: onOpenChange
|
|
36
37
|
});
|
|
37
38
|
const anchorRef = useRef(null);
|
|
39
|
+
const panelRef = useRef(null);
|
|
40
|
+
// The root survives conditionally mounted content, so a caller removing the
|
|
41
|
+
// panel on close still gets the same focus return as an animated exit.
|
|
42
|
+
useReturnFocusOnClose(anchorRef, isOpen, element => hostElement(panelRef.current)?.contains(element) ?? false);
|
|
38
43
|
const value = useMemo(() => ({
|
|
39
44
|
open: isOpen,
|
|
40
45
|
setOpen,
|
|
41
|
-
anchorRef
|
|
46
|
+
anchorRef,
|
|
47
|
+
panelRef
|
|
42
48
|
}), [isOpen, setOpen]);
|
|
43
49
|
return /*#__PURE__*/_jsx(PopoverProvider, {
|
|
44
50
|
value: value,
|
|
@@ -93,6 +99,9 @@ export function PopoverContent({
|
|
|
93
99
|
const label = labelProp ?? messages.popover;
|
|
94
100
|
const popover = usePopover();
|
|
95
101
|
const anchor = useAnchorRect(popover.anchorRef, popover.open);
|
|
102
|
+
const attachPanel = useCallback(node => {
|
|
103
|
+
if (popover.panelRef) popover.panelRef.current = node;
|
|
104
|
+
}, [popover.panelRef]);
|
|
96
105
|
const close = useCallback(() => popover.setOpen(false), [popover]);
|
|
97
106
|
const palette = useMenuPalette();
|
|
98
107
|
const {
|
|
@@ -102,6 +111,7 @@ export function PopoverContent({
|
|
|
102
111
|
const chrome = useMemo(() => resolvePopoverSurfaceStyle(palette, overridden, maxWidth === undefined ? viewportWidth : undefined), [palette, overridden, maxWidth, viewportWidth]);
|
|
103
112
|
return /*#__PURE__*/_jsx(FloatingPanel, {
|
|
104
113
|
material: material,
|
|
114
|
+
panelRef: attachPanel,
|
|
105
115
|
open: popover.open,
|
|
106
116
|
anchor: anchor,
|
|
107
117
|
role: "dialog",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useMemo","useRef","useWindowDimensions","POPOVER_TRIGGER_POPUP","FloatingPanel","useMenuPalette","TriggerSlot","useAnchorRect","useControllableState","PopoverProvider","usePopover","classChromeOverrides","POPOVER_SIDE_OFFSET","resolvePopoverSurfaceStyle","useMessages","POPOVER_MESSAGES","jsx","_jsx","Popover","children","open","defaultOpen","onOpenChange","isOpen","setOpen","value","defaultValue","onChange","anchorRef","PopoverTrigger","asChild","disabled","label","className","style","testID","popover","handle","onPress","accessibilityLabel","accessibilityRole","PopoverContent","material","labelProp","side","align","sideOffset","alignOffset","dismissible","minWidth","maxWidth","messages","anchor","close","palette","width","viewportWidth","overridden","chrome","undefined","role","onDismiss"],"sourceRoot":"../../../src","sources":["popover/Popover.web.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC3D,SAASC,mBAAmB,QAAmB,cAAc;AAE7D,SAASC,qBAAqB,QAAQ,0BAAuB;AAC7D,SAASC,aAAa,QAAQ,8BAA2B;AACzD,SAASC,cAAc,QAAQ,6BAA0B;AACzD,SAASC,WAAW,QAAQ,4BAAyB;AACrD,SAASC,aAAa,QAAQ,gCAA6B;AAC3D,SAASC,oBAAoB,QAAQ,oCAAiC;AACtE,SAASC,eAAe,EAAEC,UAAU,QAAQ,cAAW;AACvD,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,0BAA0B,QACrB,cAAW;AAElB,SAASC,WAAW,QAAQ,uBAAoB;AAChD,SAASC,gBAAgB,QAAQ,eAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE9C,OAAO,SAASC,OAAOA,CAAC;EAAEC,QAAQ;EAAEC,IAAI;EAAEC,WAAW,GAAG,KAAK;EAAEC;AAA2B,CAAC,EAAE;EAC3F,MAAM,CAACC,MAAM,EAAEC,OAAO,CAAC,GAAGhB,oBAAoB,CAAU;IACtDiB,KAAK,EAAEL,IAAI;IACXM,YAAY,EAAEL,WAAW;IACzBM,QAAQ,EAAEL;EACZ,CAAC,CAAC;EACF,MAAMM,SAAS,
|
|
1
|
+
{"version":3,"names":["React","useCallback","useMemo","useRef","useWindowDimensions","POPOVER_TRIGGER_POPUP","FloatingPanel","hostElement","useReturnFocusOnClose","useMenuPalette","TriggerSlot","useAnchorRect","useControllableState","PopoverProvider","usePopover","classChromeOverrides","POPOVER_SIDE_OFFSET","resolvePopoverSurfaceStyle","useMessages","POPOVER_MESSAGES","jsx","_jsx","Popover","children","open","defaultOpen","onOpenChange","isOpen","setOpen","value","defaultValue","onChange","anchorRef","panelRef","element","current","contains","PopoverTrigger","asChild","disabled","label","className","style","testID","popover","handle","onPress","accessibilityLabel","accessibilityRole","PopoverContent","material","labelProp","side","align","sideOffset","alignOffset","dismissible","minWidth","maxWidth","messages","anchor","attachPanel","node","close","palette","width","viewportWidth","overridden","chrome","undefined","role","onDismiss"],"sourceRoot":"../../../src","sources":["popover/Popover.web.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC3D,SAASC,mBAAmB,QAAmB,cAAc;AAE7D,SAASC,qBAAqB,QAAQ,0BAAuB;AAC7D,SAASC,aAAa,QAAQ,8BAA2B;AACzD,SAASC,WAAW,EAAEC,qBAAqB,QAAQ,8BAA2B;AAC9E,SAASC,cAAc,QAAQ,6BAA0B;AACzD,SAASC,WAAW,QAAQ,4BAAyB;AACrD,SAASC,aAAa,QAAQ,gCAA6B;AAC3D,SAASC,oBAAoB,QAAQ,oCAAiC;AACtE,SAASC,eAAe,EAAEC,UAAU,QAAQ,cAAW;AACvD,SACEC,oBAAoB,EACpBC,mBAAmB,EACnBC,0BAA0B,QACrB,cAA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Ac,CAAC,CAAC;EAChC,MAAM;IAAEwD,KAAK,EAAEC;EAAc,CAAC,GAAG9D,mBAAmB,CAAC,CAAC;EACtD,MAAM+D,UAAU,GAAGjE,OAAO,CAAC,MAAMa,oBAAoB,CAAC0B,SAAS,CAAC,EAAE,CAACA,SAAS,CAAC,CAAC;EAC9E,MAAM2B,MAAM,GAAGlE,OAAO,CACpB,MACEe,0BAA0B,CACxB+C,OAAO,EACPG,UAAU,EACVT,QAAQ,KAAKW,SAAS,GAAGH,aAAa,GAAGG,SAC3C,CAAC,EACH,CAACL,OAAO,EAAEG,UAAU,EAAET,QAAQ,EAAEQ,aAAa,CAC/C,CAAC;EAED,oBACE7C,IAAA,CAACf,aAAa;IACZ4C,QAAQ,EAAEA,QAAS;IACnBjB,QAAQ,EAAE4B,WAAY;IACtBrC,IAAI,EAAEoB,OAAO,CAACpB,IAAK;IACnBoC,MAAM,EAAEA,MAAO;IACfU,IAAI,EAAC,QAAQ;IACb9B,KAAK,EAAEA,KAAM;IACbY,IAAI,EAAEA,IAAK;IACXC,KAAK,EAAEA,KAAM;IACbC,UAAU,EAAEA,UAAW;IACvBC,WAAW,EAAEA,WAAY;IACzBC,WAAW,EAAEA,WAAY;IACzBC,QAAQ,EAAEA,QAAS;IACnBC,QAAQ,EAAEA,QAAS;IACnBa,SAAS,EAAER,KAAM;IACjBtB,SAAS,EAAEA;IACX;IACA;IAAA;IACAC,KAAK,EAAE,CAAC0B,MAAM,EAAE1B,KAAK,CAAE;IACvBC,MAAM,EAAEA,MAAO;IAAApB,QAAA,EACdA;EAAQ,CACI,CAAC;AAEpB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","PopoverContext","displayName","PopoverProvider","Provider","usePopover","value","Error"],"sourceRoot":"../../../src","sources":["popover/context.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,
|
|
1
|
+
{"version":3,"names":["createContext","useContext","PopoverContext","displayName","PopoverProvider","Provider","usePopover","value","Error"],"sourceRoot":"../../../src","sources":["popover/context.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa,EAAEC,UAAU,QAAwB,OAAO;AAUjE,MAAMC,cAAc,gBAAGF,aAAa,CAA6B,IAAI,CAAC;AACtEE,cAAc,CAACC,WAAW,GAAG,qBAAqB;AAElD,OAAO,MAAMC,eAAe,GAAGF,cAAc,CAACG,QAAQ;AAEtD,OAAO,SAASC,UAAUA,CAAA,EAAwB;EAChD,MAAMC,KAAK,GAAGN,UAAU,CAACC,cAAc,CAAC;EACxC,IAAI,CAACK,KAAK,EAAE;IACV,MAAM,IAAIC,KAAK,CAAC,oDAAoD,CAAC;EACvE;EACA,OAAOD,KAAK;AACd","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.web.d.ts","sourceRoot":"","sources":["../../../../src/popover/Popover.web.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Popover.web.d.ts","sourceRoot":"","sources":["../../../../src/popover/Popover.web.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAItF,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAmB,EAAE,YAAY,EAAE,EAAE,YAAY,2CAgB1F;AAED,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,KAAK,EACL,SAAS,EACT,KAAK,EACL,MAAM,GACP,EAAE,mBAAmB,2CAqBrB;AAED,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,KAAK,EAAE,SAAS,EAChB,IAAI,EACJ,KAAgB,EAChB,UAAgC,EAChC,WAAW,EACX,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,EACL,MAAM,GACP,EAAE,mBAAmB,2CA8CrB"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Popover`'s own open state.
|
|
3
|
+
*
|
|
4
|
+
* Its own context, not a shared one, for the reason the other three families
|
|
5
|
+
* have theirs: a dropdown menu opened from inside a popover must drive the MENU,
|
|
6
|
+
* and one shared open-state context would hand it the popover instead.
|
|
7
|
+
*/
|
|
8
|
+
import { type RefObject } from 'react';
|
|
9
|
+
import type { View } from 'react-native';
|
|
1
10
|
import type { OverlayShellContextValue } from '../floating/types';
|
|
2
|
-
|
|
3
|
-
|
|
11
|
+
interface PopoverContextValue extends OverlayShellContextValue {
|
|
12
|
+
/** Web floating host; the native sheet owns its own focus lifecycle. */
|
|
13
|
+
panelRef?: RefObject<View | null>;
|
|
14
|
+
}
|
|
15
|
+
export declare const PopoverProvider: import("react").Provider<PopoverContextValue | null>;
|
|
16
|
+
export declare function usePopover(): PopoverContextValue;
|
|
17
|
+
export {};
|
|
4
18
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/popover/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/popover/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,UAAU,mBAAoB,SAAQ,wBAAwB;IAC5D,wEAAwE;IACxE,QAAQ,CAAC,EAAE,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;CACnC;AAKD,eAAO,MAAM,eAAe,sDAA0B,CAAC;AAEvD,wBAAgB,UAAU,IAAI,mBAAmB,CAMhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.web.d.ts","sourceRoot":"","sources":["../../../../src/popover/Popover.web.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Popover.web.d.ts","sourceRoot":"","sources":["../../../../src/popover/Popover.web.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAItF,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAmB,EAAE,YAAY,EAAE,EAAE,YAAY,2CAgB1F;AAED,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,KAAK,EACL,SAAS,EACT,KAAK,EACL,MAAM,GACP,EAAE,mBAAmB,2CAqBrB;AAED,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,QAAQ,EACR,KAAK,EAAE,SAAS,EAChB,IAAI,EACJ,KAAgB,EAChB,UAAgC,EAChC,WAAW,EACX,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,KAAK,EACL,MAAM,GACP,EAAE,mBAAmB,2CA8CrB"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Popover`'s own open state.
|
|
3
|
+
*
|
|
4
|
+
* Its own context, not a shared one, for the reason the other three families
|
|
5
|
+
* have theirs: a dropdown menu opened from inside a popover must drive the MENU,
|
|
6
|
+
* and one shared open-state context would hand it the popover instead.
|
|
7
|
+
*/
|
|
8
|
+
import { type RefObject } from 'react';
|
|
9
|
+
import type { View } from 'react-native';
|
|
1
10
|
import type { OverlayShellContextValue } from '../floating/types';
|
|
2
|
-
|
|
3
|
-
|
|
11
|
+
interface PopoverContextValue extends OverlayShellContextValue {
|
|
12
|
+
/** Web floating host; the native sheet owns its own focus lifecycle. */
|
|
13
|
+
panelRef?: RefObject<View | null>;
|
|
14
|
+
}
|
|
15
|
+
export declare const PopoverProvider: import("react").Provider<PopoverContextValue | null>;
|
|
16
|
+
export declare function usePopover(): PopoverContextValue;
|
|
17
|
+
export {};
|
|
4
18
|
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/popover/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/popover/context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,UAAU,mBAAoB,SAAQ,wBAAwB;IAC5D,wEAAwE;IACxE,QAAQ,CAAC,EAAE,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;CACnC;AAKD,eAAO,MAAM,eAAe,sDAA0B,CAAC;AAEvD,wBAAgB,UAAU,IAAI,mBAAmB,CAMhD"}
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import { useWindowDimensions, type View } from 'react-native';
|
|
|
13
13
|
|
|
14
14
|
import { POPOVER_TRIGGER_POPUP } from '../floating/constants';
|
|
15
15
|
import { FloatingPanel } from '../floating/FloatingPanel';
|
|
16
|
+
import { hostElement, useReturnFocusOnClose } from '../floating/menu-keyboard';
|
|
16
17
|
import { useMenuPalette } from '../floating/menu-palette';
|
|
17
18
|
import { TriggerSlot } from '../floating/TriggerSlot';
|
|
18
19
|
import { useAnchorRect } from '../floating/use-anchor-rect';
|
|
@@ -34,7 +35,13 @@ export function Popover({ children, open, defaultOpen = false, onOpenChange }: P
|
|
|
34
35
|
onChange: onOpenChange,
|
|
35
36
|
});
|
|
36
37
|
const anchorRef = useRef<View | null>(null);
|
|
37
|
-
const
|
|
38
|
+
const panelRef = useRef<View | null>(null);
|
|
39
|
+
// The root survives conditionally mounted content, so a caller removing the
|
|
40
|
+
// panel on close still gets the same focus return as an animated exit.
|
|
41
|
+
useReturnFocusOnClose(anchorRef, isOpen, (element) =>
|
|
42
|
+
hostElement(panelRef.current)?.contains(element) ?? false,
|
|
43
|
+
);
|
|
44
|
+
const value = useMemo(() => ({ open: isOpen, setOpen, anchorRef, panelRef }), [isOpen, setOpen]);
|
|
38
45
|
|
|
39
46
|
return <PopoverProvider value={value}>{children}</PopoverProvider>;
|
|
40
47
|
}
|
|
@@ -89,6 +96,9 @@ export function PopoverContent({
|
|
|
89
96
|
const label = labelProp ?? messages.popover;
|
|
90
97
|
const popover = usePopover();
|
|
91
98
|
const anchor = useAnchorRect(popover.anchorRef, popover.open);
|
|
99
|
+
const attachPanel = useCallback((node: View | null) => {
|
|
100
|
+
if (popover.panelRef) popover.panelRef.current = node;
|
|
101
|
+
}, [popover.panelRef]);
|
|
92
102
|
const close = useCallback(() => popover.setOpen(false), [popover]);
|
|
93
103
|
const palette = useMenuPalette();
|
|
94
104
|
const { width: viewportWidth } = useWindowDimensions();
|
|
@@ -106,6 +116,7 @@ export function PopoverContent({
|
|
|
106
116
|
return (
|
|
107
117
|
<FloatingPanel
|
|
108
118
|
material={material}
|
|
119
|
+
panelRef={attachPanel}
|
|
109
120
|
open={popover.open}
|
|
110
121
|
anchor={anchor}
|
|
111
122
|
role="dialog"
|
package/src/popover/context.ts
CHANGED
|
@@ -5,16 +5,22 @@
|
|
|
5
5
|
* have theirs: a dropdown menu opened from inside a popover must drive the MENU,
|
|
6
6
|
* and one shared open-state context would hand it the popover instead.
|
|
7
7
|
*/
|
|
8
|
-
import { createContext, useContext } from 'react';
|
|
8
|
+
import { createContext, useContext, type RefObject } from 'react';
|
|
9
|
+
import type { View } from 'react-native';
|
|
9
10
|
|
|
10
11
|
import type { OverlayShellContextValue } from '../floating/types';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
interface PopoverContextValue extends OverlayShellContextValue {
|
|
14
|
+
/** Web floating host; the native sheet owns its own focus lifecycle. */
|
|
15
|
+
panelRef?: RefObject<View | null>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const PopoverContext = createContext<PopoverContextValue | null>(null);
|
|
13
19
|
PopoverContext.displayName = 'BloomPopoverContext';
|
|
14
20
|
|
|
15
21
|
export const PopoverProvider = PopoverContext.Provider;
|
|
16
22
|
|
|
17
|
-
export function usePopover():
|
|
23
|
+
export function usePopover(): PopoverContextValue {
|
|
18
24
|
const value = useContext(PopoverContext);
|
|
19
25
|
if (!value) {
|
|
20
26
|
throw new Error('Popover parts must be rendered inside a <Popover>.');
|