@tamagui/popover 1.1.8 → 1.1.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 +94 -124
- package/dist/cjs/Popover.js.map +1 -1
- package/dist/esm/Popover.js +90 -124
- package/dist/esm/Popover.js.map +1 -1
- package/dist/jsx/Popover.js +81 -32
- package/dist/jsx/Popover.js.map +1 -1
- package/package.json +17 -17
- package/dist/cjs/floating.js +0 -37
- package/dist/cjs/floating.js.map +0 -7
- package/dist/cjs/floating.native.js +0 -59
- package/dist/cjs/floating.native.js.map +0 -7
- package/dist/esm/floating.js +0 -15
- package/dist/esm/floating.js.map +0 -7
- package/dist/esm/floating.native.js +0 -31
- package/dist/esm/floating.native.js.map +0 -7
- package/dist/jsx/floating.js +0 -15
- package/dist/jsx/floating.js.map +0 -7
- package/dist/jsx/floating.native.js +0 -31
- package/dist/jsx/floating.native.js.map +0 -7
- package/types/floating.d.ts +0 -2
- package/types/floating.native.d.ts +0 -15
- package/types/useFloating.d.ts +0 -23
package/dist/esm/Popover.js
CHANGED
|
@@ -64,11 +64,7 @@ const PopoverAnchor = React.forwardRef(
|
|
|
64
64
|
onCustomAnchorAdd();
|
|
65
65
|
return () => onCustomAnchorRemove();
|
|
66
66
|
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
|
|
67
|
-
return /* @__PURE__ */ jsx(PopperAnchor, {
|
|
68
|
-
...popperScope,
|
|
69
|
-
...anchorProps,
|
|
70
|
-
ref: forwardedRef
|
|
71
|
-
});
|
|
67
|
+
return /* @__PURE__ */ jsx(PopperAnchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
|
|
72
68
|
}
|
|
73
69
|
);
|
|
74
70
|
PopoverAnchor.displayName = ANCHOR_NAME;
|
|
@@ -78,19 +74,18 @@ const PopoverTrigger = React.forwardRef((props, forwardedRef) => {
|
|
|
78
74
|
const context = usePopoverInternalContext(TRIGGER_NAME, __scopePopover);
|
|
79
75
|
const popperScope = usePopoverScope(__scopePopover);
|
|
80
76
|
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
81
|
-
const trigger = /* @__PURE__ */ jsx(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
77
|
+
const trigger = /* @__PURE__ */ jsx(
|
|
78
|
+
YStack,
|
|
79
|
+
{
|
|
80
|
+
"aria-haspopup": "dialog",
|
|
81
|
+
"aria-expanded": context.open,
|
|
82
|
+
"data-state": getState(context.open),
|
|
83
|
+
...triggerProps,
|
|
84
|
+
ref: composedTriggerRef,
|
|
85
|
+
onPress: composeEventHandlers(props.onPress, context.onOpenToggle)
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ jsx(PopperAnchor, { asChild: true, ...popperScope, children: trigger });
|
|
94
89
|
});
|
|
95
90
|
PopoverTrigger.displayName = TRIGGER_NAME;
|
|
96
91
|
const CONTENT_NAME = "PopoverContent";
|
|
@@ -113,9 +108,9 @@ const PopoverContent = React.forwardRef((props, forwardedRef) => {
|
|
|
113
108
|
if (content)
|
|
114
109
|
return hideOthers(content);
|
|
115
110
|
}, [context.open]);
|
|
116
|
-
return /* @__PURE__ */ jsx(PopoverContentPortal, {
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
return /* @__PURE__ */ jsx(PopoverContentPortal, { zIndex, children: /* @__PURE__ */ jsx(
|
|
112
|
+
PopoverContentImpl,
|
|
113
|
+
{
|
|
119
114
|
...contentModalProps,
|
|
120
115
|
disableRemoveScroll,
|
|
121
116
|
ref: composedRefs,
|
|
@@ -142,8 +137,8 @@ const PopoverContent = React.forwardRef((props, forwardedRef) => {
|
|
|
142
137
|
(event) => event.preventDefault(),
|
|
143
138
|
{ checkDefaultPrevented: false }
|
|
144
139
|
)
|
|
145
|
-
}
|
|
146
|
-
});
|
|
140
|
+
}
|
|
141
|
+
) });
|
|
147
142
|
});
|
|
148
143
|
function PopoverContentPortal(props) {
|
|
149
144
|
const themeName = useThemeName();
|
|
@@ -151,34 +146,19 @@ function PopoverContentPortal(props) {
|
|
|
151
146
|
let contents = props.children;
|
|
152
147
|
if (Platform.OS === "android") {
|
|
153
148
|
const popperContext = usePopperContext(CONTENT_NAME, context.popperScope);
|
|
154
|
-
contents = /* @__PURE__ */ jsx(PopperProvider, {
|
|
155
|
-
...popperContext,
|
|
156
|
-
scope: context.popperScope,
|
|
157
|
-
children: /* @__PURE__ */ jsx(PopoverProviderInternal, {
|
|
158
|
-
scope: props.__scopePopover,
|
|
159
|
-
...context,
|
|
160
|
-
children: props.children
|
|
161
|
-
})
|
|
162
|
-
});
|
|
149
|
+
contents = /* @__PURE__ */ jsx(PopperProvider, { ...popperContext, scope: context.popperScope, children: /* @__PURE__ */ jsx(PopoverProviderInternal, { scope: props.__scopePopover, ...context, children: props.children }) });
|
|
163
150
|
}
|
|
164
151
|
const zIndex = props.zIndex ?? 1e3;
|
|
165
|
-
return /* @__PURE__ */ jsx(Portal, {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
/* @__PURE__ */ jsx(Stack, {
|
|
176
|
-
zIndex: zIndex + 1,
|
|
177
|
-
children: contents
|
|
178
|
-
})
|
|
179
|
-
]
|
|
180
|
-
})
|
|
181
|
-
});
|
|
152
|
+
return /* @__PURE__ */ jsx(Portal, { zIndex, children: /* @__PURE__ */ jsxs(Theme, { forceClassName: true, name: themeName, children: [
|
|
153
|
+
!!context.open && !context.breakpointActive && /* @__PURE__ */ jsx(
|
|
154
|
+
YStack,
|
|
155
|
+
{
|
|
156
|
+
fullscreen: true,
|
|
157
|
+
onPress: composeEventHandlers(props.onPress, context.onOpenToggle)
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ jsx(Stack, { zIndex: zIndex + 1, children: contents })
|
|
161
|
+
] }) });
|
|
182
162
|
}
|
|
183
163
|
const PopoverContentImpl = React.forwardRef((props, forwardedRef) => {
|
|
184
164
|
const {
|
|
@@ -206,53 +186,58 @@ const PopoverContentImpl = React.forwardRef((props, forwardedRef) => {
|
|
|
206
186
|
}
|
|
207
187
|
return child;
|
|
208
188
|
});
|
|
209
|
-
return /* @__PURE__ */ jsx(PortalItem, {
|
|
210
|
-
hostName: `${context.scopeKey}SheetContents`,
|
|
211
|
-
children: childrenWithoutScrollView
|
|
212
|
-
});
|
|
189
|
+
return /* @__PURE__ */ jsx(PortalItem, { hostName: `${context.scopeKey}SheetContents`, children: childrenWithoutScrollView });
|
|
213
190
|
}
|
|
214
|
-
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
215
|
-
|
|
191
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: !!context.open && /* @__PURE__ */ jsx(
|
|
192
|
+
PopperContent,
|
|
193
|
+
{
|
|
216
194
|
"data-state": getState(context.open),
|
|
217
195
|
id: context.contentId,
|
|
218
196
|
pointerEvents: "auto",
|
|
219
197
|
ref: forwardedRef,
|
|
220
198
|
...popperScope,
|
|
221
199
|
...contentProps,
|
|
222
|
-
children: /* @__PURE__ */ jsx(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
200
|
+
children: /* @__PURE__ */ jsx(
|
|
201
|
+
RemoveScroll,
|
|
202
|
+
{
|
|
203
|
+
enabled: disableRemoveScroll ? false : context.open,
|
|
204
|
+
allowPinchZoom: true,
|
|
205
|
+
removeScrollBar: false,
|
|
206
|
+
style: {
|
|
207
|
+
display: "contents"
|
|
208
|
+
},
|
|
209
|
+
children: trapFocus === false ? children : /* @__PURE__ */ jsx(
|
|
210
|
+
FocusScope,
|
|
211
|
+
{
|
|
212
|
+
loop: true,
|
|
213
|
+
trapped: trapFocus ?? context.open,
|
|
214
|
+
onMountAutoFocus: onOpenAutoFocus,
|
|
215
|
+
onUnmountAutoFocus: onCloseAutoFocus,
|
|
216
|
+
children: isWeb ? /* @__PURE__ */ jsx("div", { style: { display: "contents" }, children }) : children
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
)
|
|
221
|
+
},
|
|
222
|
+
context.contentId
|
|
223
|
+
) });
|
|
242
224
|
});
|
|
243
225
|
const CLOSE_NAME = "PopoverClose";
|
|
244
226
|
const PopoverClose = React.forwardRef(
|
|
245
227
|
(props, forwardedRef) => {
|
|
246
228
|
const { __scopePopover, ...closeProps } = props;
|
|
247
229
|
const context = usePopoverInternalContext(CLOSE_NAME, __scopePopover);
|
|
248
|
-
return /* @__PURE__ */ jsx(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
230
|
+
return /* @__PURE__ */ jsx(
|
|
231
|
+
YStack,
|
|
232
|
+
{
|
|
233
|
+
...closeProps,
|
|
234
|
+
ref: forwardedRef,
|
|
235
|
+
onPress: composeEventHandlers(
|
|
236
|
+
props.onPress,
|
|
237
|
+
() => context.onOpenChange(false)
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
);
|
|
256
241
|
}
|
|
257
242
|
);
|
|
258
243
|
PopoverClose.displayName = CLOSE_NAME;
|
|
@@ -261,19 +246,12 @@ const PopoverArrow = React.forwardRef(
|
|
|
261
246
|
(props, forwardedRef) => {
|
|
262
247
|
const { __scopePopover, ...arrowProps } = props;
|
|
263
248
|
const popperScope = usePopoverScope(__scopePopover);
|
|
264
|
-
return /* @__PURE__ */ jsx(PopperArrow, {
|
|
265
|
-
...popperScope,
|
|
266
|
-
...arrowProps,
|
|
267
|
-
ref: forwardedRef
|
|
268
|
-
});
|
|
249
|
+
return /* @__PURE__ */ jsx(PopperArrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
269
250
|
}
|
|
270
251
|
);
|
|
271
252
|
PopoverArrow.displayName = ARROW_NAME;
|
|
272
253
|
const PopoverScrollView = React.forwardRef((props, ref) => {
|
|
273
|
-
return /* @__PURE__ */ jsx(ScrollView, {
|
|
274
|
-
ref,
|
|
275
|
-
...props
|
|
276
|
-
});
|
|
254
|
+
return /* @__PURE__ */ jsx(ScrollView, { ref, ...props });
|
|
277
255
|
});
|
|
278
256
|
const Popover = withStaticProperties(
|
|
279
257
|
(props) => {
|
|
@@ -289,9 +267,7 @@ const Popover = withStaticProperties(
|
|
|
289
267
|
const id = __scopePopover ? Object.keys(__scopePopover)[0] : internalId;
|
|
290
268
|
const { when, AdaptProvider } = useAdaptParent({
|
|
291
269
|
Contents: React.useCallback(() => {
|
|
292
|
-
return /* @__PURE__ */ jsx(PortalHost, {
|
|
293
|
-
name: `${id}SheetContents`
|
|
294
|
-
});
|
|
270
|
+
return /* @__PURE__ */ jsx(PortalHost, { name: `${id}SheetContents` });
|
|
295
271
|
}, [])
|
|
296
272
|
});
|
|
297
273
|
const sheetBreakpoint = when;
|
|
@@ -313,6 +289,10 @@ const Popover = withStaticProperties(
|
|
|
313
289
|
onOpenChange: setOpen
|
|
314
290
|
});
|
|
315
291
|
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
292
|
+
// useFocus(floating.context, {
|
|
293
|
+
// enabled: !breakpointActive,
|
|
294
|
+
// keyboardOnly: true,
|
|
295
|
+
// }),
|
|
316
296
|
useRole(floating.context, { role: "dialog" }),
|
|
317
297
|
useDismiss(floating.context, {
|
|
318
298
|
enabled: !breakpointActive
|
|
@@ -346,25 +326,8 @@ const Popover = withStaticProperties(
|
|
|
346
326
|
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
|
|
347
327
|
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), [])
|
|
348
328
|
};
|
|
349
|
-
const contents = /* @__PURE__ */ jsx(Popper, {
|
|
350
|
-
|
|
351
|
-
stayInFrame: true,
|
|
352
|
-
...restProps,
|
|
353
|
-
children: /* @__PURE__ */ jsx(PopoverProviderInternal, {
|
|
354
|
-
...popoverContext,
|
|
355
|
-
children: /* @__PURE__ */ jsx(PopoverSheetController, {
|
|
356
|
-
onOpenChange: setOpen,
|
|
357
|
-
__scopePopover,
|
|
358
|
-
children
|
|
359
|
-
})
|
|
360
|
-
})
|
|
361
|
-
});
|
|
362
|
-
return /* @__PURE__ */ jsx(AdaptProvider, {
|
|
363
|
-
children: isWeb ? /* @__PURE__ */ jsx(FloatingOverrideContext.Provider, {
|
|
364
|
-
value: useFloatingContext,
|
|
365
|
-
children: contents
|
|
366
|
-
}) : contents
|
|
367
|
-
});
|
|
329
|
+
const contents = /* @__PURE__ */ jsx(Popper, { ...popperScope, stayInFrame: true, ...restProps, children: /* @__PURE__ */ jsx(PopoverProviderInternal, { ...popoverContext, children: /* @__PURE__ */ jsx(PopoverSheetController, { onOpenChange: setOpen, __scopePopover, children }) }) });
|
|
330
|
+
return /* @__PURE__ */ jsx(AdaptProvider, { children: isWeb ? /* @__PURE__ */ jsx(FloatingOverrideContext.Provider, { value: useFloatingContext, children: contents }) : contents });
|
|
368
331
|
},
|
|
369
332
|
{
|
|
370
333
|
Anchor: PopoverAnchor,
|
|
@@ -389,16 +352,19 @@ const PopoverSheetController = (props) => {
|
|
|
389
352
|
const showSheet = useShowPopoverSheet(context);
|
|
390
353
|
const breakpointActive = context.breakpointActive;
|
|
391
354
|
const getShowSheet = useGet(showSheet);
|
|
392
|
-
return /* @__PURE__ */ jsx(
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
355
|
+
return /* @__PURE__ */ jsx(
|
|
356
|
+
SheetController,
|
|
357
|
+
{
|
|
358
|
+
onOpenChange: (val) => {
|
|
359
|
+
if (getShowSheet()) {
|
|
360
|
+
props.onOpenChange(val);
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
open: context.open,
|
|
364
|
+
hidden: breakpointActive === false,
|
|
365
|
+
children: props.children
|
|
366
|
+
}
|
|
367
|
+
);
|
|
402
368
|
};
|
|
403
369
|
const useSheetBreakpointActive = (breakpoint) => {
|
|
404
370
|
const media = useMedia();
|
package/dist/esm/Popover.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Popover.tsx"],
|
|
4
4
|
"sourcesContent": ["// adapted from radix-ui popover\n\nimport '@tamagui/polyfill-dev'\n\nimport type { UseFloatingProps } from '@floating-ui/react-dom-interactions'\nimport {\n useDismiss,\n useFloating,\n useInteractions,\n useRole,\n} from '@floating-ui/react-dom-interactions'\nimport { Adapt, useAdaptParent } from '@tamagui/adapt'\nimport { AnimatePresence } from '@tamagui/animate-presence'\nimport { hideOthers } from '@tamagui/aria-hidden'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GestureReponderEvent,\n MediaQueryKey,\n SizeTokens,\n Stack,\n TamaguiElement,\n Theme,\n composeEventHandlers,\n isWeb,\n useEvent,\n useGet,\n useId,\n useMedia,\n useThemeName,\n withStaticProperties,\n} from '@tamagui/core'\nimport type { Scope } from '@tamagui/create-context'\nimport { createContextScope } from '@tamagui/create-context'\nimport { DismissableProps } from '@tamagui/dismissable'\nimport { FloatingOverrideContext } from '@tamagui/floating'\nimport { FocusScope, FocusScopeProps } from '@tamagui/focus-scope'\nimport {\n Popper,\n PopperAnchor,\n PopperArrow,\n PopperArrowProps,\n PopperContent,\n PopperContentProps,\n PopperProps,\n PopperProvider,\n createPopperScope,\n usePopperContext,\n} from '@tamagui/popper'\nimport { Portal, PortalHost, PortalItem } from '@tamagui/portal'\nimport { RemoveScroll, RemoveScrollProps } from '@tamagui/remove-scroll'\nimport { ControlledSheet, SheetController } from '@tamagui/sheet'\nimport { SizableStack, XStack, YStack, YStackProps, ZStack } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\nimport { useEffect } from 'react'\nimport {\n GestureResponderEvent,\n Platform,\n ScrollView,\n ScrollViewProps,\n View,\n} from 'react-native'\n\nconst POPOVER_NAME = 'Popover'\n\ntype ScopedProps<P> = P & { __scopePopover?: Scope }\n\nexport type PopoverProps = PopperProps & {\n open?: boolean\n defaultOpen?: boolean\n onOpenChange?: (open: boolean) => void\n}\n\ntype PopoverContextValue = {\n triggerRef: React.RefObject<any>\n contentId?: string\n open: boolean\n onOpenChange(open: boolean): void\n onOpenToggle(): void\n hasCustomAnchor: boolean\n onCustomAnchorAdd(): void\n onCustomAnchorRemove(): void\n size?: SizeTokens\n sheetBreakpoint: any\n scopeKey: string\n popperScope: any\n breakpointActive?: boolean\n}\n\nconst [createPopoverContext, createPopoverScopeInternal] = createContextScope(\n POPOVER_NAME,\n [createPopperScope]\n)\nexport const usePopoverScope = createPopperScope()\nexport const createPopoverScope = createPopoverScopeInternal\n\nconst [PopoverProviderInternal, usePopoverInternalContext] =\n createPopoverContext<PopoverContextValue>(POPOVER_NAME)\n\nexport const __PopoverProviderInternal = PopoverProviderInternal\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverAnchor\n * -----------------------------------------------------------------------------------------------*/\n\nconst ANCHOR_NAME = 'PopoverAnchor'\n\ntype PopoverAnchorElement = HTMLElement | View\nexport type PopoverAnchorProps = YStackProps\n\nexport const PopoverAnchor = React.forwardRef<PopoverAnchorElement, PopoverAnchorProps>(\n (props: ScopedProps<PopoverAnchorProps>, forwardedRef) => {\n const { __scopePopover, ...anchorProps } = props\n const context = usePopoverInternalContext(ANCHOR_NAME, __scopePopover)\n const popperScope = usePopoverScope(__scopePopover)\n const { onCustomAnchorAdd, onCustomAnchorRemove } = context\n\n React.useEffect(() => {\n onCustomAnchorAdd()\n return () => onCustomAnchorRemove()\n }, [onCustomAnchorAdd, onCustomAnchorRemove])\n\n return <PopperAnchor {...popperScope} {...anchorProps} ref={forwardedRef} />\n }\n)\n\nPopoverAnchor.displayName = ANCHOR_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverTrigger\n * -----------------------------------------------------------------------------------------------*/\n\nconst TRIGGER_NAME = 'PopoverTrigger'\n\ntype PopoverTriggerElement = HTMLElement | View\nexport type PopoverTriggerProps = YStackProps\n\nexport const PopoverTrigger = React.forwardRef<\n PopoverTriggerElement,\n PopoverTriggerProps\n>((props: ScopedProps<PopoverTriggerProps>, forwardedRef) => {\n const { __scopePopover, ...triggerProps } = props\n const context = usePopoverInternalContext(TRIGGER_NAME, __scopePopover)\n const popperScope = usePopoverScope(__scopePopover)\n const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef)\n\n const trigger = (\n <YStack\n aria-haspopup=\"dialog\"\n aria-expanded={context.open}\n // TODO not matching\n // aria-controls={context.contentId}\n data-state={getState(context.open)}\n {...triggerProps}\n ref={composedTriggerRef}\n onPress={composeEventHandlers(props.onPress as any, context.onOpenToggle)}\n />\n )\n\n return context.hasCustomAnchor ? (\n trigger\n ) : (\n <PopperAnchor asChild {...popperScope}>\n {trigger}\n </PopperAnchor>\n )\n})\n\nPopoverTrigger.displayName = TRIGGER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverContent\n * -----------------------------------------------------------------------------------------------*/\n\nconst CONTENT_NAME = 'PopoverContent'\n\nexport type PopoverContentProps = PopoverContentTypeProps\n\ntype PopoverContentTypeElement = PopoverContentImplElement\n\nexport interface PopoverContentTypeProps\n extends Omit<PopoverContentImplProps, 'disableOutsidePointerEvents'> {\n /**\n * @see https://github.com/theKashey/react-remove-scroll#usage\n */\n allowPinchZoom?: RemoveScrollProps['allowPinchZoom']\n}\n\nexport const PopoverContent = React.forwardRef<\n PopoverContentTypeElement,\n PopoverContentTypeProps\n>((props: ScopedProps<PopoverContentTypeProps>, forwardedRef) => {\n const {\n allowPinchZoom,\n trapFocus,\n disableRemoveScroll = true,\n zIndex,\n ...contentModalProps\n } = props\n const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover)\n const contentRef = React.useRef<any>(null)\n const composedRefs = useComposedRefs(forwardedRef, contentRef)\n const isRightClickOutsideRef = React.useRef(false)\n\n // aria-hide everything except the content (better supported equivalent to setting aria-modal)\n React.useEffect(() => {\n if (!context.open) return\n const content = contentRef.current\n if (content) return hideOthers(content)\n }, [context.open])\n\n return (\n <PopoverContentPortal zIndex={zIndex}>\n <PopoverContentImpl\n {...contentModalProps}\n disableRemoveScroll={disableRemoveScroll}\n ref={composedRefs}\n // we make sure we're not trapping once it's been closed\n // (closed !== unmounted when animating out)\n trapFocus={trapFocus ?? context.open}\n disableOutsidePointerEvents\n onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {\n event.preventDefault()\n if (!isRightClickOutsideRef.current) context.triggerRef.current?.focus()\n })}\n onPointerDownOutside={composeEventHandlers(\n props.onPointerDownOutside,\n (event) => {\n const originalEvent = event.detail.originalEvent\n const ctrlLeftClick =\n originalEvent.button === 0 && originalEvent.ctrlKey === true\n const isRightClick = originalEvent.button === 2 || ctrlLeftClick\n isRightClickOutsideRef.current = isRightClick\n },\n { checkDefaultPrevented: false }\n )}\n // When focus is trapped, a `focusout` event may still happen.\n // We make sure we don't trigger our `onDismiss` in such case.\n onFocusOutside={composeEventHandlers(\n props.onFocusOutside,\n (event) => event.preventDefault(),\n { checkDefaultPrevented: false }\n )}\n />\n </PopoverContentPortal>\n )\n})\n\nfunction PopoverContentPortal(props: ScopedProps<PopoverContentTypeProps>) {\n const themeName = useThemeName()\n const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover)\n\n // on android we have to re-pass context\n let contents = props.children\n\n if (Platform.OS === 'android') {\n // ok conditional hooks by platform\n const popperContext = usePopperContext(CONTENT_NAME, context.popperScope)\n\n contents = (\n <PopperProvider {...popperContext} scope={context.popperScope}>\n <PopoverProviderInternal scope={props.__scopePopover} {...context}>\n {/* does this need to be props.__scopePopper? */}\n {props.children}\n </PopoverProviderInternal>\n </PopperProvider>\n )\n }\n\n const zIndex = props.zIndex ?? 1000\n\n // Portal the contents and add a transparent bg overlay to handle dismiss on native\n return (\n <Portal zIndex={zIndex}>\n <Theme forceClassName name={themeName}>\n {!!context.open && !context.breakpointActive && (\n <YStack\n fullscreen\n onPress={composeEventHandlers(props.onPress as any, context.onOpenToggle)}\n />\n )}\n <Stack zIndex={(zIndex as number) + 1}>{contents}</Stack>\n </Theme>\n </Portal>\n )\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype PopoverContentImplElement = React.ElementRef<typeof PopperContent>\n\nexport interface PopoverContentImplProps\n extends PopperContentProps,\n Omit<DismissableProps, 'onDismiss' | 'children'> {\n /**\n * Whether focus should be trapped within the `Popover`\n * (default: false)\n */\n trapFocus?: FocusScopeProps['trapped']\n\n /**\n * Event handler called when auto-focusing on open.\n * Can be prevented.\n */\n onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus']\n\n /**\n * Event handler called when auto-focusing on close.\n * Can be prevented.\n */\n onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus']\n\n disableRemoveScroll?: boolean\n}\n\nconst PopoverContentImpl = React.forwardRef<\n PopoverContentImplElement,\n PopoverContentImplProps\n>((props: ScopedProps<PopoverContentImplProps>, forwardedRef) => {\n const {\n __scopePopover,\n trapFocus,\n onOpenAutoFocus,\n onCloseAutoFocus,\n disableOutsidePointerEvents,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n children,\n disableRemoveScroll,\n ...contentProps\n } = props\n const popperScope = usePopoverScope(__scopePopover)\n const context = usePopoverInternalContext(CONTENT_NAME, popperScope.__scopePopover)\n\n if (context.breakpointActive) {\n // unwrap the PopoverScrollView if used, as it will use the SheetScrollView if that exists\n const childrenWithoutScrollView = React.Children.toArray(children).map((child) => {\n if (React.isValidElement(child)) {\n if (child.type === PopoverScrollView) {\n return child.props.children\n }\n }\n return child\n })\n\n // doesn't show as popover yet on native, must use as sheet\n return (\n <PortalItem hostName={`${context.scopeKey}SheetContents`}>\n {childrenWithoutScrollView}\n </PortalItem>\n )\n }\n\n // const handleDismiss = React.useCallback((event: GestureResponderEvent) =>{\n // context.onOpenChange(false);\n // }, [])\n // <Dismissable\n // disableOutsidePointerEvents={disableOutsidePointerEvents}\n // // onInteractOutside={onInteractOutside}\n // onEscapeKeyDown={onEscapeKeyDown}\n // // onPointerDownOutside={onPointerDownOutside}\n // // onFocusOutside={onFocusOutside}\n // onDismiss={handleDismiss}\n // >\n\n return (\n <AnimatePresence>\n {!!context.open && (\n <PopperContent\n key={context.contentId}\n data-state={getState(context.open)}\n id={context.contentId}\n pointerEvents=\"auto\"\n ref={forwardedRef}\n {...popperScope}\n {...contentProps}\n >\n <RemoveScroll\n enabled={disableRemoveScroll ? false : context.open}\n allowPinchZoom\n // causes lots of bugs on touch web on site\n removeScrollBar={false}\n style={{\n display: 'contents',\n }}\n >\n {trapFocus === false ? (\n children\n ) : (\n <FocusScope\n loop\n trapped={trapFocus ?? context.open}\n onMountAutoFocus={onOpenAutoFocus}\n onUnmountAutoFocus={onCloseAutoFocus}\n >\n {isWeb ? <div style={{ display: 'contents' }}>{children}</div> : children}\n </FocusScope>\n )}\n </RemoveScroll>\n </PopperContent>\n )}\n </AnimatePresence>\n )\n})\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverClose\n * -----------------------------------------------------------------------------------------------*/\n\nconst CLOSE_NAME = 'PopoverClose'\n\ntype PopoverCloseElement = HTMLElement | View\nexport type PopoverCloseProps = YStackProps\n\nexport const PopoverClose = React.forwardRef<PopoverCloseElement, PopoverCloseProps>(\n (props: ScopedProps<PopoverCloseProps>, forwardedRef) => {\n const { __scopePopover, ...closeProps } = props\n const context = usePopoverInternalContext(CLOSE_NAME, __scopePopover)\n return (\n <YStack\n {...closeProps}\n ref={forwardedRef}\n onPress={composeEventHandlers(props.onPress as any, () =>\n context.onOpenChange(false)\n )}\n />\n )\n }\n)\n\nPopoverClose.displayName = CLOSE_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverArrow\n * -----------------------------------------------------------------------------------------------*/\n\nconst ARROW_NAME = 'PopoverArrow'\n\ntype PopoverArrowElement = HTMLElement | View\nexport type PopoverArrowProps = PopperArrowProps\n\nexport const PopoverArrow = React.forwardRef<PopoverArrowElement, PopoverArrowProps>(\n (props: ScopedProps<PopoverArrowProps>, forwardedRef) => {\n const { __scopePopover, ...arrowProps } = props\n const popperScope = usePopoverScope(__scopePopover)\n return <PopperArrow {...popperScope} {...arrowProps} ref={forwardedRef} />\n }\n)\n\nPopoverArrow.displayName = ARROW_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * PopoverScrollView\n * -----------------------------------------------------------------------------------------------*/\n\nconst PopoverScrollView = React.forwardRef<ScrollView, ScrollViewProps>((props, ref) => {\n return <ScrollView ref={ref} {...props} />\n})\n\n/* -------------------------------------------------------------------------------------------------\n * Popover\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Popover = withStaticProperties(\n ((props: ScopedProps<PopoverProps>) => {\n const {\n __scopePopover,\n children,\n open: openProp,\n defaultOpen,\n onOpenChange,\n ...restProps\n } = props\n\n const internalId = useId()\n const id = __scopePopover ? Object.keys(__scopePopover)[0] : internalId\n\n const { when, AdaptProvider } = useAdaptParent({\n Contents: React.useCallback(() => {\n return <PortalHost name={`${id}SheetContents`} />\n }, []),\n })\n\n const sheetBreakpoint = when\n const popperScope = usePopoverScope(__scopePopover)\n const triggerRef = React.useRef<TamaguiElement>(null)\n const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false)\n const [open, setOpen] = useControllableState({\n prop: openProp,\n defaultProp: defaultOpen || false,\n onChange: onOpenChange,\n transition: true,\n })\n\n const breakpointActive = useSheetBreakpointActive(sheetBreakpoint)\n\n // Custom floating context to override the Popper on web\n const useFloatingContext = React.useCallback(\n (props: UseFloatingProps) => {\n const floating = useFloating({\n ...props,\n open,\n onOpenChange: setOpen,\n })\n const { getReferenceProps, getFloatingProps } = useInteractions([\n // useFocus(floating.context, {\n // enabled: !breakpointActive,\n // keyboardOnly: true,\n // }),\n useRole(floating.context, { role: 'dialog' }),\n useDismiss(floating.context, {\n enabled: !breakpointActive,\n }),\n ])\n return {\n ...floating,\n getReferenceProps,\n getFloatingProps,\n }\n },\n [breakpointActive, open, setOpen]\n )\n\n const popoverContext = {\n scope: __scopePopover,\n scopeKey: id,\n popperScope: popperScope.__scopePopper,\n sheetBreakpoint,\n contentId: useId(),\n triggerRef,\n open,\n breakpointActive,\n onOpenChange: setOpen,\n onOpenToggle: useEvent(() => {\n if (open && breakpointActive) {\n return\n }\n setOpen(!open)\n }),\n hasCustomAnchor,\n onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),\n onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), []),\n }\n\n // debug if changing too often\n // if (process.env.NODE_ENV === 'development') {\n // Object.keys(popoverContext).forEach((key) => {\n // React.useEffect(() => console.log(`changed`, key), [popoverContext[key]])\n // })\n // }\n\n const contents = (\n <Popper {...popperScope} stayInFrame {...restProps}>\n <PopoverProviderInternal {...popoverContext}>\n <PopoverSheetController onOpenChange={setOpen} __scopePopover={__scopePopover}>\n {children}\n </PopoverSheetController>\n </PopoverProviderInternal>\n </Popper>\n )\n\n return (\n <AdaptProvider>\n {isWeb ? (\n <FloatingOverrideContext.Provider value={useFloatingContext as any}>\n {contents}\n </FloatingOverrideContext.Provider>\n ) : (\n contents\n )}\n </AdaptProvider>\n )\n }) as React.FC<PopoverProps>,\n {\n Anchor: PopoverAnchor,\n Arrow: PopoverArrow,\n Trigger: PopoverTrigger,\n Content: PopoverContent,\n Close: PopoverClose,\n Adapt,\n ScrollView: PopoverScrollView,\n Sheet: ControlledSheet,\n }\n)\n\nPopover.displayName = POPOVER_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nfunction getState(open: boolean) {\n return open ? 'open' : 'closed'\n}\n\nconst PopoverSheetController = (\n props: ScopedProps<{\n children: React.ReactNode\n onOpenChange: React.Dispatch<React.SetStateAction<boolean>>\n }>\n) => {\n const context = usePopoverInternalContext(\n 'PopoverSheetController',\n props.__scopePopover\n )\n const showSheet = useShowPopoverSheet(context)\n const breakpointActive = context.breakpointActive\n const getShowSheet = useGet(showSheet)\n return (\n <SheetController\n onOpenChange={(val) => {\n if (getShowSheet()) {\n props.onOpenChange(val)\n }\n }}\n open={context.open}\n hidden={breakpointActive === false}\n >\n {props.children}\n </SheetController>\n )\n}\n\nconst useSheetBreakpointActive = (breakpoint?: MediaQueryKey | null | boolean) => {\n const media = useMedia()\n if (typeof breakpoint === 'boolean' || !breakpoint) {\n return !!breakpoint\n }\n return media[breakpoint]\n}\n\nconst useShowPopoverSheet = (context: PopoverContextValue) => {\n const breakpointActive = useSheetBreakpointActive(context.sheetBreakpoint)\n return context.open === false ? false : breakpointActive\n}\n"],
|
|
5
|
-
"mappings": "AA0HW,cAwJL,YAxJK;AAxHX,OAAO;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,OAAO,sBAAsB;AACtC,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC;AAAA,EAIE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,0BAA0B;AAEnC,SAAS,+BAA+B;AACxC,SAAS,kBAAmC;AAC5C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QAAQ,YAAY,kBAAkB;AAC/C,SAAS,oBAAuC;AAChD,SAAS,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;AAAA,IAAC;AAAA;AAAA,MACC,cAAc,CAAC,QAAQ;AACrB,YAAI,aAAa,GAAG;AAClB,gBAAM,aAAa,GAAG;AAAA,QACxB;AAAA,MACF;AAAA,MACA,MAAM,QAAQ;AAAA,MACd,QAAQ,qBAAqB;AAAA,MAE5B,gBAAM;AAAA;AAAA,EACT;AAEJ;AAEA,MAAM,2BAA2B,CAAC,eAAgD;AAChF,QAAM,QAAQ,SAAS;AACvB,MAAI,OAAO,eAAe,aAAa,CAAC,YAAY;AAClD,WAAO,CAAC,CAAC;AAAA,EACX;AACA,SAAO,MAAM,UAAU;AACzB;AAEA,MAAM,sBAAsB,CAAC,YAAiC;AAC5D,QAAM,mBAAmB,yBAAyB,QAAQ,eAAe;AACzE,SAAO,QAAQ,SAAS,QAAQ,QAAQ;AAC1C;",
|
|
6
6
|
"names": ["props"]
|
|
7
7
|
}
|
package/dist/jsx/Popover.js
CHANGED
|
@@ -73,7 +73,14 @@ const PopoverTrigger = React.forwardRef((props, forwardedRef) => {
|
|
|
73
73
|
const context = usePopoverInternalContext(TRIGGER_NAME, __scopePopover);
|
|
74
74
|
const popperScope = usePopoverScope(__scopePopover);
|
|
75
75
|
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
76
|
-
const trigger = <YStack
|
|
76
|
+
const trigger = <YStack
|
|
77
|
+
aria-haspopup="dialog"
|
|
78
|
+
aria-expanded={context.open}
|
|
79
|
+
data-state={getState(context.open)}
|
|
80
|
+
{...triggerProps}
|
|
81
|
+
ref={composedTriggerRef}
|
|
82
|
+
onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}
|
|
83
|
+
/>;
|
|
77
84
|
return context.hasCustomAnchor ? trigger : <PopperAnchor asChild {...popperScope}>{trigger}</PopperAnchor>;
|
|
78
85
|
});
|
|
79
86
|
PopoverTrigger.displayName = TRIGGER_NAME;
|
|
@@ -97,24 +104,33 @@ const PopoverContent = React.forwardRef((props, forwardedRef) => {
|
|
|
97
104
|
if (content)
|
|
98
105
|
return hideOthers(content);
|
|
99
106
|
}, [context.open]);
|
|
100
|
-
return <PopoverContentPortal zIndex={zIndex}><PopoverContentImpl
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
(event) => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
107
|
+
return <PopoverContentPortal zIndex={zIndex}><PopoverContentImpl
|
|
108
|
+
{...contentModalProps}
|
|
109
|
+
disableRemoveScroll={disableRemoveScroll}
|
|
110
|
+
ref={composedRefs}
|
|
111
|
+
trapFocus={trapFocus ?? context.open}
|
|
112
|
+
disableOutsidePointerEvents
|
|
113
|
+
onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
if (!isRightClickOutsideRef.current)
|
|
116
|
+
context.triggerRef.current?.focus();
|
|
117
|
+
})}
|
|
118
|
+
onPointerDownOutside={composeEventHandlers(
|
|
119
|
+
props.onPointerDownOutside,
|
|
120
|
+
(event) => {
|
|
121
|
+
const originalEvent = event.detail.originalEvent;
|
|
122
|
+
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
123
|
+
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
124
|
+
isRightClickOutsideRef.current = isRightClick;
|
|
125
|
+
},
|
|
126
|
+
{ checkDefaultPrevented: false }
|
|
127
|
+
)}
|
|
128
|
+
onFocusOutside={composeEventHandlers(
|
|
129
|
+
props.onFocusOutside,
|
|
130
|
+
(event) => event.preventDefault(),
|
|
131
|
+
{ checkDefaultPrevented: false }
|
|
132
|
+
)}
|
|
133
|
+
/></PopoverContentPortal>;
|
|
118
134
|
});
|
|
119
135
|
function PopoverContentPortal(props) {
|
|
120
136
|
const themeName = useThemeName();
|
|
@@ -126,7 +142,10 @@ function PopoverContentPortal(props) {
|
|
|
126
142
|
}
|
|
127
143
|
const zIndex = props.zIndex ?? 1e3;
|
|
128
144
|
return <Portal zIndex={zIndex}><Theme forceClassName name={themeName}>
|
|
129
|
-
{!!context.open && !context.breakpointActive && <YStack
|
|
145
|
+
{!!context.open && !context.breakpointActive && <YStack
|
|
146
|
+
fullscreen
|
|
147
|
+
onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}
|
|
148
|
+
/>}
|
|
130
149
|
<Stack zIndex={zIndex + 1}>{contents}</Stack>
|
|
131
150
|
</Theme></Portal>;
|
|
132
151
|
}
|
|
@@ -158,19 +177,41 @@ const PopoverContentImpl = React.forwardRef((props, forwardedRef) => {
|
|
|
158
177
|
});
|
|
159
178
|
return <PortalItem hostName={`${context.scopeKey}SheetContents`}>{childrenWithoutScrollView}</PortalItem>;
|
|
160
179
|
}
|
|
161
|
-
return <AnimatePresence>{!!context.open && <PopperContent
|
|
162
|
-
|
|
163
|
-
|
|
180
|
+
return <AnimatePresence>{!!context.open && <PopperContent
|
|
181
|
+
key={context.contentId}
|
|
182
|
+
data-state={getState(context.open)}
|
|
183
|
+
id={context.contentId}
|
|
184
|
+
pointerEvents="auto"
|
|
185
|
+
ref={forwardedRef}
|
|
186
|
+
{...popperScope}
|
|
187
|
+
{...contentProps}
|
|
188
|
+
><RemoveScroll
|
|
189
|
+
enabled={disableRemoveScroll ? false : context.open}
|
|
190
|
+
allowPinchZoom
|
|
191
|
+
removeScrollBar={false}
|
|
192
|
+
style={{
|
|
193
|
+
display: "contents"
|
|
194
|
+
}}
|
|
195
|
+
>{trapFocus === false ? children : <FocusScope
|
|
196
|
+
loop
|
|
197
|
+
trapped={trapFocus ?? context.open}
|
|
198
|
+
onMountAutoFocus={onOpenAutoFocus}
|
|
199
|
+
onUnmountAutoFocus={onCloseAutoFocus}
|
|
200
|
+
>{isWeb ? <div style={{ display: "contents" }}>{children}</div> : children}</FocusScope>}</RemoveScroll></PopperContent>}</AnimatePresence>;
|
|
164
201
|
});
|
|
165
202
|
const CLOSE_NAME = "PopoverClose";
|
|
166
203
|
const PopoverClose = React.forwardRef(
|
|
167
204
|
(props, forwardedRef) => {
|
|
168
205
|
const { __scopePopover, ...closeProps } = props;
|
|
169
206
|
const context = usePopoverInternalContext(CLOSE_NAME, __scopePopover);
|
|
170
|
-
return <YStack
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
207
|
+
return <YStack
|
|
208
|
+
{...closeProps}
|
|
209
|
+
ref={forwardedRef}
|
|
210
|
+
onPress={composeEventHandlers(
|
|
211
|
+
props.onPress,
|
|
212
|
+
() => context.onOpenChange(false)
|
|
213
|
+
)}
|
|
214
|
+
/>;
|
|
174
215
|
}
|
|
175
216
|
);
|
|
176
217
|
PopoverClose.displayName = CLOSE_NAME;
|
|
@@ -222,6 +263,10 @@ const Popover = withStaticProperties(
|
|
|
222
263
|
onOpenChange: setOpen
|
|
223
264
|
});
|
|
224
265
|
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
266
|
+
// useFocus(floating.context, {
|
|
267
|
+
// enabled: !breakpointActive,
|
|
268
|
+
// keyboardOnly: true,
|
|
269
|
+
// }),
|
|
225
270
|
useRole(floating.context, { role: "dialog" }),
|
|
226
271
|
useDismiss(floating.context, {
|
|
227
272
|
enabled: !breakpointActive
|
|
@@ -281,11 +326,15 @@ const PopoverSheetController = (props) => {
|
|
|
281
326
|
const showSheet = useShowPopoverSheet(context);
|
|
282
327
|
const breakpointActive = context.breakpointActive;
|
|
283
328
|
const getShowSheet = useGet(showSheet);
|
|
284
|
-
return <SheetController
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
329
|
+
return <SheetController
|
|
330
|
+
onOpenChange={(val) => {
|
|
331
|
+
if (getShowSheet()) {
|
|
332
|
+
props.onOpenChange(val);
|
|
333
|
+
}
|
|
334
|
+
}}
|
|
335
|
+
open={context.open}
|
|
336
|
+
hidden={breakpointActive === false}
|
|
337
|
+
>{props.children}</SheetController>;
|
|
289
338
|
};
|
|
290
339
|
const useSheetBreakpointActive = (breakpoint) => {
|
|
291
340
|
const media = useMedia();
|