@tamagui/popover 1.61.2 → 1.62.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.js +69 -176
- package/dist/cjs/Popover.js.map +2 -2
- package/dist/cjs/Popover.native.js +292 -0
- package/dist/cjs/Popover.native.js.map +6 -0
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +22 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/useFloatingContext.js +7 -13
- package/dist/cjs/useFloatingContext.js.map +1 -1
- package/dist/cjs/useFloatingContext.native.js +5 -8
- package/dist/cjs/useFloatingContext.native.js.map +1 -1
- package/dist/esm/Popover.js +62 -145
- package/dist/esm/Popover.js.map +2 -2
- package/dist/esm/useFloatingContext.js +1 -2
- package/dist/esm/useFloatingContext.js.map +1 -1
- package/dist/jsx/Popover.js +56 -137
- package/dist/jsx/Popover.js.map +2 -2
- package/dist/jsx/Popover.native.js +258 -0
- package/dist/jsx/Popover.native.js.map +6 -0
- package/dist/jsx/index.native.js +3 -0
- package/dist/jsx/index.native.js.map +6 -0
- package/dist/jsx/useFloatingContext.js +1 -2
- package/dist/jsx/useFloatingContext.js.map +1 -1
- package/package.json +18 -18
- package/types/Popover.d.ts +1 -0
- package/types/Popover.d.ts.map +1 -1
- package/dist/esm/useFloatingContext.native.js +0 -7
- package/dist/esm/useFloatingContext.native.js.map +0 -6
package/dist/cjs/Popover.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable:
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
15
|
-
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
13
|
return to;
|
|
19
14
|
};
|
|
20
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
@@ -22,10 +17,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
17
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
18
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
19
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable:
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
26
21
|
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
29
23
|
var Popover_exports = {};
|
|
30
24
|
__export(Popover_exports, {
|
|
31
25
|
Popover: () => Popover,
|
|
@@ -38,43 +32,15 @@ __export(Popover_exports, {
|
|
|
38
32
|
usePopoverContext: () => usePopoverContext
|
|
39
33
|
});
|
|
40
34
|
module.exports = __toCommonJS(Popover_exports);
|
|
41
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var import_compose_refs = require("@tamagui/compose-refs");
|
|
47
|
-
var import_core = require("@tamagui/core");
|
|
48
|
-
var import_floating = require("@tamagui/floating");
|
|
49
|
-
var import_focus_scope = require("@tamagui/focus-scope");
|
|
50
|
-
var import_popper = require("@tamagui/popper");
|
|
51
|
-
var import_portal = require("@tamagui/portal");
|
|
52
|
-
var import_remove_scroll = require("@tamagui/remove-scroll");
|
|
53
|
-
var import_sheet = require("@tamagui/sheet");
|
|
54
|
-
var import_stacks = require("@tamagui/stacks");
|
|
55
|
-
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
56
|
-
var React = __toESM(require("react"));
|
|
57
|
-
var import_react_freeze = require("react-freeze");
|
|
58
|
-
var import_react_native = require("react-native");
|
|
59
|
-
var import_useFloatingContext = require("./useFloatingContext");
|
|
60
|
-
const PopoverContext = (0, import_core.createStyledContext)({});
|
|
61
|
-
const usePopoverContext = () => React.useContext(PopoverContext);
|
|
62
|
-
const PopoverAnchor = React.forwardRef(
|
|
63
|
-
function PopoverAnchor2(props, forwardedRef) {
|
|
64
|
-
const context = usePopoverContext();
|
|
65
|
-
const { onCustomAnchorAdd, onCustomAnchorRemove } = context;
|
|
66
|
-
React.useEffect(() => {
|
|
67
|
-
onCustomAnchorAdd();
|
|
68
|
-
return () => onCustomAnchorRemove();
|
|
69
|
-
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
|
|
70
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, { ...props, ref: forwardedRef });
|
|
35
|
+
var import_polyfill_dev = require("@tamagui/polyfill-dev"), import_adapt = require("@tamagui/adapt"), import_animate = require("@tamagui/animate"), import_aria_hidden = require("@tamagui/aria-hidden"), import_compose_refs = require("@tamagui/compose-refs"), import_core = require("@tamagui/core"), import_floating = require("@tamagui/floating"), import_focus_scope = require("@tamagui/focus-scope"), import_popper = require("@tamagui/popper"), import_portal = require("@tamagui/portal"), import_remove_scroll = require("@tamagui/remove-scroll"), import_sheet = require("@tamagui/sheet"), import_stacks = require("@tamagui/stacks"), import_use_controllable_state = require("@tamagui/use-controllable-state"), React = __toESM(require("react")), import_react_freeze = require("react-freeze"), import_react_native = require("react-native"), import_useFloatingContext = require("./useFloatingContext"), import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
const PopoverContext = (0, import_core.createStyledContext)({}), usePopoverContext = () => React.useContext(PopoverContext), PopoverAnchor = React.forwardRef(
|
|
37
|
+
function(props, forwardedRef) {
|
|
38
|
+
const context = usePopoverContext(), { onCustomAnchorAdd, onCustomAnchorRemove } = context;
|
|
39
|
+
return React.useEffect(() => (onCustomAnchorAdd(), () => onCustomAnchorRemove()), [onCustomAnchorAdd, onCustomAnchorRemove]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, { ...props, ref: forwardedRef });
|
|
71
40
|
}
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const context = usePopoverContext();
|
|
76
|
-
const composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
|
|
77
|
-
const trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
+
), PopoverTrigger = React.forwardRef(
|
|
42
|
+
function(props, forwardedRef) {
|
|
43
|
+
const context = usePopoverContext(), composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef), trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
78
44
|
import_core.View,
|
|
79
45
|
{
|
|
80
46
|
"aria-haspopup": "dialog",
|
|
@@ -85,58 +51,47 @@ const PopoverTrigger = React.forwardRef(
|
|
|
85
51
|
onPress: (0, import_core.composeEventHandlers)(props.onPress, context.onOpenToggle)
|
|
86
52
|
}
|
|
87
53
|
);
|
|
88
|
-
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, { asChild:
|
|
54
|
+
return context.hasCustomAnchor ? trigger : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, { asChild: !0, children: trigger });
|
|
89
55
|
}
|
|
90
|
-
)
|
|
91
|
-
const PopoverContent = import_popper.PopperContentFrame.extractable(
|
|
56
|
+
), PopoverContent = import_popper.PopperContentFrame.extractable(
|
|
92
57
|
React.forwardRef(
|
|
93
|
-
function
|
|
58
|
+
function(props, forwardedRef) {
|
|
94
59
|
const {
|
|
95
60
|
allowPinchZoom,
|
|
96
61
|
trapFocus,
|
|
97
|
-
disableRemoveScroll =
|
|
62
|
+
disableRemoveScroll = !0,
|
|
98
63
|
zIndex,
|
|
99
64
|
...contentImplProps
|
|
100
|
-
} = props;
|
|
101
|
-
|
|
102
|
-
const contentRef = React.useRef(null);
|
|
103
|
-
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
104
|
-
const isRightClickOutsideRef = React.useRef(false);
|
|
105
|
-
React.useEffect(() => {
|
|
65
|
+
} = props, context = usePopoverContext(), contentRef = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef), isRightClickOutsideRef = React.useRef(!1);
|
|
66
|
+
return React.useEffect(() => {
|
|
106
67
|
if (!context.open)
|
|
107
68
|
return;
|
|
108
69
|
const content = contentRef.current;
|
|
109
70
|
if (content)
|
|
110
71
|
return (0, import_aria_hidden.hideOthers)(content);
|
|
111
|
-
}, [context.open])
|
|
112
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentPortal, { zIndex: props.zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Stack, { pointerEvents: context.open ? "auto" : "none", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
72
|
+
}, [context.open]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentPortal, { zIndex: props.zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Stack, { pointerEvents: context.open ? "auto" : "none", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
113
73
|
PopoverContentImpl,
|
|
114
74
|
{
|
|
115
75
|
...contentImplProps,
|
|
116
76
|
disableRemoveScroll,
|
|
117
77
|
ref: composedRefs,
|
|
118
78
|
trapFocus: trapFocus ?? context.open,
|
|
119
|
-
disableOutsidePointerEvents:
|
|
79
|
+
disableOutsidePointerEvents: !0,
|
|
120
80
|
onCloseAutoFocus: (0, import_core.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
|
|
121
|
-
|
|
122
|
-
event.preventDefault();
|
|
123
|
-
if (!isRightClickOutsideRef.current)
|
|
124
|
-
(_a = context.triggerRef.current) == null ? void 0 : _a.focus();
|
|
81
|
+
event.preventDefault(), isRightClickOutsideRef.current || context.triggerRef.current?.focus();
|
|
125
82
|
}),
|
|
126
83
|
onPointerDownOutside: (0, import_core.composeEventHandlers)(
|
|
127
84
|
props.onPointerDownOutside,
|
|
128
85
|
(event) => {
|
|
129
|
-
const originalEvent = event.detail.originalEvent;
|
|
130
|
-
const ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
131
|
-
const isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
86
|
+
const originalEvent = event.detail.originalEvent, ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0, isRightClick = originalEvent.button === 2 || ctrlLeftClick;
|
|
132
87
|
isRightClickOutsideRef.current = isRightClick;
|
|
133
88
|
},
|
|
134
|
-
{ checkDefaultPrevented:
|
|
89
|
+
{ checkDefaultPrevented: !1 }
|
|
135
90
|
),
|
|
136
91
|
onFocusOutside: (0, import_core.composeEventHandlers)(
|
|
137
92
|
props.onFocusOutside,
|
|
138
93
|
(event) => event.preventDefault(),
|
|
139
|
-
{ checkDefaultPrevented:
|
|
94
|
+
{ checkDefaultPrevented: !1 }
|
|
140
95
|
)
|
|
141
96
|
}
|
|
142
97
|
) }) });
|
|
@@ -147,26 +102,20 @@ function PopoverRepropagateContext(props) {
|
|
|
147
102
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperContext.Provider, { ...props.popperContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContext.Provider, { ...props.context, children: props.children }) });
|
|
148
103
|
}
|
|
149
104
|
function PopoverContentPortal(props) {
|
|
150
|
-
const zIndex = props.zIndex ?? 15e4;
|
|
151
|
-
const context = usePopoverContext();
|
|
152
|
-
const popperContext = (0, import_popper.usePopperContext)();
|
|
153
|
-
const themeName = (0, import_core.useThemeName)();
|
|
105
|
+
const zIndex = props.zIndex ?? 15e4, context = usePopoverContext(), popperContext = (0, import_popper.usePopperContext)(), themeName = (0, import_core.useThemeName)();
|
|
154
106
|
let contents = props.children;
|
|
155
|
-
|
|
156
|
-
contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverRepropagateContext, { popperContext, context, children: props.children });
|
|
157
|
-
}
|
|
158
|
-
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: [
|
|
107
|
+
return (import_react_native.Platform.OS === "android" || import_react_native.Platform.OS === "ios") && (contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverRepropagateContext, { popperContext, context, children: props.children })), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, { zIndex, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.Theme, { forceClassName: !0, name: themeName, children: [
|
|
159
108
|
!!context.open && !context.breakpointActive && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
160
109
|
import_stacks.YStack,
|
|
161
110
|
{
|
|
162
|
-
fullscreen:
|
|
111
|
+
fullscreen: !0,
|
|
163
112
|
onPress: (0, import_core.composeEventHandlers)(props.onPress, context.onOpenToggle)
|
|
164
113
|
}
|
|
165
114
|
),
|
|
166
115
|
contents
|
|
167
116
|
] }) });
|
|
168
117
|
}
|
|
169
|
-
const PopoverContentImpl = React.forwardRef(function
|
|
118
|
+
const PopoverContentImpl = React.forwardRef(function(props, forwardedRef) {
|
|
170
119
|
const {
|
|
171
120
|
trapFocus,
|
|
172
121
|
onOpenAutoFocus,
|
|
@@ -181,51 +130,27 @@ const PopoverContentImpl = React.forwardRef(function PopoverContentImpl2(props,
|
|
|
181
130
|
disableRemoveScroll,
|
|
182
131
|
freezeContentsWhenHidden,
|
|
183
132
|
...contentProps
|
|
184
|
-
} = props;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const popperContext = (0, import_popper.usePopperContext)();
|
|
188
|
-
const [isFullyHidden, setIsFullyHidden] = React.useState(!context.open);
|
|
189
|
-
const contents = React.useMemo(() => {
|
|
190
|
-
return import_core.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "contents" }, children }) : children;
|
|
191
|
-
}, [children]);
|
|
192
|
-
if (open && isFullyHidden) {
|
|
193
|
-
setIsFullyHidden(false);
|
|
194
|
-
}
|
|
195
|
-
if (!keepChildrenMounted) {
|
|
196
|
-
if (isFullyHidden) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
133
|
+
} = props, context = usePopoverContext(), { open, keepChildrenMounted } = context, popperContext = (0, import_popper.usePopperContext)(), [isFullyHidden, setIsFullyHidden] = React.useState(!context.open), contents = React.useMemo(() => import_core.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "contents" }, children }) : children, [children]);
|
|
134
|
+
if (open && isFullyHidden && setIsFullyHidden(!1), !keepChildrenMounted && isFullyHidden)
|
|
135
|
+
return null;
|
|
200
136
|
if (context.breakpointActive) {
|
|
201
|
-
const childrenWithoutScrollView = React.Children.toArray(children).map((child) =>
|
|
202
|
-
if (React.isValidElement(child)) {
|
|
203
|
-
if (child.type === import_react_native.ScrollView) {
|
|
204
|
-
return child.props.children;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return child;
|
|
208
|
-
});
|
|
137
|
+
const childrenWithoutScrollView = React.Children.toArray(children).map((child) => React.isValidElement(child) && child.type === import_react_native.ScrollView ? child.props.children : child);
|
|
209
138
|
let content = childrenWithoutScrollView;
|
|
210
|
-
|
|
211
|
-
content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperContext.Provider, { ...popperContext, children: childrenWithoutScrollView });
|
|
212
|
-
}
|
|
213
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: `${context.id}PopoverContents`, children: content });
|
|
139
|
+
return (import_react_native.Platform.OS === "android" || import_react_native.Platform.OS === "ios") && (content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperContext.Provider, { ...popperContext, children: childrenWithoutScrollView })), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: `${context.id}PopoverContents`, children: content });
|
|
214
140
|
}
|
|
215
|
-
const freeze = Boolean(isFullyHidden && freezeContentsWhenHidden);
|
|
216
141
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
217
142
|
import_animate.Animate,
|
|
218
143
|
{
|
|
219
144
|
type: "presence",
|
|
220
|
-
present:
|
|
145
|
+
present: !!open,
|
|
221
146
|
keepChildrenMounted,
|
|
222
147
|
onExitComplete: () => {
|
|
223
|
-
setIsFullyHidden(
|
|
148
|
+
setIsFullyHidden(!0);
|
|
224
149
|
},
|
|
225
150
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
226
151
|
FreezeToLastContents,
|
|
227
152
|
{
|
|
228
|
-
freeze,
|
|
153
|
+
freeze: !!(isFullyHidden && freezeContentsWhenHidden),
|
|
229
154
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
230
155
|
import_popper.PopperContent,
|
|
231
156
|
{
|
|
@@ -236,17 +161,17 @@ const PopoverContentImpl = React.forwardRef(function PopoverContentImpl2(props,
|
|
|
236
161
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
237
162
|
import_remove_scroll.RemoveScroll,
|
|
238
163
|
{
|
|
239
|
-
enabled: disableRemoveScroll ?
|
|
240
|
-
allowPinchZoom:
|
|
241
|
-
removeScrollBar:
|
|
164
|
+
enabled: disableRemoveScroll ? !1 : open,
|
|
165
|
+
allowPinchZoom: !0,
|
|
166
|
+
removeScrollBar: !1,
|
|
242
167
|
style: {
|
|
243
168
|
display: "contents"
|
|
244
169
|
},
|
|
245
170
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
246
171
|
import_focus_scope.FocusScope,
|
|
247
172
|
{
|
|
248
|
-
loop:
|
|
249
|
-
enabled: disableFocusScope ?
|
|
173
|
+
loop: !0,
|
|
174
|
+
enabled: disableFocusScope ? !1 : open,
|
|
250
175
|
trapped: trapFocus,
|
|
251
176
|
onMountAutoFocus: onOpenAutoFocus,
|
|
252
177
|
onUnmountAutoFocus: onCloseAutoFocus,
|
|
@@ -262,16 +187,11 @@ const PopoverContentImpl = React.forwardRef(function PopoverContentImpl2(props,
|
|
|
262
187
|
)
|
|
263
188
|
}
|
|
264
189
|
);
|
|
265
|
-
})
|
|
266
|
-
const FreezeToLastContents = (props) => {
|
|
190
|
+
}), FreezeToLastContents = (props) => {
|
|
267
191
|
const last = React.useRef();
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_freeze.Freeze, { placeholder: last.current, ...props });
|
|
272
|
-
};
|
|
273
|
-
const PopoverClose = React.forwardRef(
|
|
274
|
-
function PopoverClose2(props, forwardedRef) {
|
|
192
|
+
return props.freeze || (last.current = props.children), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_freeze.Freeze, { placeholder: last.current, ...props });
|
|
193
|
+
}, PopoverClose = React.forwardRef(
|
|
194
|
+
function(props, forwardedRef) {
|
|
275
195
|
const context = usePopoverContext();
|
|
276
196
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
277
197
|
import_stacks.YStack,
|
|
@@ -281,19 +201,17 @@ const PopoverClose = React.forwardRef(
|
|
|
281
201
|
componentName: "PopoverClose",
|
|
282
202
|
onPress: (0, import_core.composeEventHandlers)(
|
|
283
203
|
props.onPress,
|
|
284
|
-
() => context.onOpenChange(
|
|
204
|
+
() => context.onOpenChange(!1)
|
|
285
205
|
)
|
|
286
206
|
}
|
|
287
207
|
);
|
|
288
208
|
}
|
|
289
|
-
)
|
|
290
|
-
|
|
291
|
-
function PopoverArrow2(props, forwardedRef) {
|
|
209
|
+
), PopoverArrow = React.forwardRef(
|
|
210
|
+
function(props, forwardedRef) {
|
|
292
211
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperArrow, { componentName: "PopoverArrow", ...props, ref: forwardedRef });
|
|
293
212
|
}
|
|
294
|
-
)
|
|
295
|
-
|
|
296
|
-
function Popover2(props) {
|
|
213
|
+
), Popover = (0, import_core.withStaticProperties)(
|
|
214
|
+
function(props) {
|
|
297
215
|
const {
|
|
298
216
|
children,
|
|
299
217
|
open: openProp,
|
|
@@ -301,24 +219,13 @@ const Popover = (0, import_core.withStaticProperties)(
|
|
|
301
219
|
onOpenChange,
|
|
302
220
|
keepChildrenMounted,
|
|
303
221
|
...restProps
|
|
304
|
-
} = props
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
Contents: React.useCallback(() => {
|
|
308
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, { name: `${id}PopoverContents` });
|
|
309
|
-
}, [])
|
|
310
|
-
});
|
|
311
|
-
const sheetBreakpoint = when;
|
|
312
|
-
const triggerRef = React.useRef(null);
|
|
313
|
-
const [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
314
|
-
const [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
222
|
+
} = props, id = React.useId(), { when, AdaptProvider } = (0, import_adapt.useAdaptParent)({
|
|
223
|
+
Contents: React.useCallback(() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, { name: `${id}PopoverContents` }), [])
|
|
224
|
+
}), sheetBreakpoint = when, triggerRef = React.useRef(null), [hasCustomAnchor, setHasCustomAnchor] = React.useState(!1), [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
315
225
|
prop: openProp,
|
|
316
|
-
defaultProp: defaultOpen ||
|
|
226
|
+
defaultProp: defaultOpen || !1,
|
|
317
227
|
onChange: onOpenChange
|
|
318
|
-
})
|
|
319
|
-
const breakpointActive = useSheetBreakpointActive(sheetBreakpoint);
|
|
320
|
-
const floatingContext = (0, import_useFloatingContext.useFloatingContext)({ open, setOpen, breakpointActive });
|
|
321
|
-
const popoverContext = {
|
|
228
|
+
}), breakpointActive = useSheetBreakpointActive(sheetBreakpoint), floatingContext = (0, import_useFloatingContext.useFloatingContext)({ open, setOpen, breakpointActive }), popoverContext = {
|
|
322
229
|
id,
|
|
323
230
|
sheetBreakpoint,
|
|
324
231
|
contentId: React.useId(),
|
|
@@ -327,17 +234,13 @@ const Popover = (0, import_core.withStaticProperties)(
|
|
|
327
234
|
breakpointActive,
|
|
328
235
|
onOpenChange: setOpen,
|
|
329
236
|
onOpenToggle: (0, import_core.useEvent)(() => {
|
|
330
|
-
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
setOpen(!open);
|
|
237
|
+
open && breakpointActive || setOpen(!open);
|
|
334
238
|
}),
|
|
335
239
|
hasCustomAnchor,
|
|
336
|
-
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(
|
|
337
|
-
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(
|
|
240
|
+
onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(!0), []),
|
|
241
|
+
onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(!1), []),
|
|
338
242
|
keepChildrenMounted
|
|
339
|
-
};
|
|
340
|
-
const contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.Popper, { stayInFrame: true, ...restProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContext.Provider, { ...popoverContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverSheetController, { onOpenChange: setOpen, children }) }) });
|
|
243
|
+
}, contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.Popper, { stayInFrame: !0, ...restProps, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContext.Provider, { ...popoverContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverSheetController, { onOpenChange: setOpen, children }) }) });
|
|
341
244
|
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 });
|
|
342
245
|
},
|
|
343
246
|
{
|
|
@@ -355,34 +258,24 @@ function getState(open) {
|
|
|
355
258
|
return open ? "open" : "closed";
|
|
356
259
|
}
|
|
357
260
|
const PopoverSheetController = (props) => {
|
|
358
|
-
const context = usePopoverContext();
|
|
359
|
-
const showSheet = useShowPopoverSheet(context);
|
|
360
|
-
const breakpointActive = context.breakpointActive;
|
|
361
|
-
const getShowSheet = (0, import_core.useGet)(showSheet);
|
|
261
|
+
const context = usePopoverContext(), showSheet = useShowPopoverSheet(context), breakpointActive = context.breakpointActive, getShowSheet = (0, import_core.useGet)(showSheet);
|
|
362
262
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
363
263
|
import_sheet.SheetController,
|
|
364
264
|
{
|
|
365
265
|
onOpenChange: (val) => {
|
|
366
|
-
|
|
367
|
-
props.onOpenChange(val);
|
|
368
|
-
}
|
|
266
|
+
getShowSheet() && props.onOpenChange(val);
|
|
369
267
|
},
|
|
370
268
|
open: context.open,
|
|
371
|
-
hidden: breakpointActive ===
|
|
269
|
+
hidden: breakpointActive === !1,
|
|
372
270
|
children: props.children
|
|
373
271
|
}
|
|
374
272
|
);
|
|
375
|
-
}
|
|
376
|
-
const useSheetBreakpointActive = (breakpoint) => {
|
|
273
|
+
}, useSheetBreakpointActive = (breakpoint) => {
|
|
377
274
|
const media = (0, import_core.useMedia)();
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
return media[breakpoint];
|
|
382
|
-
};
|
|
383
|
-
const useShowPopoverSheet = (context) => {
|
|
275
|
+
return typeof breakpoint == "boolean" || !breakpoint ? !!breakpoint : media[breakpoint];
|
|
276
|
+
}, useShowPopoverSheet = (context) => {
|
|
384
277
|
const breakpointActive = useSheetBreakpointActive(context.sheetBreakpoint);
|
|
385
|
-
return context.open ===
|
|
278
|
+
return context.open === !1 ? !1 : breakpointActive;
|
|
386
279
|
};
|
|
387
280
|
// Annotate the CommonJS export names for ESM import in node:
|
|
388
281
|
0 && (module.exports = {
|
package/dist/cjs/Popover.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Popover.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": [
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAO,kCAEP,eAAsC,2BACtC,iBAAwB,6BACxB,qBAA2B,iCAC3B,sBAAgC,kCAChC,cAgBO,0BAEP,kBAAwC,8BACxC,qBAA4C,iCAC5C,gBAWO,4BACP,gBAA+C,4BAC/C,uBA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