@tamagui/popover 1.30.7 → 1.30.9
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/dist/cjs/Popover.js +49 -85
- package/dist/cjs/Popover.js.map +2 -2
- package/dist/esm/Popover.js +49 -84
- package/dist/esm/Popover.js.map +2 -2
- package/dist/jsx/Popover.js +46 -86
- package/dist/jsx/Popover.js.map +2 -2
- package/dist/jsx/Popover.mjs +46 -86
- package/dist/jsx/Popover.mjs.map +2 -2
- package/package.json +18 -19
- package/src/Popover.tsx +75 -137
- package/types/Popover.d.ts +18 -134
- package/types/Popover.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/popover",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.9",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -32,30 +32,29 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@floating-ui/react": "^0.24.2",
|
|
35
|
-
"@tamagui/adapt": "1.30.
|
|
36
|
-
"@tamagui/animate-presence": "1.30.
|
|
37
|
-
"@tamagui/aria-hidden": "1.30.
|
|
38
|
-
"@tamagui/compose-refs": "1.30.
|
|
39
|
-
"@tamagui/core": "1.30.
|
|
40
|
-
"@tamagui/
|
|
41
|
-
"@tamagui/
|
|
42
|
-
"@tamagui/
|
|
43
|
-
"@tamagui/
|
|
44
|
-
"@tamagui/
|
|
45
|
-
"@tamagui/
|
|
46
|
-
"@tamagui/
|
|
47
|
-
"@tamagui/
|
|
48
|
-
"@tamagui/
|
|
49
|
-
"@tamagui/
|
|
50
|
-
"@tamagui/
|
|
51
|
-
"@tamagui/use-controllable-state": "1.30.7"
|
|
35
|
+
"@tamagui/adapt": "1.30.9",
|
|
36
|
+
"@tamagui/animate-presence": "1.30.9",
|
|
37
|
+
"@tamagui/aria-hidden": "1.30.9",
|
|
38
|
+
"@tamagui/compose-refs": "1.30.9",
|
|
39
|
+
"@tamagui/core": "1.30.9",
|
|
40
|
+
"@tamagui/dismissable": "1.30.9",
|
|
41
|
+
"@tamagui/floating": "1.30.9",
|
|
42
|
+
"@tamagui/focus-scope": "1.30.9",
|
|
43
|
+
"@tamagui/polyfill-dev": "1.30.9",
|
|
44
|
+
"@tamagui/popper": "1.30.9",
|
|
45
|
+
"@tamagui/portal": "1.30.9",
|
|
46
|
+
"@tamagui/remove-scroll": "1.30.9",
|
|
47
|
+
"@tamagui/scroll-view": "1.30.9",
|
|
48
|
+
"@tamagui/sheet": "1.30.9",
|
|
49
|
+
"@tamagui/stacks": "1.30.9",
|
|
50
|
+
"@tamagui/use-controllable-state": "1.30.9"
|
|
52
51
|
},
|
|
53
52
|
"peerDependencies": {
|
|
54
53
|
"react": "*",
|
|
55
54
|
"react-native": "*"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
|
-
"@tamagui/build": "1.30.
|
|
57
|
+
"@tamagui/build": "1.30.9",
|
|
59
58
|
"react": "^18.2.0",
|
|
60
59
|
"react-native": "^0.71.7"
|
|
61
60
|
},
|
package/src/Popover.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
TamaguiElement,
|
|
14
14
|
Theme,
|
|
15
15
|
composeEventHandlers,
|
|
16
|
+
createStyledContext,
|
|
16
17
|
isWeb,
|
|
17
18
|
useEvent,
|
|
18
19
|
useGet,
|
|
@@ -20,8 +21,6 @@ import {
|
|
|
20
21
|
useThemeName,
|
|
21
22
|
withStaticProperties,
|
|
22
23
|
} from '@tamagui/core'
|
|
23
|
-
import type { Scope } from '@tamagui/create-context'
|
|
24
|
-
import { createContextScope } from '@tamagui/create-context'
|
|
25
24
|
import { DismissableProps } from '@tamagui/dismissable'
|
|
26
25
|
import { FloatingOverrideContext } from '@tamagui/floating'
|
|
27
26
|
import { FocusScope, FocusScopeProps } from '@tamagui/focus-scope'
|
|
@@ -33,9 +32,8 @@ import {
|
|
|
33
32
|
PopperContent,
|
|
34
33
|
PopperContentFrame,
|
|
35
34
|
PopperContentProps,
|
|
35
|
+
PopperContext,
|
|
36
36
|
PopperProps,
|
|
37
|
-
PopperProvider,
|
|
38
|
-
createPopperScope,
|
|
39
37
|
usePopperContext,
|
|
40
38
|
} from '@tamagui/popper'
|
|
41
39
|
import { Portal, PortalHost, PortalItem } from '@tamagui/portal'
|
|
@@ -44,14 +42,10 @@ import { Sheet, SheetController } from '@tamagui/sheet'
|
|
|
44
42
|
import { YStack, YStackProps } from '@tamagui/stacks'
|
|
45
43
|
import { useControllableState } from '@tamagui/use-controllable-state'
|
|
46
44
|
import * as React from 'react'
|
|
47
|
-
import { Platform, ScrollView, ScrollViewProps
|
|
45
|
+
import { Platform, ScrollView, ScrollViewProps } from 'react-native'
|
|
48
46
|
|
|
49
47
|
import { useFloatingContext } from './useFloatingContext'
|
|
50
48
|
|
|
51
|
-
const POPOVER_NAME = 'Popover'
|
|
52
|
-
|
|
53
|
-
type ScopedProps<P> = P & { __scopePopover?: Scope }
|
|
54
|
-
|
|
55
49
|
export type PopoverProps = PopperProps & {
|
|
56
50
|
open?: boolean
|
|
57
51
|
defaultOpen?: boolean
|
|
@@ -59,6 +53,7 @@ export type PopoverProps = PopperProps & {
|
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
type PopoverContextValue = {
|
|
56
|
+
id: string
|
|
62
57
|
triggerRef: React.RefObject<any>
|
|
63
58
|
contentId?: string
|
|
64
59
|
open: boolean
|
|
@@ -69,37 +64,22 @@ type PopoverContextValue = {
|
|
|
69
64
|
onCustomAnchorRemove(): void
|
|
70
65
|
size?: SizeTokens
|
|
71
66
|
sheetBreakpoint: any
|
|
72
|
-
scopeKey: string
|
|
73
|
-
popperScope: any
|
|
74
67
|
breakpointActive?: boolean
|
|
75
68
|
}
|
|
76
69
|
|
|
77
|
-
const
|
|
78
|
-
POPOVER_NAME,
|
|
79
|
-
[createPopperScope]
|
|
80
|
-
)
|
|
81
|
-
export const usePopoverScope = createPopperScope()
|
|
82
|
-
export const createPopoverScope = createPopoverScopeInternal
|
|
83
|
-
|
|
84
|
-
const [PopoverProviderInternal, usePopoverInternalContext] =
|
|
85
|
-
createPopoverContext<PopoverContextValue>(POPOVER_NAME)
|
|
70
|
+
export const PopoverContext = createStyledContext<PopoverContextValue>({} as any)
|
|
86
71
|
|
|
87
|
-
export const
|
|
72
|
+
export const usePopoverContext = () => React.useContext(PopoverContext)
|
|
88
73
|
|
|
89
74
|
/* -------------------------------------------------------------------------------------------------
|
|
90
75
|
* PopoverAnchor
|
|
91
76
|
* -----------------------------------------------------------------------------------------------*/
|
|
92
77
|
|
|
93
|
-
const ANCHOR_NAME = 'PopoverAnchor'
|
|
94
|
-
|
|
95
|
-
type PopoverAnchorElement = HTMLElement | View
|
|
96
78
|
export type PopoverAnchorProps = YStackProps
|
|
97
79
|
|
|
98
|
-
export const PopoverAnchor = React.forwardRef<
|
|
99
|
-
(props:
|
|
100
|
-
const
|
|
101
|
-
const context = usePopoverInternalContext(ANCHOR_NAME, __scopePopover)
|
|
102
|
-
const popperScope = usePopoverScope(__scopePopover)
|
|
80
|
+
export const PopoverAnchor = React.forwardRef<TamaguiElement, PopoverAnchorProps>(
|
|
81
|
+
function PopoverAnchor(props: PopoverAnchorProps, forwardedRef) {
|
|
82
|
+
const context = usePopoverContext()
|
|
103
83
|
const { onCustomAnchorAdd, onCustomAnchorRemove } = context
|
|
104
84
|
|
|
105
85
|
React.useEffect(() => {
|
|
@@ -107,60 +87,46 @@ export const PopoverAnchor = React.forwardRef<PopoverAnchorElement, PopoverAncho
|
|
|
107
87
|
return () => onCustomAnchorRemove()
|
|
108
88
|
}, [onCustomAnchorAdd, onCustomAnchorRemove])
|
|
109
89
|
|
|
110
|
-
return <PopperAnchor {...
|
|
90
|
+
return <PopperAnchor {...props} ref={forwardedRef} />
|
|
111
91
|
}
|
|
112
92
|
)
|
|
113
93
|
|
|
114
|
-
PopoverAnchor.displayName = ANCHOR_NAME
|
|
115
|
-
|
|
116
94
|
/* -------------------------------------------------------------------------------------------------
|
|
117
95
|
* PopoverTrigger
|
|
118
96
|
* -----------------------------------------------------------------------------------------------*/
|
|
119
97
|
|
|
120
|
-
const TRIGGER_NAME = 'PopoverTrigger'
|
|
121
|
-
|
|
122
|
-
type PopoverTriggerElement = HTMLElement | View
|
|
123
98
|
export type PopoverTriggerProps = YStackProps
|
|
124
99
|
|
|
125
|
-
export const PopoverTrigger = React.forwardRef<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const { __scopePopover, ...triggerProps } = props
|
|
130
|
-
const context = usePopoverInternalContext(TRIGGER_NAME, __scopePopover)
|
|
131
|
-
const popperScope = usePopoverScope(__scopePopover)
|
|
132
|
-
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef)
|
|
133
|
-
|
|
134
|
-
const trigger = (
|
|
135
|
-
<YStack
|
|
136
|
-
aria-haspopup="dialog"
|
|
137
|
-
aria-expanded={context.open}
|
|
138
|
-
// TODO not matching
|
|
139
|
-
// aria-controls={context.contentId}
|
|
140
|
-
data-state={getState(context.open)}
|
|
141
|
-
{...triggerProps}
|
|
142
|
-
ref={composedTriggerRef}
|
|
143
|
-
onPress={composeEventHandlers(props.onPress as any, context.onOpenToggle)}
|
|
144
|
-
/>
|
|
145
|
-
)
|
|
100
|
+
export const PopoverTrigger = React.forwardRef<TamaguiElement, PopoverTriggerProps>(
|
|
101
|
+
function PopoverTrigger(props: PopoverTriggerProps, forwardedRef) {
|
|
102
|
+
const context = usePopoverContext()
|
|
103
|
+
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef)
|
|
146
104
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
105
|
+
const trigger = (
|
|
106
|
+
<YStack
|
|
107
|
+
aria-haspopup="dialog"
|
|
108
|
+
aria-expanded={context.open}
|
|
109
|
+
// TODO not matching
|
|
110
|
+
// aria-controls={context.contentId}
|
|
111
|
+
data-state={getState(context.open)}
|
|
112
|
+
{...props}
|
|
113
|
+
ref={composedTriggerRef}
|
|
114
|
+
onPress={composeEventHandlers(props.onPress as any, context.onOpenToggle)}
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
155
117
|
|
|
156
|
-
|
|
118
|
+
return context.hasCustomAnchor ? (
|
|
119
|
+
trigger
|
|
120
|
+
) : (
|
|
121
|
+
<PopperAnchor asChild>{trigger}</PopperAnchor>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
)
|
|
157
125
|
|
|
158
126
|
/* -------------------------------------------------------------------------------------------------
|
|
159
127
|
* PopoverContent
|
|
160
128
|
* -----------------------------------------------------------------------------------------------*/
|
|
161
129
|
|
|
162
|
-
const CONTENT_NAME = 'PopoverContent'
|
|
163
|
-
|
|
164
130
|
export type PopoverContentProps = PopoverContentTypeProps
|
|
165
131
|
|
|
166
132
|
type PopoverContentTypeElement = PopoverContentImplElement
|
|
@@ -175,7 +141,7 @@ export interface PopoverContentTypeProps
|
|
|
175
141
|
|
|
176
142
|
export const PopoverContent = PopperContentFrame.extractable(
|
|
177
143
|
React.forwardRef<PopoverContentTypeElement, PopoverContentTypeProps>(
|
|
178
|
-
function PopoverContent(props:
|
|
144
|
+
function PopoverContent(props: PopoverContentTypeProps, forwardedRef) {
|
|
179
145
|
const {
|
|
180
146
|
allowPinchZoom,
|
|
181
147
|
trapFocus,
|
|
@@ -183,7 +149,7 @@ export const PopoverContent = PopperContentFrame.extractable(
|
|
|
183
149
|
zIndex,
|
|
184
150
|
...contentImplProps
|
|
185
151
|
} = props
|
|
186
|
-
const context =
|
|
152
|
+
const context = usePopoverContext()
|
|
187
153
|
const contentRef = React.useRef<any>(null)
|
|
188
154
|
const composedRefs = useComposedRefs(forwardedRef, contentRef)
|
|
189
155
|
const isRightClickOutsideRef = React.useRef(false)
|
|
@@ -234,25 +200,26 @@ export const PopoverContent = PopperContentFrame.extractable(
|
|
|
234
200
|
)
|
|
235
201
|
)
|
|
236
202
|
|
|
237
|
-
function
|
|
203
|
+
function PopoverRepropagateContext(props: { children: any }) {
|
|
204
|
+
const context = usePopoverContext()
|
|
205
|
+
const popperContext = usePopperContext()
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<PopperContext.Provider {...popperContext}>
|
|
209
|
+
<PopoverContext.Provider {...context}>{props.children}</PopoverContext.Provider>
|
|
210
|
+
</PopperContext.Provider>
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function PopoverContentPortal(props: PopoverContentTypeProps) {
|
|
238
215
|
const themeName = useThemeName()
|
|
239
|
-
const context =
|
|
216
|
+
const context = usePopoverContext()
|
|
240
217
|
|
|
241
218
|
// on android we have to re-pass context
|
|
242
219
|
let contents = props.children
|
|
243
220
|
|
|
244
221
|
if (Platform.OS === 'android') {
|
|
245
|
-
|
|
246
|
-
const popperContext = usePopperContext(CONTENT_NAME, context.popperScope)
|
|
247
|
-
|
|
248
|
-
contents = (
|
|
249
|
-
<PopperProvider {...popperContext} scope={context.popperScope}>
|
|
250
|
-
<PopoverProviderInternal scope={props.__scopePopover} {...context}>
|
|
251
|
-
{/* does this need to be props.__scopePopper? */}
|
|
252
|
-
{props.children}
|
|
253
|
-
</PopoverProviderInternal>
|
|
254
|
-
</PopperProvider>
|
|
255
|
-
)
|
|
222
|
+
contents = <PopoverRepropagateContext>{props.children}</PopoverRepropagateContext>
|
|
256
223
|
}
|
|
257
224
|
|
|
258
225
|
const zIndex = props.zIndex ?? 150_000
|
|
@@ -304,9 +271,8 @@ export interface PopoverContentImplProps
|
|
|
304
271
|
const PopoverContentImpl = React.forwardRef<
|
|
305
272
|
PopoverContentImplElement,
|
|
306
273
|
PopoverContentImplProps
|
|
307
|
-
>((props:
|
|
274
|
+
>((props: PopoverContentImplProps, forwardedRef) => {
|
|
308
275
|
const {
|
|
309
|
-
__scopePopover,
|
|
310
276
|
trapFocus,
|
|
311
277
|
onOpenAutoFocus,
|
|
312
278
|
onCloseAutoFocus,
|
|
@@ -319,12 +285,12 @@ const PopoverContentImpl = React.forwardRef<
|
|
|
319
285
|
disableRemoveScroll,
|
|
320
286
|
...contentProps
|
|
321
287
|
} = props
|
|
322
|
-
const
|
|
323
|
-
const context = usePopoverInternalContext(CONTENT_NAME, popperScope.__scopePopover)
|
|
288
|
+
const context = usePopoverContext()
|
|
324
289
|
const [isFullyHidden, setIsFullyHidden] = React.useState(!context.open)
|
|
325
290
|
|
|
326
291
|
if (context.breakpointActive) {
|
|
327
292
|
// unwrap the PopoverScrollView if used, as it will use the SheetScrollView if that exists
|
|
293
|
+
// TODO this should be disabled through context
|
|
328
294
|
const childrenWithoutScrollView = React.Children.toArray(children).map((child) => {
|
|
329
295
|
if (React.isValidElement(child)) {
|
|
330
296
|
if (child.type === PopoverScrollView) {
|
|
@@ -336,7 +302,7 @@ const PopoverContentImpl = React.forwardRef<
|
|
|
336
302
|
|
|
337
303
|
// doesn't show as popover yet on native, must use as sheet
|
|
338
304
|
return (
|
|
339
|
-
<PortalItem hostName={`${context.
|
|
305
|
+
<PortalItem hostName={`${context.id}PopoverContents`}>
|
|
340
306
|
{childrenWithoutScrollView}
|
|
341
307
|
</PortalItem>
|
|
342
308
|
)
|
|
@@ -375,7 +341,6 @@ const PopoverContentImpl = React.forwardRef<
|
|
|
375
341
|
id={context.contentId}
|
|
376
342
|
pointerEvents="auto"
|
|
377
343
|
ref={forwardedRef}
|
|
378
|
-
{...popperScope}
|
|
379
344
|
{...contentProps}
|
|
380
345
|
>
|
|
381
346
|
<RemoveScroll
|
|
@@ -410,19 +375,16 @@ const PopoverContentImpl = React.forwardRef<
|
|
|
410
375
|
* PopoverClose
|
|
411
376
|
* -----------------------------------------------------------------------------------------------*/
|
|
412
377
|
|
|
413
|
-
const CLOSE_NAME = 'PopoverClose'
|
|
414
|
-
|
|
415
|
-
type PopoverCloseElement = HTMLElement | View
|
|
416
378
|
export type PopoverCloseProps = YStackProps
|
|
417
379
|
|
|
418
|
-
export const PopoverClose = React.forwardRef<
|
|
419
|
-
(props:
|
|
420
|
-
const
|
|
421
|
-
const context = usePopoverInternalContext(CLOSE_NAME, __scopePopover)
|
|
380
|
+
export const PopoverClose = React.forwardRef<TamaguiElement, PopoverCloseProps>(
|
|
381
|
+
function PopoverClose(props: PopoverCloseProps, forwardedRef) {
|
|
382
|
+
const context = usePopoverContext()
|
|
422
383
|
return (
|
|
423
384
|
<YStack
|
|
424
|
-
{...
|
|
385
|
+
{...props}
|
|
425
386
|
ref={forwardedRef}
|
|
387
|
+
componentName="PopoverClose"
|
|
426
388
|
onPress={composeEventHandlers(props.onPress as any, () =>
|
|
427
389
|
context.onOpenChange(false)
|
|
428
390
|
)}
|
|
@@ -431,26 +393,18 @@ export const PopoverClose = React.forwardRef<PopoverCloseElement, PopoverClosePr
|
|
|
431
393
|
}
|
|
432
394
|
)
|
|
433
395
|
|
|
434
|
-
PopoverClose.displayName = CLOSE_NAME
|
|
435
|
-
|
|
436
396
|
/* -------------------------------------------------------------------------------------------------
|
|
437
397
|
* PopoverArrow
|
|
438
398
|
* -----------------------------------------------------------------------------------------------*/
|
|
439
399
|
|
|
440
|
-
const ARROW_NAME = 'PopoverArrow'
|
|
441
|
-
|
|
442
400
|
export type PopoverArrowProps = PopperArrowProps
|
|
443
401
|
|
|
444
|
-
export const PopoverArrow =
|
|
445
|
-
(props, forwardedRef)
|
|
446
|
-
|
|
447
|
-
const popperScope = usePopoverScope(__scopePopover)
|
|
448
|
-
return <PopperArrow {...popperScope} {...arrowProps} ref={forwardedRef} />
|
|
402
|
+
export const PopoverArrow = React.forwardRef<TamaguiElement, PopoverArrowProps>(
|
|
403
|
+
function PopoverArrow(props: PopoverArrowProps, forwardedRef) {
|
|
404
|
+
return <PopperArrow componentName="PopoverArrow" {...props} ref={forwardedRef} />
|
|
449
405
|
}
|
|
450
406
|
)
|
|
451
407
|
|
|
452
|
-
PopoverArrow.displayName = ARROW_NAME
|
|
453
|
-
|
|
454
408
|
/* -------------------------------------------------------------------------------------------------
|
|
455
409
|
* PopoverScrollView
|
|
456
410
|
* -----------------------------------------------------------------------------------------------*/
|
|
@@ -464,19 +418,10 @@ const PopoverScrollView = React.forwardRef<ScrollView, ScrollViewProps>((props,
|
|
|
464
418
|
* -----------------------------------------------------------------------------------------------*/
|
|
465
419
|
|
|
466
420
|
export const Popover = withStaticProperties(
|
|
467
|
-
function Popover(props:
|
|
468
|
-
const {
|
|
469
|
-
__scopePopover,
|
|
470
|
-
children,
|
|
471
|
-
open: openProp,
|
|
472
|
-
defaultOpen,
|
|
473
|
-
onOpenChange,
|
|
474
|
-
...restProps
|
|
475
|
-
} = props
|
|
476
|
-
|
|
477
|
-
const internalId = React.useId()
|
|
478
|
-
const id = __scopePopover ? Object.keys(__scopePopover)[0] : internalId
|
|
421
|
+
function Popover(props: PopoverProps) {
|
|
422
|
+
const { children, open: openProp, defaultOpen, onOpenChange, ...restProps } = props
|
|
479
423
|
|
|
424
|
+
const id = React.useId()
|
|
480
425
|
const { when, AdaptProvider } = useAdaptParent({
|
|
481
426
|
Contents: React.useCallback(() => {
|
|
482
427
|
return <PortalHost name={`${id}PopoverContents`} />
|
|
@@ -484,7 +429,6 @@ export const Popover = withStaticProperties(
|
|
|
484
429
|
})
|
|
485
430
|
|
|
486
431
|
const sheetBreakpoint = when
|
|
487
|
-
const popperScope = usePopoverScope(__scopePopover)
|
|
488
432
|
const triggerRef = React.useRef<TamaguiElement>(null)
|
|
489
433
|
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false)
|
|
490
434
|
const [open, setOpen] = useControllableState({
|
|
@@ -499,9 +443,7 @@ export const Popover = withStaticProperties(
|
|
|
499
443
|
const floatingContext = useFloatingContext({ open, setOpen, breakpointActive }) as any
|
|
500
444
|
|
|
501
445
|
const popoverContext = {
|
|
502
|
-
|
|
503
|
-
scopeKey: id,
|
|
504
|
-
popperScope: popperScope.__scopePopper,
|
|
446
|
+
id,
|
|
505
447
|
sheetBreakpoint,
|
|
506
448
|
contentId: React.useId(),
|
|
507
449
|
triggerRef,
|
|
@@ -527,12 +469,12 @@ export const Popover = withStaticProperties(
|
|
|
527
469
|
// }
|
|
528
470
|
|
|
529
471
|
const contents = (
|
|
530
|
-
<Popper
|
|
531
|
-
<
|
|
532
|
-
<PopoverSheetController onOpenChange={setOpen}
|
|
472
|
+
<Popper stayInFrame {...restProps}>
|
|
473
|
+
<PopoverContext.Provider {...popoverContext}>
|
|
474
|
+
<PopoverSheetController onOpenChange={setOpen}>
|
|
533
475
|
{children}
|
|
534
476
|
</PopoverSheetController>
|
|
535
|
-
</
|
|
477
|
+
</PopoverContext.Provider>
|
|
536
478
|
</Popper>
|
|
537
479
|
)
|
|
538
480
|
|
|
@@ -566,19 +508,15 @@ function getState(open: boolean) {
|
|
|
566
508
|
return open ? 'open' : 'closed'
|
|
567
509
|
}
|
|
568
510
|
|
|
569
|
-
const PopoverSheetController = (
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
) => {
|
|
575
|
-
const context = usePopoverInternalContext(
|
|
576
|
-
'PopoverSheetController',
|
|
577
|
-
props.__scopePopover
|
|
578
|
-
)
|
|
511
|
+
const PopoverSheetController = (props: {
|
|
512
|
+
children: React.ReactNode
|
|
513
|
+
onOpenChange: React.Dispatch<React.SetStateAction<boolean>>
|
|
514
|
+
}) => {
|
|
515
|
+
const context = usePopoverContext()
|
|
579
516
|
const showSheet = useShowPopoverSheet(context)
|
|
580
517
|
const breakpointActive = context.breakpointActive
|
|
581
518
|
const getShowSheet = useGet(showSheet)
|
|
519
|
+
|
|
582
520
|
return (
|
|
583
521
|
<SheetController
|
|
584
522
|
onOpenChange={(val) => {
|