@tamagui/popover 1.130.8 → 1.131.0
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.cjs +80 -59
- package/dist/cjs/Popover.js +175 -169
- package/dist/cjs/Popover.js.map +1 -1
- package/dist/cjs/Popover.native.js +53 -40
- package/dist/cjs/Popover.native.js.map +2 -2
- package/dist/cjs/index.cjs +2 -2
- package/dist/esm/Popover.js +178 -170
- package/dist/esm/Popover.js.map +1 -1
- package/dist/esm/Popover.mjs +81 -60
- package/dist/esm/Popover.mjs.map +1 -1
- package/dist/esm/Popover.native.js +80 -56
- package/dist/esm/Popover.native.js.map +1 -1
- package/dist/jsx/Popover.js +178 -170
- package/dist/jsx/Popover.js.map +1 -1
- package/dist/jsx/Popover.mjs +81 -60
- package/dist/jsx/Popover.mjs.map +1 -1
- package/dist/jsx/Popover.native.js +55 -42
- package/dist/jsx/Popover.native.js.map +2 -2
- package/package.json +22 -22
- package/src/Popover.tsx +324 -310
- package/types/Popover.d.ts +66 -111
- package/types/Popover.d.ts.map +1 -1
package/dist/cjs/Popover.cjs
CHANGED
|
@@ -61,34 +61,35 @@ var import_polyfill_dev = require("@tamagui/polyfill-dev"),
|
|
|
61
61
|
import_use_controllable_state = require("@tamagui/use-controllable-state"),
|
|
62
62
|
import_z_index_stack = require("@tamagui/z-index-stack"),
|
|
63
63
|
React = __toESM(require("react")),
|
|
64
|
-
import_useFloatingContext = require("./useFloatingContext"),
|
|
64
|
+
import_useFloatingContext = require("./useFloatingContext.cjs"),
|
|
65
65
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
66
66
|
const needsRepropagation = import_constants.isAndroid || import_constants.isIos && !import_portal.USE_NATIVE_PORTAL,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
PopoverContext = (0, import_core.createStyledContext)(
|
|
68
|
+
// since we always provide this we can avoid setting here
|
|
69
|
+
{}, "Popover__"),
|
|
69
70
|
usePopoverContext = PopoverContext.useStyledContext,
|
|
70
71
|
PopoverAnchor = React.forwardRef(function (props, forwardedRef) {
|
|
71
72
|
const {
|
|
72
|
-
|
|
73
|
+
scope,
|
|
73
74
|
...rest
|
|
74
75
|
} = props,
|
|
75
|
-
context = usePopoverContext(
|
|
76
|
+
context = usePopoverContext(scope),
|
|
76
77
|
{
|
|
77
78
|
onCustomAnchorAdd,
|
|
78
79
|
onCustomAnchorRemove
|
|
79
80
|
} = context || {};
|
|
80
81
|
return React.useEffect(() => (onCustomAnchorAdd(), () => onCustomAnchorRemove()), [onCustomAnchorAdd, onCustomAnchorRemove]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, {
|
|
81
|
-
|
|
82
|
+
scope,
|
|
82
83
|
...rest,
|
|
83
84
|
ref: forwardedRef
|
|
84
85
|
});
|
|
85
86
|
}),
|
|
86
87
|
PopoverTrigger = React.forwardRef(function (props, forwardedRef) {
|
|
87
88
|
const {
|
|
88
|
-
|
|
89
|
+
scope,
|
|
89
90
|
...rest
|
|
90
91
|
} = props,
|
|
91
|
-
context = usePopoverContext(
|
|
92
|
+
context = usePopoverContext(scope),
|
|
92
93
|
anchorTo = context.anchorTo,
|
|
93
94
|
composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
94
95
|
if (!props.children) return null;
|
|
@@ -112,20 +113,23 @@ const needsRepropagation = import_constants.isAndroid || import_constants.isIos
|
|
|
112
113
|
...(virtualRef && {
|
|
113
114
|
virtualRef
|
|
114
115
|
}),
|
|
115
|
-
|
|
116
|
+
scope,
|
|
116
117
|
asChild: rest.asChild,
|
|
117
118
|
children: trigger
|
|
118
119
|
});
|
|
119
120
|
}),
|
|
120
|
-
|
|
121
|
+
PopoverContentFrame = (0, import_core.styled)(import_popper.PopperContentFrame, {
|
|
122
|
+
name: "Popover"
|
|
123
|
+
}),
|
|
124
|
+
PopoverContent = PopoverContentFrame.extractable(React.forwardRef(function (props, forwardedRef) {
|
|
121
125
|
const {
|
|
122
126
|
trapFocus,
|
|
123
127
|
enableRemoveScroll = !1,
|
|
124
128
|
zIndex,
|
|
125
|
-
|
|
129
|
+
scope,
|
|
126
130
|
...contentImplProps
|
|
127
131
|
} = props,
|
|
128
|
-
context = usePopoverContext(
|
|
132
|
+
context = usePopoverContext(scope),
|
|
129
133
|
contentRef = React.useRef(null),
|
|
130
134
|
composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef),
|
|
131
135
|
isRightClickOutsideRef = React.useRef(!1),
|
|
@@ -136,17 +140,18 @@ const needsRepropagation = import_constants.isAndroid || import_constants.isIos
|
|
|
136
140
|
if (content) return (0, import_aria_hidden.hideOthers)(content);
|
|
137
141
|
}, [context.open]), !context.keepChildrenMounted && isFullyHidden ? null : /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverPortal, {
|
|
138
142
|
passThrough: context.breakpointActive,
|
|
139
|
-
|
|
143
|
+
context,
|
|
140
144
|
zIndex,
|
|
141
145
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Stack, {
|
|
142
146
|
passThrough: context.breakpointActive,
|
|
143
147
|
pointerEvents: context.open ? contentImplProps.pointerEvents ?? "auto" : "none",
|
|
144
148
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverContentImpl, {
|
|
145
149
|
...contentImplProps,
|
|
150
|
+
context,
|
|
146
151
|
enableRemoveScroll,
|
|
147
152
|
ref: composedRefs,
|
|
148
153
|
setIsFullyHidden,
|
|
149
|
-
|
|
154
|
+
scope,
|
|
150
155
|
trapFocus: trapFocus ?? context.open,
|
|
151
156
|
disableOutsidePointerEvents: !0,
|
|
152
157
|
onCloseAutoFocus: props.onCloseAutoFocus === !1 ? void 0 : (0, import_helpers.composeEventHandlers)(props.onCloseAutoFocus, event => {
|
|
@@ -168,9 +173,9 @@ const needsRepropagation = import_constants.isAndroid || import_constants.isIos
|
|
|
168
173
|
});
|
|
169
174
|
})),
|
|
170
175
|
useParentContexts = scope => {
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
176
|
+
const context = usePopoverContext(scope),
|
|
177
|
+
popperContext = (0, import_popper.usePopperContext)(scope),
|
|
178
|
+
adaptContext = (0, import_adapt.useAdaptContext)(context.adaptScope);
|
|
174
179
|
return {
|
|
175
180
|
popperContext,
|
|
176
181
|
adaptContext,
|
|
@@ -181,11 +186,10 @@ function RepropagateParentContexts({
|
|
|
181
186
|
adaptContext,
|
|
182
187
|
children,
|
|
183
188
|
context,
|
|
184
|
-
popperContext
|
|
185
|
-
scope
|
|
189
|
+
popperContext
|
|
186
190
|
}) {
|
|
187
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.
|
|
188
|
-
scope,
|
|
191
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperProvider, {
|
|
192
|
+
scope: context.popoverScope,
|
|
189
193
|
...popperContext,
|
|
190
194
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverContext.Provider, {
|
|
191
195
|
...context,
|
|
@@ -198,42 +202,44 @@ function RepropagateParentContexts({
|
|
|
198
202
|
}
|
|
199
203
|
const PortalAdaptSafe = ({
|
|
200
204
|
children,
|
|
201
|
-
|
|
205
|
+
context
|
|
202
206
|
}) => {
|
|
203
207
|
if (needsRepropagation) {
|
|
204
|
-
const
|
|
205
|
-
parentContexts = useParentContexts(scope);
|
|
208
|
+
const parentContexts = useParentContexts(context.popoverScope);
|
|
206
209
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptPortalContents, {
|
|
210
|
+
scope: context.adaptScope,
|
|
207
211
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(RepropagateParentContexts, {
|
|
208
|
-
scope,
|
|
209
212
|
...parentContexts,
|
|
210
213
|
children
|
|
211
214
|
})
|
|
212
215
|
});
|
|
213
216
|
}
|
|
214
217
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptPortalContents, {
|
|
218
|
+
scope: context.adaptScope,
|
|
215
219
|
children
|
|
216
220
|
});
|
|
217
221
|
};
|
|
218
|
-
function PopoverPortal(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
222
|
+
function PopoverPortal({
|
|
223
|
+
context,
|
|
224
|
+
zIndex,
|
|
225
|
+
passThrough,
|
|
226
|
+
children
|
|
227
|
+
}) {
|
|
228
|
+
const themeName = (0, import_core.useThemeName)();
|
|
229
|
+
let content = children;
|
|
223
230
|
if (needsRepropagation) {
|
|
224
|
-
const parentContexts = useParentContexts(
|
|
231
|
+
const parentContexts = useParentContexts(context.popoverScope);
|
|
225
232
|
content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(RepropagateParentContexts, {
|
|
226
|
-
scope,
|
|
227
233
|
...parentContexts,
|
|
228
234
|
children: content
|
|
229
235
|
});
|
|
230
236
|
}
|
|
231
237
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.Portal, {
|
|
232
|
-
passThrough
|
|
238
|
+
passThrough,
|
|
233
239
|
stackZIndex: !0,
|
|
234
240
|
zIndex,
|
|
235
241
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.Theme, {
|
|
236
|
-
passThrough
|
|
242
|
+
passThrough,
|
|
237
243
|
contain: !0,
|
|
238
244
|
forceClassName: !0,
|
|
239
245
|
name: themeName,
|
|
@@ -247,7 +253,7 @@ function PopoverPortal(props) {
|
|
|
247
253
|
const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
248
254
|
const {
|
|
249
255
|
trapFocus,
|
|
250
|
-
|
|
256
|
+
scope,
|
|
251
257
|
onOpenAutoFocus,
|
|
252
258
|
onCloseAutoFocus,
|
|
253
259
|
disableOutsidePointerEvents,
|
|
@@ -261,9 +267,9 @@ const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
|
261
267
|
freezeContentsWhenHidden,
|
|
262
268
|
setIsFullyHidden,
|
|
263
269
|
lazyMount,
|
|
270
|
+
context,
|
|
264
271
|
...contentProps
|
|
265
272
|
} = props,
|
|
266
|
-
context = usePopoverContext(__scopePopover || POPOVER_SCOPE),
|
|
267
273
|
{
|
|
268
274
|
open,
|
|
269
275
|
keepChildrenMounted
|
|
@@ -296,13 +302,14 @@ const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
|
296
302
|
lazyMount,
|
|
297
303
|
passThrough: context.breakpointActive,
|
|
298
304
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperContent, {
|
|
299
|
-
|
|
305
|
+
scope,
|
|
300
306
|
"data-state": getState(open),
|
|
301
307
|
id: context.contentId,
|
|
302
308
|
ref: forwardedRef,
|
|
303
309
|
passThrough: context.breakpointActive,
|
|
304
310
|
...contentProps,
|
|
305
311
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PortalAdaptSafe, {
|
|
312
|
+
context,
|
|
306
313
|
children: contents
|
|
307
314
|
})
|
|
308
315
|
}, context.contentId)
|
|
@@ -313,10 +320,10 @@ const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
|
313
320
|
},
|
|
314
321
|
PopoverClose = React.forwardRef(function (props, forwardedRef) {
|
|
315
322
|
const {
|
|
316
|
-
|
|
323
|
+
scope,
|
|
317
324
|
...rest
|
|
318
325
|
} = props,
|
|
319
|
-
context = usePopoverContext(
|
|
326
|
+
context = usePopoverContext(scope);
|
|
320
327
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
321
328
|
...rest,
|
|
322
329
|
ref: forwardedRef,
|
|
@@ -324,20 +331,24 @@ const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
|
324
331
|
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, () => context?.onOpenChange?.(!1, "press"))
|
|
325
332
|
});
|
|
326
333
|
}),
|
|
327
|
-
PopoverArrow = import_popper.
|
|
334
|
+
PopoverArrow = import_popper.PopperArrowFrame.styleable(function (props, forwardedRef) {
|
|
328
335
|
const {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
336
|
+
scope,
|
|
337
|
+
...rest
|
|
338
|
+
} = props,
|
|
339
|
+
context = usePopoverContext(scope);
|
|
340
|
+
return (0, import_adapt.useAdaptIsActive)(context.adaptScope) ? null : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperArrow, {
|
|
341
|
+
scope,
|
|
334
342
|
componentName: "PopoverArrow",
|
|
335
343
|
...rest,
|
|
336
344
|
ref: forwardedRef
|
|
337
345
|
});
|
|
338
346
|
}),
|
|
339
|
-
PopoverScrollView = React.forwardRef((
|
|
340
|
-
|
|
347
|
+
PopoverScrollView = React.forwardRef(({
|
|
348
|
+
scope,
|
|
349
|
+
...props
|
|
350
|
+
}, ref) => {
|
|
351
|
+
const context = usePopoverContext(scope);
|
|
341
352
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_scroll_view.ScrollView, {
|
|
342
353
|
ref,
|
|
343
354
|
pointerEvents: context.breakpointActive ? "none" : void 0,
|
|
@@ -346,14 +357,21 @@ const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
|
346
357
|
...props
|
|
347
358
|
});
|
|
348
359
|
}),
|
|
349
|
-
|
|
350
|
-
|
|
360
|
+
DEFAULT_SCOPE = "",
|
|
361
|
+
Popover = (0, import_helpers.withStaticProperties)(React.forwardRef(function ({
|
|
362
|
+
scope = DEFAULT_SCOPE,
|
|
363
|
+
...props
|
|
364
|
+
}, ref) {
|
|
365
|
+
const id = React.useId(),
|
|
366
|
+
adaptScope = `PopoverAdapt${scope}`;
|
|
351
367
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptParent, {
|
|
352
|
-
scope:
|
|
368
|
+
scope: adaptScope,
|
|
353
369
|
portal: !0,
|
|
354
370
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverInner, {
|
|
371
|
+
adaptScope,
|
|
355
372
|
ref,
|
|
356
373
|
id,
|
|
374
|
+
scope,
|
|
357
375
|
...props
|
|
358
376
|
})
|
|
359
377
|
});
|
|
@@ -374,11 +392,12 @@ const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
|
374
392
|
open: openProp,
|
|
375
393
|
defaultOpen,
|
|
376
394
|
onOpenChange,
|
|
377
|
-
|
|
395
|
+
scope = DEFAULT_SCOPE,
|
|
378
396
|
keepChildrenMounted: keepChildrenMountedProp,
|
|
379
397
|
hoverable,
|
|
380
398
|
disableFocus,
|
|
381
399
|
id,
|
|
400
|
+
adaptScope,
|
|
382
401
|
...restProps
|
|
383
402
|
} = props,
|
|
384
403
|
triggerRef = React.useRef(null),
|
|
@@ -399,7 +418,7 @@ const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
|
399
418
|
handleOpenChange = (0, import_core.useEvent)((val, via) => {
|
|
400
419
|
viaRef.current = via, setOpen(val);
|
|
401
420
|
}),
|
|
402
|
-
isAdapted = (0, import_adapt.useAdaptIsActive)(),
|
|
421
|
+
isAdapted = (0, import_adapt.useAdaptIsActive)(adaptScope),
|
|
403
422
|
floatingContext = (0, import_useFloatingContext.useFloatingContext)({
|
|
404
423
|
open,
|
|
405
424
|
setOpen: handleOpenChange,
|
|
@@ -417,6 +436,8 @@ const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
|
417
436
|
setOpen
|
|
418
437
|
}));
|
|
419
438
|
const popoverContext = {
|
|
439
|
+
popoverScope: scope,
|
|
440
|
+
adaptScope,
|
|
420
441
|
id,
|
|
421
442
|
contentId: React.useId(),
|
|
422
443
|
triggerRef,
|
|
@@ -433,17 +454,18 @@ const PopoverContentImpl = React.forwardRef(function (props, forwardedRef) {
|
|
|
433
454
|
keepChildrenMounted
|
|
434
455
|
},
|
|
435
456
|
memoizedChildren = React.useMemo(() => /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverContext.Provider, {
|
|
436
|
-
scope
|
|
457
|
+
scope,
|
|
437
458
|
...popoverContext,
|
|
438
459
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverSheetController, {
|
|
460
|
+
context: popoverContext,
|
|
439
461
|
onOpenChange: setOpen,
|
|
440
462
|
children
|
|
441
463
|
})
|
|
442
|
-
}), [
|
|
464
|
+
}), [scope, setOpen, children, ...Object.values(popoverContext)]),
|
|
443
465
|
contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.Popper, {
|
|
444
466
|
open,
|
|
445
467
|
passThrough: isAdapted,
|
|
446
|
-
|
|
468
|
+
scope,
|
|
447
469
|
stayInFrame: !0,
|
|
448
470
|
...restProps,
|
|
449
471
|
children: memoizedChildren
|
|
@@ -459,11 +481,10 @@ function getState(open) {
|
|
|
459
481
|
return open ? "open" : "closed";
|
|
460
482
|
}
|
|
461
483
|
const PopoverSheetController = ({
|
|
462
|
-
|
|
484
|
+
context,
|
|
463
485
|
...props
|
|
464
486
|
}) => {
|
|
465
|
-
const
|
|
466
|
-
showSheet = useShowPopoverSheet(context),
|
|
487
|
+
const showSheet = useShowPopoverSheet(context),
|
|
467
488
|
breakpointActive = context.breakpointActive,
|
|
468
489
|
getShowSheet = (0, import_core.useGet)(showSheet);
|
|
469
490
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_sheet.SheetController, {
|
|
@@ -476,6 +497,6 @@ const PopoverSheetController = ({
|
|
|
476
497
|
});
|
|
477
498
|
},
|
|
478
499
|
useShowPopoverSheet = context => {
|
|
479
|
-
const isAdapted = (0, import_adapt.useAdaptIsActive)();
|
|
500
|
+
const isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
480
501
|
return context.open === !1 ? !1 : isAdapted;
|
|
481
502
|
};
|