@tamagui/popover 1.13.2 → 1.13.4
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 +1 -384
- package/dist/cjs/Popover.js.map +2 -2
- package/dist/cjs/index.js +1 -19
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/useFloatingContext.js +1 -54
- package/dist/cjs/useFloatingContext.js.map +2 -2
- package/dist/cjs/useFloatingContext.native.js +1 -30
- package/dist/cjs/useFloatingContext.native.js.map +2 -2
- package/dist/esm/Popover.js +1 -362
- package/dist/esm/Popover.js.map +2 -2
- package/dist/esm/Popover.mjs +1 -362
- package/dist/esm/Popover.mjs.map +2 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/useFloatingContext.js +1 -30
- package/dist/esm/useFloatingContext.js.map +2 -2
- package/dist/esm/useFloatingContext.mjs +1 -30
- package/dist/esm/useFloatingContext.mjs.map +2 -2
- package/dist/esm/useFloatingContext.native.js +1 -6
- package/dist/esm/useFloatingContext.native.js.map +2 -2
- package/dist/esm/useFloatingContext.native.mjs +1 -6
- package/dist/esm/useFloatingContext.native.mjs.map +2 -2
- package/dist/jsx/Popover.js +1 -332
- package/dist/jsx/Popover.js.map +2 -2
- package/dist/jsx/Popover.mjs +1 -332
- package/dist/jsx/Popover.mjs.map +2 -2
- package/dist/jsx/index.js +1 -2
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -2
- package/dist/jsx/index.mjs.map +1 -1
- package/dist/jsx/useFloatingContext.js +1 -30
- package/dist/jsx/useFloatingContext.js.map +2 -2
- package/dist/jsx/useFloatingContext.mjs +1 -30
- package/dist/jsx/useFloatingContext.mjs.map +2 -2
- package/dist/jsx/useFloatingContext.native.js +1 -6
- package/dist/jsx/useFloatingContext.native.js.map +2 -2
- package/dist/jsx/useFloatingContext.native.mjs +1 -6
- package/dist/jsx/useFloatingContext.native.mjs.map +2 -2
- package/package.json +19 -19
package/dist/jsx/Popover.mjs
CHANGED
|
@@ -1,333 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Adapt, useAdaptParent } from "@tamagui/adapt";
|
|
3
|
-
import { AnimatePresence } from "@tamagui/animate-presence";
|
|
4
|
-
import { hideOthers } from "@tamagui/aria-hidden";
|
|
5
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
6
|
-
import {
|
|
7
|
-
Stack,
|
|
8
|
-
Theme,
|
|
9
|
-
composeEventHandlers,
|
|
10
|
-
isWeb,
|
|
11
|
-
useEvent,
|
|
12
|
-
useGet,
|
|
13
|
-
useId,
|
|
14
|
-
useMedia,
|
|
15
|
-
useThemeName,
|
|
16
|
-
withStaticProperties
|
|
17
|
-
} from "@tamagui/core";
|
|
18
|
-
import { createContextScope } from "@tamagui/create-context";
|
|
19
|
-
import { FloatingOverrideContext } from "@tamagui/floating";
|
|
20
|
-
import { FocusScope } from "@tamagui/focus-scope";
|
|
21
|
-
import {
|
|
22
|
-
Popper,
|
|
23
|
-
PopperAnchor,
|
|
24
|
-
PopperArrow,
|
|
25
|
-
PopperContent,
|
|
26
|
-
PopperContentFrame,
|
|
27
|
-
PopperProvider,
|
|
28
|
-
createPopperScope,
|
|
29
|
-
usePopperContext
|
|
30
|
-
} from "@tamagui/popper";
|
|
31
|
-
import { Portal, PortalHost, PortalItem } from "@tamagui/portal";
|
|
32
|
-
import { RemoveScroll } from "@tamagui/remove-scroll";
|
|
33
|
-
import { ControlledSheet, SheetController } from "@tamagui/sheet";
|
|
34
|
-
import { YStack } from "@tamagui/stacks";
|
|
35
|
-
import { useControllableState } from "@tamagui/use-controllable-state";
|
|
36
|
-
import * as React from "react";
|
|
37
|
-
import { Platform, ScrollView } from "react-native";
|
|
38
|
-
import { useFloatingContext } from "./useFloatingContext";
|
|
39
|
-
const POPOVER_NAME = "Popover";
|
|
40
|
-
const [createPopoverContext, createPopoverScopeInternal] = createContextScope(
|
|
41
|
-
POPOVER_NAME,
|
|
42
|
-
[createPopperScope]
|
|
43
|
-
);
|
|
44
|
-
const usePopoverScope = createPopperScope();
|
|
45
|
-
const createPopoverScope = createPopoverScopeInternal;
|
|
46
|
-
const [PopoverProviderInternal, usePopoverInternalContext] = createPopoverContext(POPOVER_NAME);
|
|
47
|
-
const __PopoverProviderInternal = PopoverProviderInternal;
|
|
48
|
-
const ANCHOR_NAME = "PopoverAnchor";
|
|
49
|
-
const PopoverAnchor = React.forwardRef(
|
|
50
|
-
(props, forwardedRef) => {
|
|
51
|
-
const { __scopePopover, ...anchorProps } = props;
|
|
52
|
-
const context = usePopoverInternalContext(ANCHOR_NAME, __scopePopover);
|
|
53
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
54
|
-
const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
|
|
55
|
-
React.useEffect(() => {
|
|
56
|
-
onCustomAnchorAdd();
|
|
57
|
-
return () => onCustomAnchorRemove();
|
|
58
|
-
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
|
|
59
|
-
return <PopperAnchor {...popperScope} {...anchorProps} ref={forwardedRef} />;
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
PopoverAnchor.displayName = ANCHOR_NAME;
|
|
63
|
-
const TRIGGER_NAME = "PopoverTrigger";
|
|
64
|
-
const PopoverTrigger = React.forwardRef((props, forwardedRef) => {
|
|
65
|
-
const { __scopePopover, ...triggerProps } = props;
|
|
66
|
-
const context = usePopoverInternalContext(TRIGGER_NAME, __scopePopover);
|
|
67
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
68
|
-
const composedTriggerRef = useComposedRefs(forwardedRef, context.triggerRef);
|
|
69
|
-
const trigger = <YStack
|
|
70
|
-
aria-haspopup="dialog"
|
|
71
|
-
aria-expanded={context.open}
|
|
72
|
-
data-state={getState(context.open)}
|
|
73
|
-
{...triggerProps}
|
|
74
|
-
ref={composedTriggerRef}
|
|
75
|
-
onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}
|
|
76
|
-
/>;
|
|
77
|
-
return context.hasCustomAnchor ? trigger : <PopperAnchor asChild {...popperScope}>{trigger}</PopperAnchor>;
|
|
78
|
-
});
|
|
79
|
-
PopoverTrigger.displayName = TRIGGER_NAME;
|
|
80
|
-
const CONTENT_NAME = "PopoverContent";
|
|
81
|
-
const PopoverContent = PopperContentFrame.extractable(
|
|
82
|
-
React.forwardRef(
|
|
83
|
-
function PopoverContent2(props, forwardedRef) {
|
|
84
|
-
const {
|
|
85
|
-
allowPinchZoom,
|
|
86
|
-
trapFocus,
|
|
87
|
-
disableRemoveScroll = true,
|
|
88
|
-
zIndex,
|
|
89
|
-
...contentImplProps
|
|
90
|
-
} = props;
|
|
91
|
-
const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover);
|
|
92
|
-
const contentRef = React.useRef(null);
|
|
93
|
-
const composedRefs = useComposedRefs(forwardedRef, contentRef);
|
|
94
|
-
const isRightClickOutsideRef = React.useRef(false);
|
|
95
|
-
React.useEffect(() => {
|
|
96
|
-
if (!context.open)
|
|
97
|
-
return;
|
|
98
|
-
const content = contentRef.current;
|
|
99
|
-
if (content)
|
|
100
|
-
return hideOthers(content);
|
|
101
|
-
}, [context.open]);
|
|
102
|
-
return <PopoverContentPortal zIndex={zIndex}><PopoverContentImpl
|
|
103
|
-
{...contentImplProps}
|
|
104
|
-
disableRemoveScroll={disableRemoveScroll}
|
|
105
|
-
ref={composedRefs}
|
|
106
|
-
trapFocus={trapFocus ?? context.open}
|
|
107
|
-
disableOutsidePointerEvents
|
|
108
|
-
onCloseAutoFocus={composeEventHandlers(props.onCloseAutoFocus, (event) => {
|
|
109
|
-
event.preventDefault();
|
|
110
|
-
if (!isRightClickOutsideRef.current)
|
|
111
|
-
context.triggerRef.current?.focus();
|
|
112
|
-
})}
|
|
113
|
-
onPointerDownOutside={composeEventHandlers(
|
|
114
|
-
props.onPointerDownOutside,
|
|
115
|
-
(event) => {
|
|
116
|
-
const originalEvent = event.detail.originalEvent;
|
|
117
|
-
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
118
|
-
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
119
|
-
isRightClickOutsideRef.current = isRightClick;
|
|
120
|
-
},
|
|
121
|
-
{ checkDefaultPrevented: false }
|
|
122
|
-
)}
|
|
123
|
-
onFocusOutside={composeEventHandlers(
|
|
124
|
-
props.onFocusOutside,
|
|
125
|
-
(event) => event.preventDefault(),
|
|
126
|
-
{ checkDefaultPrevented: false }
|
|
127
|
-
)}
|
|
128
|
-
/></PopoverContentPortal>;
|
|
129
|
-
}
|
|
130
|
-
)
|
|
131
|
-
);
|
|
132
|
-
function PopoverContentPortal(props) {
|
|
133
|
-
const themeName = useThemeName();
|
|
134
|
-
const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover);
|
|
135
|
-
let contents = props.children;
|
|
136
|
-
if (Platform.OS === "android") {
|
|
137
|
-
const popperContext = usePopperContext(CONTENT_NAME, context.popperScope);
|
|
138
|
-
contents = <PopperProvider {...popperContext} scope={context.popperScope}><PopoverProviderInternal scope={props.__scopePopover} {...context}>{props.children}</PopoverProviderInternal></PopperProvider>;
|
|
139
|
-
}
|
|
140
|
-
const zIndex = props.zIndex ?? 1e3;
|
|
141
|
-
return <Portal zIndex={zIndex}><Theme forceClassName name={themeName}>
|
|
142
|
-
{!!context.open && !context.breakpointActive && <YStack
|
|
143
|
-
fullscreen
|
|
144
|
-
onPress={composeEventHandlers(props.onPress, context.onOpenToggle)}
|
|
145
|
-
/>}
|
|
146
|
-
<Stack zIndex={zIndex + 1}>{contents}</Stack>
|
|
147
|
-
</Theme></Portal>;
|
|
148
|
-
}
|
|
149
|
-
const PopoverContentImpl = React.forwardRef((props, forwardedRef) => {
|
|
150
|
-
const {
|
|
151
|
-
__scopePopover,
|
|
152
|
-
trapFocus,
|
|
153
|
-
onOpenAutoFocus,
|
|
154
|
-
onCloseAutoFocus,
|
|
155
|
-
disableOutsidePointerEvents,
|
|
156
|
-
onEscapeKeyDown,
|
|
157
|
-
onPointerDownOutside,
|
|
158
|
-
onFocusOutside,
|
|
159
|
-
onInteractOutside,
|
|
160
|
-
children,
|
|
161
|
-
disableRemoveScroll,
|
|
162
|
-
...contentProps
|
|
163
|
-
} = props;
|
|
164
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
165
|
-
const context = usePopoverInternalContext(CONTENT_NAME, popperScope.__scopePopover);
|
|
166
|
-
if (context.breakpointActive) {
|
|
167
|
-
const childrenWithoutScrollView = React.Children.toArray(children).map((child) => {
|
|
168
|
-
if (React.isValidElement(child)) {
|
|
169
|
-
if (child.type === PopoverScrollView) {
|
|
170
|
-
return child.props.children;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return child;
|
|
174
|
-
});
|
|
175
|
-
return <PortalItem hostName={`${context.scopeKey}PopoverContents`}>{childrenWithoutScrollView}</PortalItem>;
|
|
176
|
-
}
|
|
177
|
-
return <AnimatePresence>{!!context.open && <PopperContent
|
|
178
|
-
key={context.contentId}
|
|
179
|
-
data-state={getState(context.open)}
|
|
180
|
-
id={context.contentId}
|
|
181
|
-
pointerEvents="auto"
|
|
182
|
-
ref={forwardedRef}
|
|
183
|
-
{...popperScope}
|
|
184
|
-
{...contentProps}
|
|
185
|
-
><RemoveScroll
|
|
186
|
-
enabled={disableRemoveScroll ? false : context.open}
|
|
187
|
-
allowPinchZoom
|
|
188
|
-
removeScrollBar={false}
|
|
189
|
-
style={{
|
|
190
|
-
display: "contents"
|
|
191
|
-
}}
|
|
192
|
-
>{trapFocus === false ? children : <FocusScope
|
|
193
|
-
loop
|
|
194
|
-
trapped={trapFocus ?? context.open}
|
|
195
|
-
onMountAutoFocus={onOpenAutoFocus}
|
|
196
|
-
onUnmountAutoFocus={onCloseAutoFocus}
|
|
197
|
-
>{isWeb ? <div style={{ display: "contents" }}>{children}</div> : children}</FocusScope>}</RemoveScroll></PopperContent>}</AnimatePresence>;
|
|
198
|
-
});
|
|
199
|
-
const CLOSE_NAME = "PopoverClose";
|
|
200
|
-
const PopoverClose = React.forwardRef(
|
|
201
|
-
(props, forwardedRef) => {
|
|
202
|
-
const { __scopePopover, ...closeProps } = props;
|
|
203
|
-
const context = usePopoverInternalContext(CLOSE_NAME, __scopePopover);
|
|
204
|
-
return <YStack
|
|
205
|
-
{...closeProps}
|
|
206
|
-
ref={forwardedRef}
|
|
207
|
-
onPress={composeEventHandlers(
|
|
208
|
-
props.onPress,
|
|
209
|
-
() => context.onOpenChange(false)
|
|
210
|
-
)}
|
|
211
|
-
/>;
|
|
212
|
-
}
|
|
213
|
-
);
|
|
214
|
-
PopoverClose.displayName = CLOSE_NAME;
|
|
215
|
-
const ARROW_NAME = "PopoverArrow";
|
|
216
|
-
const PopoverArrow = React.forwardRef(
|
|
217
|
-
(props, forwardedRef) => {
|
|
218
|
-
const { __scopePopover, ...arrowProps } = props;
|
|
219
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
220
|
-
return <PopperArrow {...popperScope} {...arrowProps} ref={forwardedRef} />;
|
|
221
|
-
}
|
|
222
|
-
);
|
|
223
|
-
PopoverArrow.displayName = ARROW_NAME;
|
|
224
|
-
const PopoverScrollView = React.forwardRef((props, ref) => {
|
|
225
|
-
return <ScrollView ref={ref} {...props} />;
|
|
226
|
-
});
|
|
227
|
-
const Popover = withStaticProperties(
|
|
228
|
-
function Popover2(props) {
|
|
229
|
-
const {
|
|
230
|
-
__scopePopover,
|
|
231
|
-
children,
|
|
232
|
-
open: openProp,
|
|
233
|
-
defaultOpen,
|
|
234
|
-
onOpenChange,
|
|
235
|
-
...restProps
|
|
236
|
-
} = props;
|
|
237
|
-
const internalId = useId();
|
|
238
|
-
const id = __scopePopover ? Object.keys(__scopePopover)[0] : internalId;
|
|
239
|
-
const { when, AdaptProvider } = useAdaptParent({
|
|
240
|
-
Contents: React.useCallback(() => {
|
|
241
|
-
return <PortalHost name={`${id}PopoverContents`} />;
|
|
242
|
-
}, [])
|
|
243
|
-
});
|
|
244
|
-
const sheetBreakpoint = when;
|
|
245
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
246
|
-
const triggerRef = React.useRef(null);
|
|
247
|
-
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
248
|
-
const [open, setOpen] = useControllableState({
|
|
249
|
-
prop: openProp,
|
|
250
|
-
defaultProp: defaultOpen || false,
|
|
251
|
-
onChange: onOpenChange,
|
|
252
|
-
transition: true
|
|
253
|
-
});
|
|
254
|
-
const breakpointActive = useSheetBreakpointActive(sheetBreakpoint);
|
|
255
|
-
const floatingContext = useFloatingContext({ open, setOpen, breakpointActive });
|
|
256
|
-
const popoverContext = {
|
|
257
|
-
scope: __scopePopover,
|
|
258
|
-
scopeKey: id,
|
|
259
|
-
popperScope: popperScope.__scopePopper,
|
|
260
|
-
sheetBreakpoint,
|
|
261
|
-
contentId: useId(),
|
|
262
|
-
triggerRef,
|
|
263
|
-
open,
|
|
264
|
-
breakpointActive,
|
|
265
|
-
onOpenChange: setOpen,
|
|
266
|
-
onOpenToggle: useEvent(() => {
|
|
267
|
-
if (open && breakpointActive) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
setOpen(!open);
|
|
271
|
-
}),
|
|
272
|
-
hasCustomAnchor,
|
|
273
|
-
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
|
|
274
|
-
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), [])
|
|
275
|
-
};
|
|
276
|
-
const contents = <Popper {...popperScope} stayInFrame {...restProps}><PopoverProviderInternal {...popoverContext}><PopoverSheetController onOpenChange={setOpen} __scopePopover={__scopePopover}>{children}</PopoverSheetController></PopoverProviderInternal></Popper>;
|
|
277
|
-
return <AdaptProvider>{isWeb ? <FloatingOverrideContext.Provider value={floatingContext}>{contents}</FloatingOverrideContext.Provider> : contents}</AdaptProvider>;
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
Anchor: PopoverAnchor,
|
|
281
|
-
Arrow: PopoverArrow,
|
|
282
|
-
Trigger: PopoverTrigger,
|
|
283
|
-
Content: PopoverContent,
|
|
284
|
-
Close: PopoverClose,
|
|
285
|
-
Adapt,
|
|
286
|
-
ScrollView: PopoverScrollView,
|
|
287
|
-
Sheet: ControlledSheet
|
|
288
|
-
}
|
|
289
|
-
);
|
|
290
|
-
function getState(open) {
|
|
291
|
-
return open ? "open" : "closed";
|
|
292
|
-
}
|
|
293
|
-
const PopoverSheetController = (props) => {
|
|
294
|
-
const context = usePopoverInternalContext(
|
|
295
|
-
"PopoverSheetController",
|
|
296
|
-
props.__scopePopover
|
|
297
|
-
);
|
|
298
|
-
const showSheet = useShowPopoverSheet(context);
|
|
299
|
-
const breakpointActive = context.breakpointActive;
|
|
300
|
-
const getShowSheet = useGet(showSheet);
|
|
301
|
-
return <SheetController
|
|
302
|
-
onOpenChange={(val) => {
|
|
303
|
-
if (getShowSheet()) {
|
|
304
|
-
props.onOpenChange(val);
|
|
305
|
-
}
|
|
306
|
-
}}
|
|
307
|
-
open={context.open}
|
|
308
|
-
hidden={breakpointActive === false}
|
|
309
|
-
>{props.children}</SheetController>;
|
|
310
|
-
};
|
|
311
|
-
const useSheetBreakpointActive = (breakpoint) => {
|
|
312
|
-
const media = useMedia();
|
|
313
|
-
if (typeof breakpoint === "boolean" || !breakpoint) {
|
|
314
|
-
return !!breakpoint;
|
|
315
|
-
}
|
|
316
|
-
return media[breakpoint];
|
|
317
|
-
};
|
|
318
|
-
const useShowPopoverSheet = (context) => {
|
|
319
|
-
const breakpointActive = useSheetBreakpointActive(context.sheetBreakpoint);
|
|
320
|
-
return context.open === false ? false : breakpointActive;
|
|
321
|
-
};
|
|
322
|
-
export {
|
|
323
|
-
Popover,
|
|
324
|
-
PopoverAnchor,
|
|
325
|
-
PopoverArrow,
|
|
326
|
-
PopoverClose,
|
|
327
|
-
PopoverContent,
|
|
328
|
-
PopoverTrigger,
|
|
329
|
-
__PopoverProviderInternal,
|
|
330
|
-
createPopoverScope,
|
|
331
|
-
usePopoverScope
|
|
332
|
-
};
|
|
1
|
+
import"@tamagui/polyfill-dev";import{Adapt as oo,useAdaptParent as eo}from"@tamagui/adapt";import{AnimatePresence as Po}from"@tamagui/animate-presence";import{hideOthers as io}from"@tamagui/aria-hidden";import{useComposedRefs as V}from"@tamagui/compose-refs";import{Stack as Co,Theme as So,composeEventHandlers as x,isWeb as M,useEvent as go,useGet as Ao,useId as D,useMedia as yo,useThemeName as wo,withStaticProperties as xo}from"@tamagui/core";import{createContextScope as Ro}from"@tamagui/create-context";import{FloatingOverrideContext as Oo}from"@tamagui/floating";import{FocusScope as Eo}from"@tamagui/focus-scope";import{Popper as _o,PopperAnchor as H,PopperArrow as To,PopperContent as Io,PopperContentFrame as ko,PopperProvider as Fo,createPopperScope as K,usePopperContext as No}from"@tamagui/popper";import{Portal as Vo,PortalHost as Mo,PortalItem as Do}from"@tamagui/portal";import{RemoveScroll as Ho}from"@tamagui/remove-scroll";import{ControlledSheet as Ko,SheetController as Lo}from"@tamagui/sheet";import{YStack as I}from"@tamagui/stacks";import{useControllableState as Bo}from"@tamagui/use-controllable-state";import*as p from"react";import{Platform as Wo,ScrollView as Yo}from"react-native";import{useFloatingContext as Zo}from"./useFloatingContext";const L="Popover",[Go,jo]=Ro(L,[K]),R=K(),Te=jo,[F,A]=Go(L),Ie=F,B="PopoverAnchor",W=p.forwardRef((o,e)=>{const{__scopePopover:t,...n}=o,r=A(B,t),s=R(t),{onCustomAnchorAdd:P,onCustomAnchorRemove:l}=r;return p.useEffect(()=>(P(),()=>l()),[P,l]),<H{...s}{...n}ref={e}/>});W.displayName=B;const Y="PopoverTrigger",Z=p.forwardRef((o,e)=>{const{__scopePopover:t,...n}=o,r=A(Y,t),s=R(t),P=V(e,r.triggerRef),l=<I aria-haspopup="dialog"aria-expanded={r.open}data-state={$(r.open)}{...n}ref={P}onPress={x(o.onPress,r.onOpenToggle)}/>;return r.hasCustomAnchor?l:<H asChild{...s}>{l}</H>});Z.displayName=Y;const _="PopoverContent",Qo=ko.extractable(p.forwardRef(function(e,t){const{allowPinchZoom:n,trapFocus:r,disableRemoveScroll:s=!0,zIndex:P,...l}=e,g=A(_,e.__scopePopover),y=p.useRef(null),O=V(t,y),C=p.useRef(!1);return p.useEffect(()=>{if(!g.open)return;const c=y.current;if(c)return io(c)},[g.open]),<Uo zIndex={P}><$o{...l}disableRemoveScroll={s}ref={O}trapFocus={r??g.open}disableOutsidePointerEvents onCloseAutoFocus={x(e.onCloseAutoFocus,c=>{c.preventDefault(),C.current||g.triggerRef.current?.focus()})}onPointerDownOutside={x(e.onPointerDownOutside,c=>{const S=c.detail.originalEvent,w=S.button===0&&S.ctrlKey===!0,a=S.button===2||w;C.current=a},{checkDefaultPrevented:!1})}onFocusOutside={x(e.onFocusOutside,c=>c.preventDefault(),{checkDefaultPrevented:!1})}/></Uo>}));function Uo(o){const e=wo(),t=A(_,o.__scopePopover);let n=o.children;if(Wo.OS==="android"){const s=No(_,t.popperScope);n=<Fo{...s}scope={t.popperScope}><F scope={o.__scopePopover}{...t}>{o.children}</F></Fo>}const r=o.zIndex??1e3;return<Vo zIndex={r}><So forceClassName name={e}>{!!t.open&&!t.breakpointActive&&<I fullscreen onPress={x(o.onPress,t.onOpenToggle)}/>}<Co zIndex={r+1}>{n}</Co></So></Vo>}const $o=p.forwardRef((o,e)=>{const{__scopePopover:t,trapFocus:n,onOpenAutoFocus:r,onCloseAutoFocus:s,disableOutsidePointerEvents:P,onEscapeKeyDown:l,onPointerDownOutside:g,onFocusOutside:y,onInteractOutside:O,children:C,disableRemoveScroll:c,...S}=o,w=R(t),a=A(_,w.__scopePopover);if(a.breakpointActive){const E=p.Children.toArray(C).map(h=>p.isValidElement(h)&&h.type===U?h.props.children:h);return<Do hostName={`${a.scopeKey}PopoverContents`}>{E}</Do>}return<Po>{!!a.open&&<Io key={a.contentId}data-state={$(a.open)}id={a.contentId}pointerEvents="auto"ref={e}{...w}{...S}><Ho enabled={c?!1:a.open}allowPinchZoom removeScrollBar={!1}style={{display:"contents"}}>{n===!1?C:<Eo loop trapped={n??a.open}onMountAutoFocus={r}onUnmountAutoFocus={s}>{M?<div style={{display:"contents"}}>{C}</div>:C}</Eo>}</Ho></Io>}</Po>}),G="PopoverClose",j=p.forwardRef((o,e)=>{const{__scopePopover:t,...n}=o,r=A(G,t);return<I{...n}ref={e}onPress={x(o.onPress,()=>r.onOpenChange(!1))}/>});j.displayName=G;const qo="PopoverArrow",Q=p.forwardRef((o,e)=>{const{__scopePopover:t,...n}=o,r=R(t);return<To{...r}{...n}ref={e}/>});Q.displayName=qo;const U=p.forwardRef((o,e)=><Yo ref={e}{...o}/>),ke=xo(function(e){const{__scopePopover:t,children:n,open:r,defaultOpen:s,onOpenChange:P,...l}=e,g=D(),y=t?Object.keys(t)[0]:g,{when:O,AdaptProvider:C}=eo({Contents:p.useCallback(()=><Mo name={`${y}PopoverContents`}/>,[])}),c=O,S=R(t),w=p.useRef(null),[a,E]=p.useState(!1),[h,b]=Bo({prop:r,defaultProp:s||!1,onChange:P,transition:!0}),T=q(c),J=Zo({open:h,setOpen:b,breakpointActive:T}),X={scope:t,scopeKey:y,popperScope:S.__scopePopper,sheetBreakpoint:c,contentId:D(),triggerRef:w,open:h,breakpointActive:T,onOpenChange:b,onOpenToggle:go(()=>{h&&T||b(!h)}),hasCustomAnchor:a,onCustomAnchorAdd:p.useCallback(()=>E(!0),[]),onCustomAnchorRemove:p.useCallback(()=>E(!1),[])},N=<_o{...S}stayInFrame{...l}><F{...X}><Jo onOpenChange={b}__scopePopover={t}>{n}</Jo></F></_o>;return<C>{M?<Oo.Provider value={J}>{N}</Oo.Provider>:N}</C>},{Anchor:W,Arrow:Q,Trigger:Z,Content:Qo,Close:j,Adapt:oo,ScrollView:U,Sheet:Ko});function $(o){return o?"open":"closed"}const Jo=o=>{const e=A("PopoverSheetController",o.__scopePopover),t=Xo(e),n=e.breakpointActive,r=Ao(t);return<Lo onOpenChange={s=>{r()&&o.onOpenChange(s)}}open={e.open}hidden={n===!1}>{o.children}</Lo>},q=o=>{const e=yo();return typeof o=="boolean"||!o?!!o:e[o]},Xo=o=>{const e=q(o.sheetBreakpoint);return o.open===!1?!1:e};export{ke as Popover,W as PopoverAnchor,Q as PopoverArrow,j as PopoverClose,Qo as PopoverContent,Z as PopoverTrigger,Ie as __PopoverProviderInternal,Te as createPopoverScope,R as usePopoverScope};
|
|
333
2
|
//# sourceMappingURL=Popover.mjs.map
|
package/dist/jsx/Popover.mjs.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 { 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 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 PopperContentFrame,\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 { YStack, YStackProps } from '@tamagui/stacks'\nimport { useControllableState } from '@tamagui/use-controllable-state'\nimport * as React from 'react'\nimport { Platform, ScrollView, ScrollViewProps, View } from 'react-native'\n\nimport { useFloatingContext } from './useFloatingContext'\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 = PopperContentFrame.extractable(\n React.forwardRef<PopoverContentTypeElement, PopoverContentTypeProps>(\n function PopoverContent(props: ScopedProps<PopoverContentTypeProps>, forwardedRef) {\n const {\n allowPinchZoom,\n trapFocus,\n disableRemoveScroll = true,\n zIndex,\n ...contentImplProps\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 {...contentImplProps}\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 )\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}PopoverContents`}>\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 function Popover(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}PopoverContents`} />\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 const floatingContext = useFloatingContext({ open, setOpen, breakpointActive }) as any\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={floatingContext}>\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\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": "AAEA,
|
|
6
|
-
"names": ["PopoverContent", "Popover"]
|
|
5
|
+
"mappings": "AAEA,MAAO,wBAEP,OAAS,SAAAA,GAAO,kBAAAC,OAAsB,iBACtC,OAAS,mBAAAC,OAAuB,4BAChC,OAAS,cAAAC,OAAkB,uBAC3B,OAAS,mBAAAC,MAAuB,wBAChC,OAGE,SAAAC,GAEA,SAAAC,GACA,wBAAAC,EACA,SAAAC,EACA,YAAAC,GACA,UAAAC,GACA,SAAAC,EACA,YAAAC,GACA,gBAAAC,GACA,wBAAAC,OACK,gBAEP,OAAS,sBAAAC,OAA0B,0BAEnC,OAAS,2BAAAC,OAA+B,oBACxC,OAAS,cAAAC,OAAmC,uBAC5C,OACE,UAAAC,GACA,gBAAAC,EACA,eAAAC,GAEA,iBAAAC,GACA,sBAAAC,GAGA,kBAAAC,GACA,qBAAAC,EACA,oBAAAC,OACK,kBACP,OAAS,UAAAC,GAAQ,cAAAC,GAAY,cAAAC,OAAkB,kBAC/C,OAAS,gBAAAC,OAAuC,yBAChD,OAAS,mBAAAC,GAAiB,mBAAAC,OAAuB,iBACjD,OAAS,UAAAC,MAA2B,kBACpC,OAAS,wBAAAC,OAA4B,kCACrC,UAAYC,MAAW,QACvB,OAAS,YAAAC,GAAU,cAAAC,OAAyC,eAE5D,OAAS,sBAAAC,OAA0B,uBAEnC,MAAMC,EAAe,UA0Bf,CAACC,GAAsBC,EAA0B,EAAIzB,GACzDuB,EACA,CAACd,CAAiB,CACpB,EACaiB,EAAkBjB,EAAkB,EACpCkB,GAAqBF,GAE5B,CAACG,EAAyBC,CAAyB,EACvDL,GAA0CD,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AC3BuE,EAAejH,GAAO+G,CAAS,EACrC,MACE,CAAC1F,GACC,cAAe6F,GAAQ,CACjBD,EAAa,GACf3E,EAAM,aAAa4E,CAAG,CAE1B,EACA,MAAMxE,EAAQ,KACd,QAAQgE,IAAqB,KAE5BpE,EAAM,SACT,EAVCjB,GAYL,EAEMsF,EAA4BQ,GAAgD,CAChF,MAAMC,EAAQlH,GAAS,EACvB,OAAI,OAAOiH,GAAe,WAAa,CAACA,EAC/B,CAAC,CAACA,EAEJC,EAAMD,CAAU,CACzB,EAEMH,GAAuBtE,GAAiC,CAC5D,MAAMgE,EAAmBC,EAAyBjE,EAAQ,eAAe,EACzE,OAAOA,EAAQ,OAAS,GAAQ,GAAQgE,CAC1C",
|
|
6
|
+
"names": ["Adapt", "useAdaptParent", "AnimatePresence", "hideOthers", "useComposedRefs", "Stack", "Theme", "composeEventHandlers", "isWeb", "useEvent", "useGet", "useId", "useMedia", "useThemeName", "withStaticProperties", "createContextScope", "FloatingOverrideContext", "FocusScope", "Popper", "PopperAnchor", "PopperArrow", "PopperContent", "PopperContentFrame", "PopperProvider", "createPopperScope", "usePopperContext", "Portal", "PortalHost", "PortalItem", "RemoveScroll", "ControlledSheet", "SheetController", "YStack", "useControllableState", "React", "Platform", "ScrollView", "useFloatingContext", "POPOVER_NAME", "createPopoverContext", "createPopoverScopeInternal", "usePopoverScope", "createPopoverScope", "PopoverProviderInternal", "usePopoverInternalContext", "__PopoverProviderInternal", "ANCHOR_NAME", "PopoverAnchor", "props", "forwardedRef", "__scopePopover", "anchorProps", "context", "popperScope", "onCustomAnchorAdd", "onCustomAnchorRemove", "TRIGGER_NAME", "PopoverTrigger", "triggerProps", "composedTriggerRef", "trigger", "getState", "CONTENT_NAME", "PopoverContent", "allowPinchZoom", "trapFocus", "disableRemoveScroll", "zIndex", "contentImplProps", "contentRef", "composedRefs", "isRightClickOutsideRef", "content", "PopoverContentPortal", "PopoverContentImpl", "event", "originalEvent", "ctrlLeftClick", "isRightClick", "themeName", "contents", "popperContext", "onOpenAutoFocus", "onCloseAutoFocus", "disableOutsidePointerEvents", "onEscapeKeyDown", "onPointerDownOutside", "onFocusOutside", "onInteractOutside", "children", "contentProps", "childrenWithoutScrollView", "child", "PopoverScrollView", "CLOSE_NAME", "PopoverClose", "closeProps", "ARROW_NAME", "PopoverArrow", "arrowProps", "ref", "Popover", "openProp", "defaultOpen", "onOpenChange", "restProps", "internalId", "id", "when", "AdaptProvider", "sheetBreakpoint", "triggerRef", "hasCustomAnchor", "setHasCustomAnchor", "open", "setOpen", "breakpointActive", "useSheetBreakpointActive", "floatingContext", "popoverContext", "PopoverSheetController", "showSheet", "useShowPopoverSheet", "getShowSheet", "val", "breakpoint", "media"]
|
|
7
7
|
}
|
package/dist/jsx/index.js
CHANGED
package/dist/jsx/index.js.map
CHANGED
package/dist/jsx/index.mjs
CHANGED
package/dist/jsx/index.mjs.map
CHANGED
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCallback } from "react";
|
|
3
|
-
const useFloatingContext = ({ open, setOpen, breakpointActive }) => useCallback(
|
|
4
|
-
(props) => {
|
|
5
|
-
const floating = useFloating({
|
|
6
|
-
...props,
|
|
7
|
-
open,
|
|
8
|
-
onOpenChange: setOpen
|
|
9
|
-
});
|
|
10
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
11
|
-
// useFocus(floating.context, {
|
|
12
|
-
// enabled: !breakpointActive,
|
|
13
|
-
// keyboardOnly: true,
|
|
14
|
-
// }),
|
|
15
|
-
useRole(floating.context, { role: "dialog" }),
|
|
16
|
-
useDismiss(floating.context, {
|
|
17
|
-
enabled: !breakpointActive
|
|
18
|
-
})
|
|
19
|
-
]);
|
|
20
|
-
return {
|
|
21
|
-
...floating,
|
|
22
|
-
getReferenceProps,
|
|
23
|
-
getFloatingProps
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
[open, setOpen, breakpointActive]
|
|
27
|
-
);
|
|
28
|
-
export {
|
|
29
|
-
useFloatingContext
|
|
30
|
-
};
|
|
1
|
+
import{useDismiss as i,useFloating as l,useInteractions as g,useRole as c}from"@floating-ui/react";import{useCallback as u}from"react";const F=({open:t,setOpen:e,breakpointActive:n})=>u(s=>{const o=l({...s,open:t,onOpenChange:e}),{getReferenceProps:a,getFloatingProps:r}=g([c(o.context,{role:"dialog"}),i(o.context,{enabled:!n})]);return{...o,getReferenceProps:a,getFloatingProps:r}},[t,e,n]);export{F as useFloatingContext};
|
|
31
2
|
//# sourceMappingURL=useFloatingContext.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useFloatingContext.tsx"],
|
|
4
4
|
"sourcesContent": ["import type { UseFloatingProps } from '@floating-ui/react'\nimport { useDismiss, useFloating, useInteractions, useRole } from '@floating-ui/react'\nimport React, { useCallback } from 'react'\n\n// Custom floating context to override the Popper on web\nexport const useFloatingContext = ({ open, setOpen, breakpointActive }) =>\n useCallback(\n (props: UseFloatingProps) => {\n const floating = useFloating({\n ...props,\n open,\n onOpenChange: setOpen,\n }) as any\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 [open, setOpen, breakpointActive]\n )\n"],
|
|
5
|
-
"mappings": "AACA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AACA,OAAS,cAAAA,EAAY,eAAAC,EAAa,mBAAAC,EAAiB,WAAAC,MAAe,qBAClE,OAAgB,eAAAC,MAAmB,QAG5B,MAAMC,EAAqB,CAAC,CAAE,KAAAC,EAAM,QAAAC,EAAS,iBAAAC,CAAiB,IACnEJ,EACGK,GAA4B,CAC3B,MAAMC,EAAWT,EAAY,CAC3B,GAAGQ,EACH,KAAAH,EACA,aAAcC,CAChB,CAAC,EACK,CAAE,kBAAAI,EAAmB,iBAAAC,CAAiB,EAAIV,EAAgB,CAK9DC,EAAQO,EAAS,QAAS,CAAE,KAAM,QAAS,CAAC,EAC5CV,EAAWU,EAAS,QAAS,CAC3B,QAAS,CAACF,CACZ,CAAC,CACH,CAAC,EACD,MAAO,CACL,GAAGE,EACH,kBAAAC,EACA,iBAAAC,CACF,CACF,EACA,CAACN,EAAMC,EAASC,CAAgB,CAClC",
|
|
6
|
+
"names": ["useDismiss", "useFloating", "useInteractions", "useRole", "useCallback", "useFloatingContext", "open", "setOpen", "breakpointActive", "props", "floating", "getReferenceProps", "getFloatingProps"]
|
|
7
7
|
}
|
|
@@ -1,31 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCallback } from "react";
|
|
3
|
-
const useFloatingContext = ({ open, setOpen, breakpointActive }) => useCallback(
|
|
4
|
-
(props) => {
|
|
5
|
-
const floating = useFloating({
|
|
6
|
-
...props,
|
|
7
|
-
open,
|
|
8
|
-
onOpenChange: setOpen
|
|
9
|
-
});
|
|
10
|
-
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
11
|
-
// useFocus(floating.context, {
|
|
12
|
-
// enabled: !breakpointActive,
|
|
13
|
-
// keyboardOnly: true,
|
|
14
|
-
// }),
|
|
15
|
-
useRole(floating.context, { role: "dialog" }),
|
|
16
|
-
useDismiss(floating.context, {
|
|
17
|
-
enabled: !breakpointActive
|
|
18
|
-
})
|
|
19
|
-
]);
|
|
20
|
-
return {
|
|
21
|
-
...floating,
|
|
22
|
-
getReferenceProps,
|
|
23
|
-
getFloatingProps
|
|
24
|
-
};
|
|
25
|
-
},
|
|
26
|
-
[open, setOpen, breakpointActive]
|
|
27
|
-
);
|
|
28
|
-
export {
|
|
29
|
-
useFloatingContext
|
|
30
|
-
};
|
|
1
|
+
import{useDismiss as i,useFloating as l,useInteractions as g,useRole as c}from"@floating-ui/react";import{useCallback as u}from"react";const F=({open:t,setOpen:e,breakpointActive:n})=>u(s=>{const o=l({...s,open:t,onOpenChange:e}),{getReferenceProps:a,getFloatingProps:r}=g([c(o.context,{role:"dialog"}),i(o.context,{enabled:!n})]);return{...o,getReferenceProps:a,getFloatingProps:r}},[t,e,n]);export{F as useFloatingContext};
|
|
31
2
|
//# sourceMappingURL=useFloatingContext.mjs.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useFloatingContext.tsx"],
|
|
4
4
|
"sourcesContent": ["import type { UseFloatingProps } from '@floating-ui/react'\nimport { useDismiss, useFloating, useInteractions, useRole } from '@floating-ui/react'\nimport React, { useCallback } from 'react'\n\n// Custom floating context to override the Popper on web\nexport const useFloatingContext = ({ open, setOpen, breakpointActive }) =>\n useCallback(\n (props: UseFloatingProps) => {\n const floating = useFloating({\n ...props,\n open,\n onOpenChange: setOpen,\n }) as any\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 [open, setOpen, breakpointActive]\n )\n"],
|
|
5
|
-
"mappings": "AACA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AACA,OAAS,cAAAA,EAAY,eAAAC,EAAa,mBAAAC,EAAiB,WAAAC,MAAe,qBAClE,OAAgB,eAAAC,MAAmB,QAG5B,MAAMC,EAAqB,CAAC,CAAE,KAAAC,EAAM,QAAAC,EAAS,iBAAAC,CAAiB,IACnEJ,EACGK,GAA4B,CAC3B,MAAMC,EAAWT,EAAY,CAC3B,GAAGQ,EACH,KAAAH,EACA,aAAcC,CAChB,CAAC,EACK,CAAE,kBAAAI,EAAmB,iBAAAC,CAAiB,EAAIV,EAAgB,CAK9DC,EAAQO,EAAS,QAAS,CAAE,KAAM,QAAS,CAAC,EAC5CV,EAAWU,EAAS,QAAS,CAC3B,QAAS,CAACF,CACZ,CAAC,CACH,CAAC,EACD,MAAO,CACL,GAAGE,EACH,kBAAAC,EACA,iBAAAC,CACF,CACF,EACA,CAACN,EAAMC,EAASC,CAAgB,CAClC",
|
|
6
|
+
"names": ["useDismiss", "useFloating", "useInteractions", "useRole", "useCallback", "useFloatingContext", "open", "setOpen", "breakpointActive", "props", "floating", "getReferenceProps", "getFloatingProps"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
const useFloatingContext = () => useCallback(() => {
|
|
3
|
-
}, []);
|
|
4
|
-
export {
|
|
5
|
-
useFloatingContext
|
|
6
|
-
};
|
|
1
|
+
import{useCallback as t}from"react";const a=()=>t(()=>{},[]);export{a as useFloatingContext};
|
|
7
2
|
//# sourceMappingURL=useFloatingContext.native.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/useFloatingContext.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import React, { useCallback } from 'react'\n\n// Avoid bundling react-dom into native: https://github.com/tamagui/tamagui/issues/688\nexport const useFloatingContext = () => useCallback(() => {}, [])\n"],
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "AAAA,OAAgB,eAAAA,MAAmB,QAG5B,MAAMC,EAAqB,IAAMD,EAAY,IAAM,CAAC,EAAG,CAAC,CAAC",
|
|
6
|
+
"names": ["useCallback", "useFloatingContext"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
const useFloatingContext = () => useCallback(() => {
|
|
3
|
-
}, []);
|
|
4
|
-
export {
|
|
5
|
-
useFloatingContext
|
|
6
|
-
};
|
|
1
|
+
import{useCallback as t}from"react";const a=()=>t(()=>{},[]);export{a as useFloatingContext};
|
|
7
2
|
//# sourceMappingURL=useFloatingContext.native.mjs.map
|