@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/cjs/Popover.js
CHANGED
|
@@ -1,385 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var Popover_exports = {};
|
|
30
|
-
__export(Popover_exports, {
|
|
31
|
-
Popover: () => Popover,
|
|
32
|
-
PopoverAnchor: () => PopoverAnchor,
|
|
33
|
-
PopoverArrow: () => PopoverArrow,
|
|
34
|
-
PopoverClose: () => PopoverClose,
|
|
35
|
-
PopoverContent: () => PopoverContent,
|
|
36
|
-
PopoverTrigger: () => PopoverTrigger,
|
|
37
|
-
__PopoverProviderInternal: () => __PopoverProviderInternal,
|
|
38
|
-
createPopoverScope: () => createPopoverScope,
|
|
39
|
-
usePopoverScope: () => usePopoverScope
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(Popover_exports);
|
|
42
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
-
var import_polyfill_dev = require("@tamagui/polyfill-dev");
|
|
44
|
-
var import_adapt = require("@tamagui/adapt");
|
|
45
|
-
var import_animate_presence = require("@tamagui/animate-presence");
|
|
46
|
-
var import_aria_hidden = require("@tamagui/aria-hidden");
|
|
47
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
48
|
-
var import_core = require("@tamagui/core");
|
|
49
|
-
var import_create_context = require("@tamagui/create-context");
|
|
50
|
-
var import_floating = require("@tamagui/floating");
|
|
51
|
-
var import_focus_scope = require("@tamagui/focus-scope");
|
|
52
|
-
var import_popper = require("@tamagui/popper");
|
|
53
|
-
var import_portal = require("@tamagui/portal");
|
|
54
|
-
var import_remove_scroll = require("@tamagui/remove-scroll");
|
|
55
|
-
var import_sheet = require("@tamagui/sheet");
|
|
56
|
-
var import_stacks = require("@tamagui/stacks");
|
|
57
|
-
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
58
|
-
var React = __toESM(require("react"));
|
|
59
|
-
var import_react_native = require("react-native");
|
|
60
|
-
var import_useFloatingContext = require("./useFloatingContext");
|
|
61
|
-
const POPOVER_NAME = "Popover";
|
|
62
|
-
const [createPopoverContext, createPopoverScopeInternal] = (0, import_create_context.createContextScope)(
|
|
63
|
-
POPOVER_NAME,
|
|
64
|
-
[import_popper.createPopperScope]
|
|
65
|
-
);
|
|
66
|
-
const usePopoverScope = (0, import_popper.createPopperScope)();
|
|
67
|
-
const createPopoverScope = createPopoverScopeInternal;
|
|
68
|
-
const [PopoverProviderInternal, usePopoverInternalContext] = createPopoverContext(POPOVER_NAME);
|
|
69
|
-
const __PopoverProviderInternal = PopoverProviderInternal;
|
|
70
|
-
const ANCHOR_NAME = "PopoverAnchor";
|
|
71
|
-
const PopoverAnchor = React.forwardRef(
|
|
72
|
-
(props, forwardedRef) => {
|
|
73
|
-
const { __scopePopover, ...anchorProps } = props;
|
|
74
|
-
const context = usePopoverInternalContext(ANCHOR_NAME, __scopePopover);
|
|
75
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
76
|
-
const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
|
|
77
|
-
React.useEffect(() => {
|
|
78
|
-
onCustomAnchorAdd();
|
|
79
|
-
return () => onCustomAnchorRemove();
|
|
80
|
-
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
|
|
81
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, { ...popperScope, ...anchorProps, ref: forwardedRef });
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
PopoverAnchor.displayName = ANCHOR_NAME;
|
|
85
|
-
const TRIGGER_NAME = "PopoverTrigger";
|
|
86
|
-
const PopoverTrigger = React.forwardRef((props, forwardedRef) => {
|
|
87
|
-
const { __scopePopover, ...triggerProps } = props;
|
|
88
|
-
const context = usePopoverInternalContext(TRIGGER_NAME, __scopePopover);
|
|
89
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
90
|
-
const composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
91
|
-
const trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
|
-
import_stacks.YStack,
|
|
93
|
-
{
|
|
94
|
-
"aria-haspopup": "dialog",
|
|
95
|
-
"aria-expanded": context.open,
|
|
96
|
-
"data-state": getState(context.open),
|
|
97
|
-
...triggerProps,
|
|
98
|
-
ref: composedTriggerRef,
|
|
99
|
-
onPress: (0, import_core.composeEventHandlers)(props.onPress, context.onOpenToggle)
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, { asChild: true, ...popperScope, children: trigger });
|
|
103
|
-
});
|
|
104
|
-
PopoverTrigger.displayName = TRIGGER_NAME;
|
|
105
|
-
const CONTENT_NAME = "PopoverContent";
|
|
106
|
-
const PopoverContent = import_popper.PopperContentFrame.extractable(
|
|
107
|
-
React.forwardRef(
|
|
108
|
-
function PopoverContent2(props, forwardedRef) {
|
|
109
|
-
const {
|
|
110
|
-
allowPinchZoom,
|
|
111
|
-
trapFocus,
|
|
112
|
-
disableRemoveScroll = true,
|
|
113
|
-
zIndex,
|
|
114
|
-
...contentImplProps
|
|
115
|
-
} = props;
|
|
116
|
-
const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover);
|
|
117
|
-
const contentRef = React.useRef(null);
|
|
118
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
119
|
-
const isRightClickOutsideRef = React.useRef(false);
|
|
120
|
-
React.useEffect(() => {
|
|
121
|
-
if (!context.open)
|
|
122
|
-
return;
|
|
123
|
-
const content = contentRef.current;
|
|
124
|
-
if (content)
|
|
125
|
-
return (0, import_aria_hidden.hideOthers)(content);
|
|
126
|
-
}, [context.open]);
|
|
127
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentPortal, { zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
128
|
-
PopoverContentImpl,
|
|
129
|
-
{
|
|
130
|
-
...contentImplProps,
|
|
131
|
-
disableRemoveScroll,
|
|
132
|
-
ref: composedRefs,
|
|
133
|
-
trapFocus: trapFocus ?? context.open,
|
|
134
|
-
disableOutsidePointerEvents: true,
|
|
135
|
-
onCloseAutoFocus: (0, import_core.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
|
|
136
|
-
var _a;
|
|
137
|
-
event.preventDefault();
|
|
138
|
-
if (!isRightClickOutsideRef.current)
|
|
139
|
-
(_a = context.triggerRef.current) == null ? void 0 : _a.focus();
|
|
140
|
-
}),
|
|
141
|
-
onPointerDownOutside: (0, import_core.composeEventHandlers)(
|
|
142
|
-
props.onPointerDownOutside,
|
|
143
|
-
(event) => {
|
|
144
|
-
const originalEvent = event.detail.originalEvent;
|
|
145
|
-
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
146
|
-
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
147
|
-
isRightClickOutsideRef.current = isRightClick;
|
|
148
|
-
},
|
|
149
|
-
{ checkDefaultPrevented: false }
|
|
150
|
-
),
|
|
151
|
-
onFocusOutside: (0, import_core.composeEventHandlers)(
|
|
152
|
-
props.onFocusOutside,
|
|
153
|
-
(event) => event.preventDefault(),
|
|
154
|
-
{ checkDefaultPrevented: false }
|
|
155
|
-
)
|
|
156
|
-
}
|
|
157
|
-
) });
|
|
158
|
-
}
|
|
159
|
-
)
|
|
160
|
-
);
|
|
161
|
-
function PopoverContentPortal(props) {
|
|
162
|
-
const themeName = (0, import_core.useThemeName)();
|
|
163
|
-
const context = usePopoverInternalContext(CONTENT_NAME, props.__scopePopover);
|
|
164
|
-
let contents = props.children;
|
|
165
|
-
if (import_react_native.Platform.OS === "android") {
|
|
166
|
-
const popperContext = (0, import_popper.usePopperContext)(CONTENT_NAME, context.popperScope);
|
|
167
|
-
contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperProvider, { ...popperContext, scope: context.popperScope, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverProviderInternal, { scope: props.__scopePopover, ...context, children: props.children }) });
|
|
168
|
-
}
|
|
169
|
-
const zIndex = props.zIndex ?? 1e3;
|
|
170
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Theme, { forceClassName: true, name: themeName, children: [
|
|
171
|
-
!!context.open && !context.breakpointActive && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
172
|
-
import_stacks.YStack,
|
|
173
|
-
{
|
|
174
|
-
fullscreen: true,
|
|
175
|
-
onPress: (0, import_core.composeEventHandlers)(props.onPress, context.onOpenToggle)
|
|
176
|
-
}
|
|
177
|
-
),
|
|
178
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Stack, { zIndex: zIndex + 1, children: contents })
|
|
179
|
-
] }) });
|
|
180
|
-
}
|
|
181
|
-
const PopoverContentImpl = React.forwardRef((props, forwardedRef) => {
|
|
182
|
-
const {
|
|
183
|
-
__scopePopover,
|
|
184
|
-
trapFocus,
|
|
185
|
-
onOpenAutoFocus,
|
|
186
|
-
onCloseAutoFocus,
|
|
187
|
-
disableOutsidePointerEvents,
|
|
188
|
-
onEscapeKeyDown,
|
|
189
|
-
onPointerDownOutside,
|
|
190
|
-
onFocusOutside,
|
|
191
|
-
onInteractOutside,
|
|
192
|
-
children,
|
|
193
|
-
disableRemoveScroll,
|
|
194
|
-
...contentProps
|
|
195
|
-
} = props;
|
|
196
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
197
|
-
const context = usePopoverInternalContext(CONTENT_NAME, popperScope.__scopePopover);
|
|
198
|
-
if (context.breakpointActive) {
|
|
199
|
-
const childrenWithoutScrollView = React.Children.toArray(children).map((child) => {
|
|
200
|
-
if (React.isValidElement(child)) {
|
|
201
|
-
if (child.type === PopoverScrollView) {
|
|
202
|
-
return child.props.children;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return child;
|
|
206
|
-
});
|
|
207
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: `${context.scopeKey}PopoverContents`, children: childrenWithoutScrollView });
|
|
208
|
-
}
|
|
209
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, { children: !!context.open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
210
|
-
import_popper.PopperContent,
|
|
211
|
-
{
|
|
212
|
-
"data-state": getState(context.open),
|
|
213
|
-
id: context.contentId,
|
|
214
|
-
pointerEvents: "auto",
|
|
215
|
-
ref: forwardedRef,
|
|
216
|
-
...popperScope,
|
|
217
|
-
...contentProps,
|
|
218
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
219
|
-
import_remove_scroll.RemoveScroll,
|
|
220
|
-
{
|
|
221
|
-
enabled: disableRemoveScroll ? false : context.open,
|
|
222
|
-
allowPinchZoom: true,
|
|
223
|
-
removeScrollBar: false,
|
|
224
|
-
style: {
|
|
225
|
-
display: "contents"
|
|
226
|
-
},
|
|
227
|
-
children: trapFocus === false ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
228
|
-
import_focus_scope.FocusScope,
|
|
229
|
-
{
|
|
230
|
-
loop: true,
|
|
231
|
-
trapped: trapFocus ?? context.open,
|
|
232
|
-
onMountAutoFocus: onOpenAutoFocus,
|
|
233
|
-
onUnmountAutoFocus: onCloseAutoFocus,
|
|
234
|
-
children: import_core.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "contents" }, children }) : children
|
|
235
|
-
}
|
|
236
|
-
)
|
|
237
|
-
}
|
|
238
|
-
)
|
|
239
|
-
},
|
|
240
|
-
context.contentId
|
|
241
|
-
) });
|
|
242
|
-
});
|
|
243
|
-
const CLOSE_NAME = "PopoverClose";
|
|
244
|
-
const PopoverClose = React.forwardRef(
|
|
245
|
-
(props, forwardedRef) => {
|
|
246
|
-
const { __scopePopover, ...closeProps } = props;
|
|
247
|
-
const context = usePopoverInternalContext(CLOSE_NAME, __scopePopover);
|
|
248
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
249
|
-
import_stacks.YStack,
|
|
250
|
-
{
|
|
251
|
-
...closeProps,
|
|
252
|
-
ref: forwardedRef,
|
|
253
|
-
onPress: (0, import_core.composeEventHandlers)(
|
|
254
|
-
props.onPress,
|
|
255
|
-
() => context.onOpenChange(false)
|
|
256
|
-
)
|
|
257
|
-
}
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
);
|
|
261
|
-
PopoverClose.displayName = CLOSE_NAME;
|
|
262
|
-
const ARROW_NAME = "PopoverArrow";
|
|
263
|
-
const PopoverArrow = React.forwardRef(
|
|
264
|
-
(props, forwardedRef) => {
|
|
265
|
-
const { __scopePopover, ...arrowProps } = props;
|
|
266
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
267
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperArrow, { ...popperScope, ...arrowProps, ref: forwardedRef });
|
|
268
|
-
}
|
|
269
|
-
);
|
|
270
|
-
PopoverArrow.displayName = ARROW_NAME;
|
|
271
|
-
const PopoverScrollView = React.forwardRef((props, ref) => {
|
|
272
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.ScrollView, { ref, ...props });
|
|
273
|
-
});
|
|
274
|
-
const Popover = (0, import_core.withStaticProperties)(
|
|
275
|
-
function Popover2(props) {
|
|
276
|
-
const {
|
|
277
|
-
__scopePopover,
|
|
278
|
-
children,
|
|
279
|
-
open: openProp,
|
|
280
|
-
defaultOpen,
|
|
281
|
-
onOpenChange,
|
|
282
|
-
...restProps
|
|
283
|
-
} = props;
|
|
284
|
-
const internalId = (0, import_core.useId)();
|
|
285
|
-
const id = __scopePopover ? Object.keys(__scopePopover)[0] : internalId;
|
|
286
|
-
const { when, AdaptProvider } = (0, import_adapt.useAdaptParent)({
|
|
287
|
-
Contents: React.useCallback(() => {
|
|
288
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, { name: `${id}PopoverContents` });
|
|
289
|
-
}, [])
|
|
290
|
-
});
|
|
291
|
-
const sheetBreakpoint = when;
|
|
292
|
-
const popperScope = usePopoverScope(__scopePopover);
|
|
293
|
-
const triggerRef = React.useRef(null);
|
|
294
|
-
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
295
|
-
const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
296
|
-
prop: openProp,
|
|
297
|
-
defaultProp: defaultOpen || false,
|
|
298
|
-
onChange: onOpenChange,
|
|
299
|
-
transition: true
|
|
300
|
-
});
|
|
301
|
-
const breakpointActive = useSheetBreakpointActive(sheetBreakpoint);
|
|
302
|
-
const floatingContext = (0, import_useFloatingContext.useFloatingContext)({ open, setOpen, breakpointActive });
|
|
303
|
-
const popoverContext = {
|
|
304
|
-
scope: __scopePopover,
|
|
305
|
-
scopeKey: id,
|
|
306
|
-
popperScope: popperScope.__scopePopper,
|
|
307
|
-
sheetBreakpoint,
|
|
308
|
-
contentId: (0, import_core.useId)(),
|
|
309
|
-
triggerRef,
|
|
310
|
-
open,
|
|
311
|
-
breakpointActive,
|
|
312
|
-
onOpenChange: setOpen,
|
|
313
|
-
onOpenToggle: (0, import_core.useEvent)(() => {
|
|
314
|
-
if (open && breakpointActive) {
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
setOpen(!open);
|
|
318
|
-
}),
|
|
319
|
-
hasCustomAnchor,
|
|
320
|
-
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(true), []),
|
|
321
|
-
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(false), [])
|
|
322
|
-
};
|
|
323
|
-
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.Popper, { ...popperScope, stayInFrame: true, ...restProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverProviderInternal, { ...popoverContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverSheetController, { onOpenChange: setOpen, __scopePopover, children }) }) });
|
|
324
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdaptProvider, { children: import_core.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_floating.FloatingOverrideContext.Provider, { value: floatingContext, children: contents }) : contents });
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
Anchor: PopoverAnchor,
|
|
328
|
-
Arrow: PopoverArrow,
|
|
329
|
-
Trigger: PopoverTrigger,
|
|
330
|
-
Content: PopoverContent,
|
|
331
|
-
Close: PopoverClose,
|
|
332
|
-
Adapt: import_adapt.Adapt,
|
|
333
|
-
ScrollView: PopoverScrollView,
|
|
334
|
-
Sheet: import_sheet.ControlledSheet
|
|
335
|
-
}
|
|
336
|
-
);
|
|
337
|
-
function getState(open) {
|
|
338
|
-
return open ? "open" : "closed";
|
|
339
|
-
}
|
|
340
|
-
const PopoverSheetController = (props) => {
|
|
341
|
-
const context = usePopoverInternalContext(
|
|
342
|
-
"PopoverSheetController",
|
|
343
|
-
props.__scopePopover
|
|
344
|
-
);
|
|
345
|
-
const showSheet = useShowPopoverSheet(context);
|
|
346
|
-
const breakpointActive = context.breakpointActive;
|
|
347
|
-
const getShowSheet = (0, import_core.useGet)(showSheet);
|
|
348
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
349
|
-
import_sheet.SheetController,
|
|
350
|
-
{
|
|
351
|
-
onOpenChange: (val) => {
|
|
352
|
-
if (getShowSheet()) {
|
|
353
|
-
props.onOpenChange(val);
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
open: context.open,
|
|
357
|
-
hidden: breakpointActive === false,
|
|
358
|
-
children: props.children
|
|
359
|
-
}
|
|
360
|
-
);
|
|
361
|
-
};
|
|
362
|
-
const useSheetBreakpointActive = (breakpoint) => {
|
|
363
|
-
const media = (0, import_core.useMedia)();
|
|
364
|
-
if (typeof breakpoint === "boolean" || !breakpoint) {
|
|
365
|
-
return !!breakpoint;
|
|
366
|
-
}
|
|
367
|
-
return media[breakpoint];
|
|
368
|
-
};
|
|
369
|
-
const useShowPopoverSheet = (context) => {
|
|
370
|
-
const breakpointActive = useSheetBreakpointActive(context.sheetBreakpoint);
|
|
371
|
-
return context.open === false ? false : breakpointActive;
|
|
372
|
-
};
|
|
373
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
374
|
-
0 && (module.exports = {
|
|
375
|
-
Popover,
|
|
376
|
-
PopoverAnchor,
|
|
377
|
-
PopoverArrow,
|
|
378
|
-
PopoverClose,
|
|
379
|
-
PopoverContent,
|
|
380
|
-
PopoverTrigger,
|
|
381
|
-
__PopoverProviderInternal,
|
|
382
|
-
createPopoverScope,
|
|
383
|
-
usePopoverScope
|
|
384
|
-
});
|
|
1
|
+
"use strict";var po=Object.create;var O=Object.defineProperty;var so=Object.getOwnPropertyDescriptor;var co=Object.getOwnPropertyNames;var ao=Object.getPrototypeOf,lo=Object.prototype.hasOwnProperty;var Po=(o,e)=>{for(var t in e)O(o,t,{get:e[t],enumerable:!0})},K=(o,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of co(e))!lo.call(o,n)&&n!==t&&O(o,n,{get:()=>e[n],enumerable:!(s=so(e,n))||s.enumerable});return o};var io=(o,e,t)=>(t=o!=null?po(ao(o)):{},K(e||!o||!o.__esModule?O(t,"default",{value:o,enumerable:!0}):t,o)),uo=o=>K(O({},"__esModule",{value:!0}),o);var Ro={};Po(Ro,{Popover:()=>Ao,PopoverAnchor:()=>V,PopoverArrow:()=>z,PopoverClose:()=>D,PopoverContent:()=>to,PopoverTrigger:()=>M,__PopoverProviderInternal:()=>Co,createPopoverScope:()=>fo,usePopoverScope:()=>A});module.exports=uo(Ro);var r=require("react/jsx-runtime"),Oo=require("@tamagui/polyfill-dev"),_=require("@tamagui/adapt"),U=require("@tamagui/animate-presence"),$=require("@tamagui/aria-hidden"),N=require("@tamagui/compose-refs"),p=require("@tamagui/core"),j=require("@tamagui/create-context"),q=require("@tamagui/floating"),J=require("@tamagui/focus-scope"),a=require("@tamagui/popper"),y=require("@tamagui/portal"),X=require("@tamagui/remove-scroll"),T=require("@tamagui/sheet"),b=require("@tamagui/stacks"),oo=require("@tamagui/use-controllable-state"),c=io(require("react")),I=require("react-native"),eo=require("./useFloatingContext");const L="Popover",[vo,mo]=(0,j.createContextScope)(L,[a.createPopperScope]),A=(0,a.createPopperScope)(),fo=mo,[F,h]=vo(L),Co=F,B="PopoverAnchor",V=c.forwardRef((o,e)=>{const{__scopePopover:t,...s}=o,n=h(B,t),l=A(t),{onCustomAnchorAdd:m,onCustomAnchorRemove:v}=n;return c.useEffect(()=>(m(),()=>v()),[m,v]),(0,r.jsx)(a.PopperAnchor,{...l,...s,ref:e})});V.displayName=B;const W="PopoverTrigger",M=c.forwardRef((o,e)=>{const{__scopePopover:t,...s}=o,n=h(W,t),l=A(t),m=(0,N.useComposedRefs)(e,n.triggerRef),v=(0,r.jsx)(b.YStack,{"aria-haspopup":"dialog","aria-expanded":n.open,"data-state":G(n.open),...s,ref:m,onPress:(0,p.composeEventHandlers)(o.onPress,n.onOpenToggle)});return n.hasCustomAnchor?v:(0,r.jsx)(a.PopperAnchor,{asChild:!0,...l,children:v})});M.displayName=W;const E="PopoverContent",to=a.PopperContentFrame.extractable(c.forwardRef(function(e,t){const{allowPinchZoom:s,trapFocus:n,disableRemoveScroll:l=!0,zIndex:m,...v}=e,C=h(E,e.__scopePopover),S=c.useRef(null),w=(0,N.useComposedRefs)(t,S),d=c.useRef(!1);return c.useEffect(()=>{if(!C.open)return;const P=S.current;if(P)return(0,$.hideOthers)(P)},[C.open]),(0,r.jsx)(ho,{zIndex:m,children:(0,r.jsx)(So,{...v,disableRemoveScroll:l,ref:w,trapFocus:n??C.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,p.composeEventHandlers)(e.onCloseAutoFocus,P=>{var u;P.preventDefault(),d.current||(u=C.triggerRef.current)==null||u.focus()}),onPointerDownOutside:(0,p.composeEventHandlers)(e.onPointerDownOutside,P=>{const u=P.detail.originalEvent,g=u.button===0&&u.ctrlKey===!0,i=u.button===2||g;d.current=i},{checkDefaultPrevented:!1}),onFocusOutside:(0,p.composeEventHandlers)(e.onFocusOutside,P=>P.preventDefault(),{checkDefaultPrevented:!1})})})}));function ho(o){const e=(0,p.useThemeName)(),t=h(E,o.__scopePopover);let s=o.children;if(I.Platform.OS==="android"){const l=(0,a.usePopperContext)(E,t.popperScope);s=(0,r.jsx)(a.PopperProvider,{...l,scope:t.popperScope,children:(0,r.jsx)(F,{scope:o.__scopePopover,...t,children:o.children})})}const n=o.zIndex??1e3;return(0,r.jsx)(y.Portal,{zIndex:n,children:(0,r.jsxs)(p.Theme,{forceClassName:!0,name:e,children:[!!t.open&&!t.breakpointActive&&(0,r.jsx)(b.YStack,{fullscreen:!0,onPress:(0,p.composeEventHandlers)(o.onPress,t.onOpenToggle)}),(0,r.jsx)(p.Stack,{zIndex:n+1,children:s})]})})}const So=c.forwardRef((o,e)=>{const{__scopePopover:t,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:l,disableOutsidePointerEvents:m,onEscapeKeyDown:v,onPointerDownOutside:C,onFocusOutside:S,onInteractOutside:w,children:d,disableRemoveScroll:P,...u}=o,g=A(t),i=h(E,g.__scopePopover);if(i.breakpointActive){const R=c.Children.toArray(d).map(f=>c.isValidElement(f)&&f.type===Z?f.props.children:f);return(0,r.jsx)(y.PortalItem,{hostName:`${i.scopeKey}PopoverContents`,children:R})}return(0,r.jsx)(U.AnimatePresence,{children:!!i.open&&(0,r.jsx)(a.PopperContent,{"data-state":G(i.open),id:i.contentId,pointerEvents:"auto",ref:e,...g,...u,children:(0,r.jsx)(X.RemoveScroll,{enabled:P?!1:i.open,allowPinchZoom:!0,removeScrollBar:!1,style:{display:"contents"},children:s===!1?d:(0,r.jsx)(J.FocusScope,{loop:!0,trapped:s??i.open,onMountAutoFocus:n,onUnmountAutoFocus:l,children:p.isWeb?(0,r.jsx)("div",{style:{display:"contents"},children:d}):d})})},i.contentId)})}),Y="PopoverClose",D=c.forwardRef((o,e)=>{const{__scopePopover:t,...s}=o,n=h(Y,t);return(0,r.jsx)(b.YStack,{...s,ref:e,onPress:(0,p.composeEventHandlers)(o.onPress,()=>n.onOpenChange(!1))})});D.displayName=Y;const go="PopoverArrow",z=c.forwardRef((o,e)=>{const{__scopePopover:t,...s}=o,n=A(t);return(0,r.jsx)(a.PopperArrow,{...n,...s,ref:e})});z.displayName=go;const Z=c.forwardRef((o,e)=>(0,r.jsx)(I.ScrollView,{ref:e,...o})),Ao=(0,p.withStaticProperties)(function(e){const{__scopePopover:t,children:s,open:n,defaultOpen:l,onOpenChange:m,...v}=e,C=(0,p.useId)(),S=t?Object.keys(t)[0]:C,{when:w,AdaptProvider:d}=(0,_.useAdaptParent)({Contents:c.useCallback(()=>(0,r.jsx)(y.PortalHost,{name:`${S}PopoverContents`}),[])}),P=w,u=A(t),g=c.useRef(null),[i,R]=c.useState(!1),[f,x]=(0,oo.useControllableState)({prop:n,defaultProp:l||!1,onChange:m,transition:!0}),k=Q(P),ro=(0,eo.useFloatingContext)({open:f,setOpen:x,breakpointActive:k}),no={scope:t,scopeKey:S,popperScope:u.__scopePopper,sheetBreakpoint:P,contentId:(0,p.useId)(),triggerRef:g,open:f,breakpointActive:k,onOpenChange:x,onOpenToggle:(0,p.useEvent)(()=>{f&&k||x(!f)}),hasCustomAnchor:i,onCustomAnchorAdd:c.useCallback(()=>R(!0),[]),onCustomAnchorRemove:c.useCallback(()=>R(!1),[])},H=(0,r.jsx)(a.Popper,{...u,stayInFrame:!0,...v,children:(0,r.jsx)(F,{...no,children:(0,r.jsx)(yo,{onOpenChange:x,__scopePopover:t,children:s})})});return(0,r.jsx)(d,{children:p.isWeb?(0,r.jsx)(q.FloatingOverrideContext.Provider,{value:ro,children:H}):H})},{Anchor:V,Arrow:z,Trigger:M,Content:to,Close:D,Adapt:_.Adapt,ScrollView:Z,Sheet:T.ControlledSheet});function G(o){return o?"open":"closed"}const yo=o=>{const e=h("PopoverSheetController",o.__scopePopover),t=wo(e),s=e.breakpointActive,n=(0,p.useGet)(t);return(0,r.jsx)(T.SheetController,{onOpenChange:l=>{n()&&o.onOpenChange(l)},open:e.open,hidden:s===!1,children:o.children})},Q=o=>{const e=(0,p.useMedia)();return typeof o=="boolean"||!o?!!o:e[o]},wo=o=>{const e=Q(o.sheetBreakpoint);return o.open===!1?!1:e};0&&(module.exports={Popover,PopoverAnchor,PopoverArrow,PopoverClose,PopoverContent,PopoverTrigger,__PopoverProviderInternal,createPopoverScope,usePopoverScope});
|
|
385
2
|
//# sourceMappingURL=Popover.js.map
|
package/dist/cjs/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 { 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": "
|
|
6
|
-
"names": ["
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,aAAAE,GAAA,kBAAAC,EAAA,iBAAAC,EAAA,iBAAAC,EAAA,mBAAAC,GAAA,mBAAAC,EAAA,8BAAAC,GAAA,uBAAAC,GAAA,oBAAAC,IAAA,eAAAC,GAAAX,IA8GW,IAAAY,EAAA,6BA5GXC,GAAO,iCAEPC,EAAsC,0BACtCC,EAAgC,qCAChCC,EAA2B,gCAC3BC,EAAgC,iCAChCC,EAcO,yBAEPC,EAAmC,mCAEnCC,EAAwC,6BACxCC,EAA4C,gCAC5CC,EAYO,2BACPC,EAA+C,2BAC/CC,EAAgD,kCAChDC,EAAiD,0BACjDC,EAAoC,2BACpCC,GAAqC,2CACrCC,EAAuB,qBACvBC,EAA4D,wBAE5DC,GAAmC,gCAEnC,MAAMC,EAAe,UA0Bf,CAACC,GAAsBC,EAA0B,KAAI,sBACzDF,EACA,CAAC,mBAAiB,CACpB,EACarB,KAAkB,qBAAkB,EACpCD,GAAqBwB,GAE5B,CAACC,EAAyBC,CAAyB,EACvDH,GAA0CD,CAAY,EAE3CvB,GAA4B0B,EAMnCE,EAAc,gBAKPjC,EAAgByB,EAAM,WACjC,CAACS,EAAwCC,IAAiB,CACxD,KAAM,CAAE,eAAAC,EAAgB,GAAGC,CAAY,EAAIH,EACrCI,EAAUN,EAA0BC,EAAaG,CAAc,EAC/DG,EAAchC,EAAgB6B,CAAc,EAC5C,CAAE,kBAAAI,EAAmB,qBAAAC,CAAqB,EAAIH,EAEpD,OAAAb,EAAM,UAAU,KACde,EAAkB,EACX,IAA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WAAa,CAACA,EAC/B,CAAC,CAACA,EAEJC,EAAMD,CAAU,CACzB,EAEMH,GAAuBlE,GAAiC,CAC5D,MAAM4D,EAAmBC,EAAyB7D,EAAQ,eAAe,EACzE,OAAOA,EAAQ,OAAS,GAAQ,GAAQ4D,CAC1C",
|
|
6
|
+
"names": ["Popover_exports", "__export", "Popover", "PopoverAnchor", "PopoverArrow", "PopoverClose", "PopoverContent", "PopoverTrigger", "__PopoverProviderInternal", "createPopoverScope", "usePopoverScope", "__toCommonJS", "import_jsx_runtime", "import_polyfill_dev", "import_adapt", "import_animate_presence", "import_aria_hidden", "import_compose_refs", "import_core", "import_create_context", "import_floating", "import_focus_scope", "import_popper", "import_portal", "import_remove_scroll", "import_sheet", "import_stacks", "import_use_controllable_state", "React", "import_react_native", "import_useFloatingContext", "POPOVER_NAME", "createPopoverContext", "createPopoverScopeInternal", "PopoverProviderInternal", "usePopoverInternalContext", "ANCHOR_NAME", "props", "forwardedRef", "__scopePopover", "anchorProps", "context", "popperScope", "onCustomAnchorAdd", "onCustomAnchorRemove", "TRIGGER_NAME", "triggerProps", "composedTriggerRef", "trigger", "getState", "CONTENT_NAME", "allowPinchZoom", "trapFocus", "disableRemoveScroll", "zIndex", "contentImplProps", "contentRef", "composedRefs", "isRightClickOutsideRef", "content", "PopoverContentPortal", "PopoverContentImpl", "event", "_a", "originalEvent", "ctrlLeftClick", "isRightClick", "themeName", "contents", "popperContext", "onOpenAutoFocus", "onCloseAutoFocus", "disableOutsidePointerEvents", "onEscapeKeyDown", "onPointerDownOutside", "onFocusOutside", "onInteractOutside", "children", "contentProps", "childrenWithoutScrollView", "child", "PopoverScrollView", "CLOSE_NAME", "closeProps", "ARROW_NAME", "arrowProps", "ref", "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/cjs/index.js
CHANGED
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var src_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(src_exports);
|
|
18
|
-
__reExport(src_exports, require("./Popover"), module.exports);
|
|
19
|
-
__reExport(src_exports, require("./useFloatingContext"), module.exports);
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(r,m)&&m!==p&&a(r,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return r},f=(r,o,p)=>(t(r,o,"default"),p&&t(p,o,"default"));var g=r=>t(a({},"__esModule",{value:!0}),r);var e={};module.exports=g(e);f(e,require("./Popover"),module.exports);f(e,require("./useFloatingContext"),module.exports);
|
|
20
2
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["export * from './Popover'\nexport * from './useFloatingContext'\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
5
|
+
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,qBAAd,gBACAE,EAAAF,EAAc,gCADd",
|
|
6
|
+
"names": ["src_exports", "__toCommonJS", "__reExport"]
|
|
7
7
|
}
|
|
@@ -1,55 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var useFloatingContext_exports = {};
|
|
20
|
-
__export(useFloatingContext_exports, {
|
|
21
|
-
useFloatingContext: () => useFloatingContext
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(useFloatingContext_exports);
|
|
24
|
-
var import_react = require("@floating-ui/react");
|
|
25
|
-
var import_react2 = require("react");
|
|
26
|
-
const useFloatingContext = ({ open, setOpen, breakpointActive }) => (0, import_react2.useCallback)(
|
|
27
|
-
(props) => {
|
|
28
|
-
const floating = (0, import_react.useFloating)({
|
|
29
|
-
...props,
|
|
30
|
-
open,
|
|
31
|
-
onOpenChange: setOpen
|
|
32
|
-
});
|
|
33
|
-
const { getReferenceProps, getFloatingProps } = (0, import_react.useInteractions)([
|
|
34
|
-
// useFocus(floating.context, {
|
|
35
|
-
// enabled: !breakpointActive,
|
|
36
|
-
// keyboardOnly: true,
|
|
37
|
-
// }),
|
|
38
|
-
(0, import_react.useRole)(floating.context, { role: "dialog" }),
|
|
39
|
-
(0, import_react.useDismiss)(floating.context, {
|
|
40
|
-
enabled: !breakpointActive
|
|
41
|
-
})
|
|
42
|
-
]);
|
|
43
|
-
return {
|
|
44
|
-
...floating,
|
|
45
|
-
getReferenceProps,
|
|
46
|
-
getFloatingProps
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
[open, setOpen, breakpointActive]
|
|
50
|
-
);
|
|
51
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
-
0 && (module.exports = {
|
|
53
|
-
useFloatingContext
|
|
54
|
-
});
|
|
1
|
+
"use strict";var r=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var p=(t,o)=>{for(var s in o)r(t,s,{get:o[s],enumerable:!0})},f=(t,o,s,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of u(o))!m.call(t,e)&&e!==s&&r(t,e,{get:()=>o[e],enumerable:!(a=c(o,e))||a.enumerable});return t};var F=t=>f(r({},"__esModule",{value:!0}),t);var P={};p(P,{useFloatingContext:()=>x});module.exports=F(P);var n=require("@floating-ui/react"),i=require("react");const x=({open:t,setOpen:o,breakpointActive:s})=>(0,i.useCallback)(a=>{const e=(0,n.useFloating)({...a,open:t,onOpenChange:o}),{getReferenceProps:l,getFloatingProps:g}=(0,n.useInteractions)([(0,n.useRole)(e.context,{role:"dialog"}),(0,n.useDismiss)(e.context,{enabled:!s})]);return{...e,getReferenceProps:l,getFloatingProps:g}},[t,o,s]);0&&(module.exports={useFloatingContext});
|
|
55
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": "
|
|
6
|
-
"names": ["import_react"]
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAAkE,8BAClEA,EAAmC,iBAG5B,MAAMF,EAAqB,CAAC,CAAE,KAAAG,EAAM,QAAAC,EAAS,iBAAAC,CAAiB,OACnE,eACGC,GAA4B,CAC3B,MAAMC,KAAW,eAAY,CAC3B,GAAGD,EACH,KAAAH,EACA,aAAcC,CAChB,CAAC,EACK,CAAE,kBAAAI,EAAmB,iBAAAC,CAAiB,KAAI,mBAAgB,IAK9D,WAAQF,EAAS,QAAS,CAAE,KAAM,QAAS,CAAC,KAC5C,cAAWA,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": ["useFloatingContext_exports", "__export", "useFloatingContext", "__toCommonJS", "import_react", "open", "setOpen", "breakpointActive", "props", "floating", "getReferenceProps", "getFloatingProps"]
|
|
7
7
|
}
|