@tamagui/popover 2.0.0-rc.9 → 2.1.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 +637 -406
- package/dist/cjs/Popover.native.js +651 -436
- package/dist/cjs/Popover.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/useFloatingContext.cjs +226 -58
- package/dist/cjs/useFloatingContext.native.js +28 -26
- package/dist/cjs/useFloatingContext.native.js.map +1 -1
- package/dist/esm/Popover.mjs +589 -376
- package/dist/esm/Popover.mjs.map +1 -1
- package/dist/esm/Popover.native.js +605 -408
- package/dist/esm/Popover.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/useFloatingContext.mjs +200 -34
- package/dist/esm/useFloatingContext.mjs.map +1 -1
- package/dist/jsx/Popover.mjs +589 -376
- package/dist/jsx/Popover.mjs.map +1 -1
- package/dist/jsx/Popover.native.js +651 -436
- package/dist/jsx/Popover.native.js.map +1 -1
- package/dist/jsx/index.js +2 -2
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/dist/jsx/useFloatingContext.mjs +200 -34
- package/dist/jsx/useFloatingContext.mjs.map +1 -1
- package/dist/jsx/useFloatingContext.native.js +28 -26
- package/dist/jsx/useFloatingContext.native.js.map +1 -1
- package/package.json +25 -26
- package/src/Popover.tsx +536 -177
- package/src/useFloatingContext.tsx +321 -43
- package/types/Popover.d.ts +126 -8
- package/types/Popover.d.ts.map +1 -1
- package/types/useFloatingContext.d.ts +14 -8
- package/types/useFloatingContext.d.ts.map +1 -1
- package/dist/cjs/Popover.js +0 -394
- package/dist/cjs/Popover.js.map +0 -6
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/useFloatingContext.js +0 -74
- package/dist/cjs/useFloatingContext.js.map +0 -6
- package/dist/esm/Popover.js +0 -415
- package/dist/esm/Popover.js.map +0 -6
- package/dist/esm/useFloatingContext.js +0 -59
- package/dist/esm/useFloatingContext.js.map +0 -6
- package/dist/jsx/Popover.js +0 -415
- package/dist/jsx/Popover.js.map +0 -6
- package/dist/jsx/useFloatingContext.js +0 -59
- package/dist/jsx/useFloatingContext.js.map +0 -6
|
@@ -4,33 +4,35 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var Popover_exports = {};
|
|
35
37
|
__export(Popover_exports, {
|
|
36
38
|
Popover: () => Popover,
|
|
@@ -39,192 +41,373 @@ __export(Popover_exports, {
|
|
|
39
41
|
PopoverClose: () => PopoverClose,
|
|
40
42
|
PopoverContent: () => PopoverContent,
|
|
41
43
|
PopoverContext: () => PopoverContext,
|
|
44
|
+
PopoverContextProvider: () => PopoverContextProvider,
|
|
42
45
|
PopoverTrigger: () => PopoverTrigger,
|
|
43
|
-
|
|
46
|
+
PopoverTriggerContext: () => PopoverTriggerContext,
|
|
47
|
+
PopoverZIndexContext: () => PopoverZIndexContext,
|
|
48
|
+
closeLastOpenedPopover: () => closeLastOpenedPopover,
|
|
49
|
+
closeOpenPopovers: () => closeOpenPopovers,
|
|
50
|
+
hasOpenPopovers: () => hasOpenPopovers,
|
|
51
|
+
usePopoverContext: () => usePopoverContext,
|
|
52
|
+
usePopoverOpen: () => usePopoverOpen,
|
|
53
|
+
usePopoverTriggerContext: () => usePopoverTriggerContext,
|
|
54
|
+
usePopoverTriggerSetup: () => usePopoverTriggerSetup
|
|
44
55
|
});
|
|
45
56
|
module.exports = __toCommonJS(Popover_exports);
|
|
46
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
57
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
58
|
+
require("@tamagui/polyfill-dev");
|
|
59
|
+
var import_adapt = require("@tamagui/adapt");
|
|
60
|
+
var import_animate = require("@tamagui/animate");
|
|
61
|
+
var import_animate_presence = require("@tamagui/animate-presence");
|
|
62
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
63
|
+
var import_constants = require("@tamagui/constants");
|
|
64
|
+
var import_core = require("@tamagui/core");
|
|
65
|
+
var import_dismissable = require("@tamagui/dismissable");
|
|
66
|
+
var import_floating = require("@tamagui/floating");
|
|
67
|
+
var import_focus_scope = require("@tamagui/focus-scope");
|
|
68
|
+
var import_helpers = require("@tamagui/helpers");
|
|
69
|
+
var import_popper = require("@tamagui/popper");
|
|
70
|
+
var import_portal = require("@tamagui/portal");
|
|
71
|
+
require("@tamagui/remove-scroll");
|
|
72
|
+
var import_scroll_view = require("@tamagui/scroll-view");
|
|
73
|
+
var import_controller = require("@tamagui/sheet/controller");
|
|
74
|
+
var import_stacks = require("@tamagui/stacks");
|
|
75
|
+
var import_use_controllable_state = require("@tamagui/use-controllable-state");
|
|
76
|
+
var React = __toESM(require("react"), 1);
|
|
77
|
+
var import_useFloatingContext = require("./useFloatingContext.native.js");
|
|
78
|
+
var needsRepropagation = (0, import_portal.needsPortalRepropagation)();
|
|
79
|
+
var openPopovers = /* @__PURE__ */new Set();
|
|
80
|
+
var hasOpenPopovers = function () {
|
|
81
|
+
return openPopovers.size > 0;
|
|
82
|
+
};
|
|
83
|
+
var closeOpenPopovers = function () {
|
|
84
|
+
if (openPopovers.size === 0) return false;
|
|
85
|
+
openPopovers.forEach(function (setOpen) {
|
|
86
|
+
return setOpen(false);
|
|
87
|
+
});
|
|
88
|
+
return true;
|
|
89
|
+
};
|
|
90
|
+
var closeLastOpenedPopover = function () {
|
|
91
|
+
if (openPopovers.size === 0) return false;
|
|
92
|
+
var last = Array.from(openPopovers).pop();
|
|
93
|
+
if (last) {
|
|
94
|
+
last(false);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
return false;
|
|
98
|
+
};
|
|
99
|
+
var PopoverContext = (0, import_core.createStyledContext)(
|
|
100
|
+
// since we always provide this we can avoid setting here
|
|
101
|
+
{}, "Popover__");
|
|
102
|
+
var PopoverZIndexContext = /* @__PURE__ */React.createContext(void 0);
|
|
103
|
+
var PopoverAdaptHiddenContext = /* @__PURE__ */React.createContext(true);
|
|
104
|
+
var PopoverTriggerContext = (0, import_core.createStyledContext)({}, "PopoverTrigger__");
|
|
105
|
+
var usePopoverContext = PopoverContext.useStyledContext;
|
|
106
|
+
var usePopoverTriggerContext = PopoverTriggerContext.useStyledContext;
|
|
107
|
+
function usePopoverOpen(scope) {
|
|
108
|
+
return usePopoverContext(scope).open;
|
|
109
|
+
}
|
|
110
|
+
function usePopoverTriggerSetup(open) {
|
|
111
|
+
var triggerStateSettersRef = React.useRef(/* @__PURE__ */new Map());
|
|
112
|
+
var activeTriggerIdRef = React.useRef(null);
|
|
113
|
+
var setActiveTrigger = (0, import_core.useEvent)(function (id) {
|
|
114
|
+
var prevId = activeTriggerIdRef.current;
|
|
115
|
+
if (prevId === id) return;
|
|
116
|
+
if (prevId) {
|
|
117
|
+
var _triggerStateSettersRef_current_get;
|
|
118
|
+
(_triggerStateSettersRef_current_get = triggerStateSettersRef.current.get(prevId)) === null || _triggerStateSettersRef_current_get === void 0 || _triggerStateSettersRef_current_get(false);
|
|
119
|
+
}
|
|
120
|
+
activeTriggerIdRef.current = id;
|
|
121
|
+
if (id && open) {
|
|
122
|
+
var _triggerStateSettersRef_current_get1;
|
|
123
|
+
(_triggerStateSettersRef_current_get1 = triggerStateSettersRef.current.get(id)) === null || _triggerStateSettersRef_current_get1 === void 0 || _triggerStateSettersRef_current_get1(true);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
var registerTrigger = (0, import_core.useEvent)(function (id, setOpenState) {
|
|
127
|
+
triggerStateSettersRef.current.set(id, setOpenState);
|
|
128
|
+
setOpenState(activeTriggerIdRef.current === id && open);
|
|
129
|
+
});
|
|
130
|
+
var unregisterTrigger = (0, import_core.useEvent)(function (id) {
|
|
131
|
+
triggerStateSettersRef.current.delete(id);
|
|
132
|
+
if (activeTriggerIdRef.current === id) activeTriggerIdRef.current = null;
|
|
133
|
+
});
|
|
134
|
+
React.useEffect(function () {
|
|
135
|
+
if (!open) {
|
|
136
|
+
setActiveTrigger(null);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
var activeId = activeTriggerIdRef.current;
|
|
140
|
+
if (activeId) {
|
|
141
|
+
var _triggerStateSettersRef_current_get;
|
|
142
|
+
(_triggerStateSettersRef_current_get = triggerStateSettersRef.current.get(activeId)) === null || _triggerStateSettersRef_current_get === void 0 || _triggerStateSettersRef_current_get(true);
|
|
143
|
+
}
|
|
144
|
+
}, [open, setActiveTrigger]);
|
|
145
|
+
return {
|
|
146
|
+
setActiveTrigger,
|
|
147
|
+
registerTrigger,
|
|
148
|
+
unregisterTrigger
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
var PopoverContextProvider = /* @__PURE__ */React.memo(function (param) {
|
|
152
|
+
var {
|
|
153
|
+
scope,
|
|
154
|
+
children,
|
|
155
|
+
open,
|
|
156
|
+
onOpenChange,
|
|
157
|
+
onOpenToggle,
|
|
158
|
+
triggerRef,
|
|
159
|
+
id = "",
|
|
160
|
+
contentId,
|
|
161
|
+
hasCustomAnchor = false,
|
|
162
|
+
onCustomAnchorAdd = voidFn,
|
|
163
|
+
onCustomAnchorRemove = voidFn,
|
|
164
|
+
anchorTo,
|
|
165
|
+
adaptScope,
|
|
166
|
+
breakpointActive,
|
|
167
|
+
keepChildrenMounted,
|
|
168
|
+
disableDismissable,
|
|
169
|
+
hoverable
|
|
170
|
+
} = param;
|
|
171
|
+
var [branches] = React.useState(function () {
|
|
172
|
+
return /* @__PURE__ */new Set();
|
|
173
|
+
});
|
|
174
|
+
var {
|
|
175
|
+
setActiveTrigger,
|
|
176
|
+
registerTrigger,
|
|
177
|
+
unregisterTrigger
|
|
178
|
+
} = usePopoverTriggerSetup(open);
|
|
179
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverContext.Provider, {
|
|
180
|
+
scope,
|
|
181
|
+
popoverScope: scope,
|
|
182
|
+
adaptScope,
|
|
183
|
+
id,
|
|
184
|
+
contentId,
|
|
185
|
+
triggerRef,
|
|
186
|
+
open,
|
|
187
|
+
onOpenChange,
|
|
188
|
+
onOpenToggle,
|
|
189
|
+
hasCustomAnchor,
|
|
190
|
+
onCustomAnchorAdd,
|
|
191
|
+
onCustomAnchorRemove,
|
|
192
|
+
anchorTo,
|
|
193
|
+
branches,
|
|
194
|
+
breakpointActive,
|
|
195
|
+
keepChildrenMounted,
|
|
196
|
+
disableDismissable,
|
|
197
|
+
hoverable,
|
|
198
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverTriggerContext.Provider, {
|
|
87
199
|
scope,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
200
|
+
triggerRef,
|
|
201
|
+
hasCustomAnchor,
|
|
202
|
+
anchorTo,
|
|
203
|
+
branches,
|
|
204
|
+
onOpenToggle,
|
|
205
|
+
setActiveTrigger,
|
|
206
|
+
registerTrigger,
|
|
207
|
+
unregisterTrigger,
|
|
208
|
+
children
|
|
209
|
+
})
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
var voidFn = function () {};
|
|
213
|
+
var PopoverAnchor = /* @__PURE__ */React.memo(/* @__PURE__ */React.forwardRef(function PopoverAnchor2(props, forwardedRef) {
|
|
214
|
+
var {
|
|
215
|
+
scope,
|
|
216
|
+
...rest
|
|
217
|
+
} = props;
|
|
218
|
+
var {
|
|
219
|
+
onCustomAnchorAdd,
|
|
220
|
+
onCustomAnchorRemove
|
|
221
|
+
} = usePopoverContext(scope) || {};
|
|
222
|
+
React.useEffect(function () {
|
|
223
|
+
onCustomAnchorAdd();
|
|
224
|
+
return function () {
|
|
225
|
+
return onCustomAnchorRemove();
|
|
226
|
+
};
|
|
227
|
+
}, [onCustomAnchorAdd, onCustomAnchorRemove]);
|
|
228
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, {
|
|
229
|
+
scope,
|
|
230
|
+
...rest,
|
|
231
|
+
ref: forwardedRef
|
|
232
|
+
});
|
|
233
|
+
}));
|
|
234
|
+
var PopoverTrigger = /* @__PURE__ */React.memo(/* @__PURE__ */React.forwardRef(function PopoverTrigger2(props, forwardedRef) {
|
|
235
|
+
var {
|
|
236
|
+
scope,
|
|
237
|
+
disablePressTrigger,
|
|
238
|
+
...rest
|
|
239
|
+
} = props;
|
|
240
|
+
var triggerContext = usePopoverTriggerContext(scope);
|
|
241
|
+
var triggerId = React.useId();
|
|
242
|
+
var [open, setOpen] = React.useState(false);
|
|
243
|
+
var anchorTo = triggerContext.anchorTo;
|
|
244
|
+
var triggerElRef = React.useRef(null);
|
|
245
|
+
var composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, triggerElRef);
|
|
246
|
+
var {
|
|
247
|
+
registerTrigger,
|
|
248
|
+
unregisterTrigger
|
|
249
|
+
} = triggerContext;
|
|
250
|
+
React.useEffect(function () {
|
|
251
|
+
registerTrigger(triggerId, setOpen);
|
|
252
|
+
return function () {
|
|
253
|
+
unregisterTrigger(triggerId);
|
|
254
|
+
};
|
|
255
|
+
}, [registerTrigger, unregisterTrigger, triggerId]);
|
|
256
|
+
if (!rest.children) return null;
|
|
257
|
+
var activateSelf = function () {
|
|
258
|
+
triggerContext.setActiveTrigger(triggerId);
|
|
259
|
+
var el = triggerElRef.current;
|
|
260
|
+
if (el) triggerContext.triggerRef.current = el;
|
|
261
|
+
};
|
|
262
|
+
var trigger = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
|
|
263
|
+
"aria-expanded": open,
|
|
264
|
+
"data-state": getState(open),
|
|
265
|
+
...rest,
|
|
266
|
+
ref: composedTriggerRef,
|
|
267
|
+
onPress: (0, import_helpers.composeEventHandlers)(rest.onPress, function () {
|
|
268
|
+
if (disablePressTrigger) return;
|
|
269
|
+
triggerContext.setActiveTrigger(open ? null : triggerId);
|
|
270
|
+
triggerContext.onOpenToggle();
|
|
271
|
+
}),
|
|
272
|
+
onMouseEnter: (0, import_helpers.composeEventHandlers)(rest.onMouseEnter, activateSelf),
|
|
273
|
+
onPressIn: (0, import_helpers.composeEventHandlers)(rest.onPressIn, activateSelf),
|
|
274
|
+
onFocus: (0, import_helpers.composeEventHandlers)(rest.onFocus, activateSelf)
|
|
275
|
+
});
|
|
276
|
+
var virtualRef = React.useMemo(function () {
|
|
277
|
+
if (!anchorTo) return null;
|
|
278
|
+
return {
|
|
279
|
+
current: {
|
|
280
|
+
getBoundingClientRect: function () {
|
|
281
|
+
return import_constants.isWeb ? DOMRect.fromRect(anchorTo) : anchorTo;
|
|
282
|
+
},
|
|
283
|
+
...(!import_constants.isWeb && {
|
|
284
|
+
measure: function (c) {
|
|
285
|
+
return c(anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.x, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.y, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.width, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.height);
|
|
286
|
+
},
|
|
287
|
+
measureInWindow: function (c) {
|
|
288
|
+
return c(anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.x, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.y, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.width, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.height);
|
|
125
289
|
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
290
|
+
})
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}, [triggerContext.anchorTo, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.x, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.y, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.height, anchorTo === null || anchorTo === void 0 ? void 0 : anchorTo.width]);
|
|
294
|
+
var wrappedTrigger = import_constants.isWeb ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_dismissable.DismissableBranch, {
|
|
295
|
+
branches: triggerContext.branches,
|
|
296
|
+
children: trigger
|
|
297
|
+
}) : trigger;
|
|
298
|
+
return triggerContext.hasCustomAnchor ? wrappedTrigger : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, {
|
|
299
|
+
...(virtualRef && {
|
|
300
|
+
virtualRef
|
|
301
|
+
}),
|
|
302
|
+
scope,
|
|
303
|
+
asChild: true,
|
|
304
|
+
children: wrappedTrigger
|
|
305
|
+
});
|
|
306
|
+
}));
|
|
307
|
+
var PopoverContent = import_popper.PopperContentFrame.styleable(function PopoverContent2(props, forwardedRef) {
|
|
308
|
+
var {
|
|
309
|
+
trapFocus,
|
|
310
|
+
enableRemoveScroll = false,
|
|
311
|
+
zIndex: zIndexProp,
|
|
312
|
+
scope,
|
|
313
|
+
...contentImplProps
|
|
314
|
+
} = props;
|
|
315
|
+
var context = usePopoverContext(scope);
|
|
316
|
+
var zIndexFromContext = React.useContext(PopoverZIndexContext);
|
|
317
|
+
var zIndex = zIndexProp !== null && zIndexProp !== void 0 ? zIndexProp : zIndexFromContext;
|
|
318
|
+
var open = usePopoverOpen(scope);
|
|
319
|
+
var contentRef = React.useRef(null);
|
|
320
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef);
|
|
321
|
+
var isRightClickOutsideRef = React.useRef(false);
|
|
322
|
+
var [isFullyHidden, setIsFullyHidden] = React.useState(!open);
|
|
323
|
+
(0, import_constants.useIsomorphicLayoutEffect)(function () {
|
|
324
|
+
if (open && isFullyHidden) setIsFullyHidden(false);
|
|
325
|
+
}, [open, isFullyHidden]);
|
|
326
|
+
var isAdaptFullyHidden = React.useContext(PopoverAdaptHiddenContext);
|
|
327
|
+
if (!context.keepChildrenMounted) {
|
|
328
|
+
if (context.breakpointActive) {
|
|
329
|
+
if (!open && isAdaptFullyHidden) return null;
|
|
330
|
+
} else if (isFullyHidden && !open) return null;
|
|
331
|
+
}
|
|
332
|
+
var _contentImplProps_pointerEvents;
|
|
333
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverPortal, {
|
|
334
|
+
passThrough: context.breakpointActive,
|
|
335
|
+
context,
|
|
336
|
+
open,
|
|
337
|
+
zIndex,
|
|
338
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
|
|
158
339
|
passThrough: context.breakpointActive,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
// When focus is trapped, a `focusout` event may still happen.
|
|
188
|
-
// We make sure we don't trigger our `onDismiss` in such case.
|
|
189
|
-
onFocusOutside: (0, import_helpers.composeEventHandlers)(props.onFocusOutside, function (event) {
|
|
190
|
-
return event.preventDefault();
|
|
191
|
-
}, {
|
|
192
|
-
checkDefaultPrevented: !1
|
|
193
|
-
})
|
|
340
|
+
pointerEvents: open ? (_contentImplProps_pointerEvents = contentImplProps.pointerEvents) !== null && _contentImplProps_pointerEvents !== void 0 ? _contentImplProps_pointerEvents : "auto" : "none",
|
|
341
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverContentImpl, {
|
|
342
|
+
...contentImplProps,
|
|
343
|
+
context,
|
|
344
|
+
open,
|
|
345
|
+
enableRemoveScroll,
|
|
346
|
+
ref: composedRefs,
|
|
347
|
+
setIsFullyHidden,
|
|
348
|
+
scope,
|
|
349
|
+
trapFocus: trapFocus !== null && trapFocus !== void 0 ? trapFocus : open,
|
|
350
|
+
disableOutsidePointerEvents: true,
|
|
351
|
+
onCloseAutoFocus: props.onCloseAutoFocus === false ? void 0 : (0, import_helpers.composeEventHandlers)(props.onCloseAutoFocus, function (event) {
|
|
352
|
+
var _context_triggerRef_current;
|
|
353
|
+
if (event.defaultPrevented) return;
|
|
354
|
+
event.preventDefault();
|
|
355
|
+
if (!isRightClickOutsideRef.current) (_context_triggerRef_current = context.triggerRef.current) === null || _context_triggerRef_current === void 0 || _context_triggerRef_current.focus();
|
|
356
|
+
}),
|
|
357
|
+
onPointerDownOutside: (0, import_helpers.composeEventHandlers)(props.onPointerDownOutside, function (event) {
|
|
358
|
+
var originalEvent = event.detail.originalEvent;
|
|
359
|
+
var ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === true;
|
|
360
|
+
isRightClickOutsideRef.current = originalEvent.button === 2 || ctrlLeftClick;
|
|
361
|
+
}, {
|
|
362
|
+
checkDefaultPrevented: false
|
|
363
|
+
}),
|
|
364
|
+
onFocusOutside: (0, import_helpers.composeEventHandlers)(props.onFocusOutside, function (event) {
|
|
365
|
+
return event.preventDefault();
|
|
366
|
+
}, {
|
|
367
|
+
checkDefaultPrevented: false
|
|
194
368
|
})
|
|
195
369
|
})
|
|
196
|
-
})
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
370
|
+
})
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
var useParentContexts = function (scope) {
|
|
374
|
+
var context = usePopoverContext(scope);
|
|
375
|
+
var triggerContext = usePopoverTriggerContext(scope);
|
|
376
|
+
return {
|
|
377
|
+
popperContext: (0, import_popper.usePopperContext)(scope),
|
|
378
|
+
adaptContext: (0, import_adapt.useAdaptContext)(context.adaptScope),
|
|
379
|
+
context,
|
|
380
|
+
triggerContext
|
|
207
381
|
};
|
|
382
|
+
};
|
|
208
383
|
function RepropagateParentContexts(param) {
|
|
209
384
|
var {
|
|
210
385
|
adaptContext,
|
|
211
386
|
children,
|
|
212
387
|
context,
|
|
388
|
+
triggerContext,
|
|
213
389
|
popperContext
|
|
214
390
|
} = param;
|
|
215
391
|
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperProvider, {
|
|
216
392
|
scope: context.popoverScope,
|
|
217
393
|
...popperContext,
|
|
218
394
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverContext.Provider, {
|
|
395
|
+
scope: context.popoverScope,
|
|
219
396
|
...context,
|
|
220
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(
|
|
221
|
-
|
|
222
|
-
|
|
397
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverTriggerContext.Provider, {
|
|
398
|
+
scope: context.popoverScope,
|
|
399
|
+
...triggerContext,
|
|
400
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.ProvideAdaptContext, {
|
|
401
|
+
...adaptContext,
|
|
402
|
+
children
|
|
403
|
+
})
|
|
223
404
|
})
|
|
224
405
|
})
|
|
225
406
|
});
|
|
226
407
|
}
|
|
227
408
|
var PortalAdaptSafe = function (param) {
|
|
409
|
+
"use no memo";
|
|
410
|
+
|
|
228
411
|
var {
|
|
229
412
|
children,
|
|
230
413
|
context
|
|
@@ -245,15 +428,17 @@ var PortalAdaptSafe = function (param) {
|
|
|
245
428
|
});
|
|
246
429
|
};
|
|
247
430
|
function PopoverPortal(param) {
|
|
431
|
+
"use no memo";
|
|
432
|
+
|
|
248
433
|
var {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
434
|
+
context,
|
|
435
|
+
open,
|
|
436
|
+
zIndex,
|
|
437
|
+
passThrough,
|
|
438
|
+
children,
|
|
439
|
+
onPress
|
|
440
|
+
} = param;
|
|
441
|
+
var content = children;
|
|
257
442
|
if (needsRepropagation) {
|
|
258
443
|
var parentContexts = useParentContexts(context.popoverScope);
|
|
259
444
|
content = /* @__PURE__ */(0, import_jsx_runtime.jsx)(RepropagateParentContexts, {
|
|
@@ -261,62 +446,58 @@ function PopoverPortal(param) {
|
|
|
261
446
|
children: content
|
|
262
447
|
});
|
|
263
448
|
}
|
|
264
|
-
return /* @__PURE__ */(0, import_jsx_runtime.
|
|
449
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_portal.Portal, {
|
|
265
450
|
passThrough,
|
|
266
|
-
stackZIndex:
|
|
451
|
+
stackZIndex: true,
|
|
267
452
|
zIndex,
|
|
268
|
-
children:
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
contain: !0,
|
|
273
|
-
forceClassName: !0,
|
|
274
|
-
name: themeName,
|
|
275
|
-
children: [!!context.open && !context.breakpointActive && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
276
|
-
fullscreen: !0,
|
|
277
|
-
onPress: (0, import_helpers.composeEventHandlers)(onPress, context.onOpenToggle)
|
|
278
|
-
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_z_index_stack.StackZIndexContext, {
|
|
279
|
-
zIndex: (0, import_portal.resolveViewZIndex)(zIndex),
|
|
280
|
-
children: content
|
|
281
|
-
})]
|
|
282
|
-
}))
|
|
453
|
+
children: [!!open && !context.breakpointActive && !context.hoverable && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
454
|
+
fullscreen: true,
|
|
455
|
+
onPress: (0, import_helpers.composeEventHandlers)(onPress, context.onOpenToggle)
|
|
456
|
+
}), content]
|
|
283
457
|
});
|
|
284
458
|
}
|
|
285
|
-
var PopoverContentImpl = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
459
|
+
var PopoverContentImpl = /* @__PURE__ */React.forwardRef(function PopoverContentImpl2(props, forwardedRef) {
|
|
286
460
|
var {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
461
|
+
trapFocus,
|
|
462
|
+
scope,
|
|
463
|
+
onOpenAutoFocus,
|
|
464
|
+
onCloseAutoFocus,
|
|
465
|
+
disableOutsidePointerEvents,
|
|
466
|
+
disableFocusScope,
|
|
467
|
+
onEscapeKeyDown,
|
|
468
|
+
onPointerDownOutside,
|
|
469
|
+
onFocusOutside,
|
|
470
|
+
onInteractOutside,
|
|
471
|
+
children,
|
|
472
|
+
enableRemoveScroll,
|
|
473
|
+
freezeContentsWhenHidden,
|
|
474
|
+
setIsFullyHidden,
|
|
475
|
+
lazyMount,
|
|
476
|
+
forceUnmount,
|
|
477
|
+
context,
|
|
478
|
+
open,
|
|
479
|
+
alwaysDisable,
|
|
480
|
+
...contentProps
|
|
481
|
+
} = props;
|
|
482
|
+
var {
|
|
483
|
+
keepChildrenMounted,
|
|
484
|
+
disableDismissable
|
|
485
|
+
} = context;
|
|
486
|
+
var handleExitComplete = React.useCallback(function () {
|
|
487
|
+
setIsFullyHidden === null || setIsFullyHidden === void 0 || setIsFullyHidden(true);
|
|
488
|
+
}, [setIsFullyHidden]);
|
|
489
|
+
var contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.ResetPresence, {
|
|
490
|
+
disable: context.breakpointActive,
|
|
491
|
+
children
|
|
492
|
+
});
|
|
493
|
+
React.useCallback(function () {
|
|
494
|
+
context.onOpenChange(false, "press");
|
|
495
|
+
}, [context]);
|
|
496
|
+
if (!context.breakpointActive) {}
|
|
497
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate.Animate, {
|
|
317
498
|
type: "presence",
|
|
318
|
-
present:
|
|
319
|
-
keepChildrenMounted:
|
|
499
|
+
present: Boolean(open),
|
|
500
|
+
keepChildrenMounted: Boolean(keepChildrenMounted),
|
|
320
501
|
onExitComplete: handleExitComplete,
|
|
321
502
|
lazyMount,
|
|
322
503
|
passThrough: context.breakpointActive,
|
|
@@ -326,6 +507,11 @@ var PopoverContentImpl = /* @__PURE__ */React.forwardRef(function (props, forwar
|
|
|
326
507
|
id: context.contentId,
|
|
327
508
|
ref: forwardedRef,
|
|
328
509
|
passThrough: context.breakpointActive,
|
|
510
|
+
...(!contentProps.unstyled && {
|
|
511
|
+
size: "$true",
|
|
512
|
+
backgroundColor: "$background",
|
|
513
|
+
alignItems: "center"
|
|
514
|
+
}),
|
|
329
515
|
...contentProps,
|
|
330
516
|
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PortalAdaptSafe, {
|
|
331
517
|
context,
|
|
@@ -334,212 +520,241 @@ var PopoverContentImpl = /* @__PURE__ */React.forwardRef(function (props, forwar
|
|
|
334
520
|
}, context.contentId)
|
|
335
521
|
});
|
|
336
522
|
});
|
|
337
|
-
var PopoverClose = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
523
|
+
var PopoverClose = /* @__PURE__ */React.forwardRef(function PopoverClose2(props, forwardedRef) {
|
|
524
|
+
var {
|
|
525
|
+
scope,
|
|
526
|
+
...rest
|
|
527
|
+
} = props;
|
|
528
|
+
var context = usePopoverContext(scope);
|
|
529
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
530
|
+
...rest,
|
|
531
|
+
ref: forwardedRef,
|
|
532
|
+
componentName: "PopoverClose",
|
|
533
|
+
onPress: (0, import_helpers.composeEventHandlers)(props.onPress, function () {
|
|
534
|
+
var _context_onOpenChange;
|
|
535
|
+
return context === null || context === void 0 ? void 0 : (_context_onOpenChange = context.onOpenChange) === null || _context_onOpenChange === void 0 ? void 0 : _context_onOpenChange.call(context, false, "press");
|
|
536
|
+
})
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
var PopoverArrow = import_popper.PopperArrowFrame.styleable(function PopoverArrow2(props, forwardedRef) {
|
|
540
|
+
var {
|
|
541
|
+
scope,
|
|
542
|
+
...rest
|
|
543
|
+
} = props;
|
|
544
|
+
var context = usePopoverContext(scope);
|
|
545
|
+
if ((0, import_adapt.useAdaptIsActive)(context.adaptScope)) return null;
|
|
546
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.PopperArrow, {
|
|
547
|
+
scope,
|
|
548
|
+
componentName: "PopoverArrow",
|
|
549
|
+
...rest,
|
|
550
|
+
ref: forwardedRef
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
var PopoverScrollView = /* @__PURE__ */React.forwardRef(function (param, ref) {
|
|
554
|
+
var {
|
|
555
|
+
scope,
|
|
556
|
+
...props
|
|
557
|
+
} = param;
|
|
558
|
+
var context = usePopoverContext(scope);
|
|
559
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_scroll_view.ScrollView, {
|
|
560
|
+
ref,
|
|
561
|
+
pointerEvents: context.breakpointActive ? "none" : void 0,
|
|
562
|
+
scrollEnabled: !context.breakpointActive,
|
|
563
|
+
passThrough: context.breakpointActive,
|
|
564
|
+
...props
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
var DEFAULT_SCOPE = "";
|
|
568
|
+
var Popover = (0, import_helpers.withStaticProperties)(/* @__PURE__ */React.forwardRef(function Popover2(param, ref) {
|
|
569
|
+
var {
|
|
570
|
+
scope = DEFAULT_SCOPE,
|
|
571
|
+
...props
|
|
572
|
+
} = param;
|
|
573
|
+
var id = React.useId();
|
|
574
|
+
var adaptScope = `PopoverAdapt${scope}`;
|
|
575
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_adapt.AdaptParent, {
|
|
576
|
+
scope: adaptScope,
|
|
577
|
+
portal: true,
|
|
578
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverInner, {
|
|
579
|
+
adaptScope,
|
|
374
580
|
ref,
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
scrollEnabled: !context.breakpointActive,
|
|
378
|
-
passThrough: context.breakpointActive,
|
|
581
|
+
id,
|
|
582
|
+
scope,
|
|
379
583
|
...props
|
|
380
|
-
})
|
|
381
|
-
})
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}),
|
|
451
|
-
[anchorTo, setAnchorToRaw] = React.useState(),
|
|
452
|
-
setAnchorTo = (0, import_core.useCreateShallowSetState)(setAnchorToRaw);
|
|
453
|
-
React.useImperativeHandle(forwardedRef, function () {
|
|
454
|
-
return {
|
|
455
|
-
anchorTo: setAnchorTo,
|
|
456
|
-
toggle: function () {
|
|
457
|
-
return setOpen(function (prev) {
|
|
458
|
-
return !prev;
|
|
459
|
-
});
|
|
460
|
-
},
|
|
461
|
-
open: function () {
|
|
462
|
-
return setOpen(!0);
|
|
463
|
-
},
|
|
464
|
-
close: function () {
|
|
465
|
-
return setOpen(!1);
|
|
466
|
-
},
|
|
467
|
-
setOpen
|
|
468
|
-
};
|
|
469
|
-
});
|
|
470
|
-
var popoverContext = {
|
|
471
|
-
popoverScope: scope,
|
|
472
|
-
adaptScope,
|
|
473
|
-
id,
|
|
474
|
-
contentId: React.useId(),
|
|
475
|
-
triggerRef,
|
|
476
|
-
open,
|
|
477
|
-
breakpointActive: isAdapted,
|
|
478
|
-
onOpenChange: handleOpenChange,
|
|
479
|
-
onOpenToggle: (0, import_core.useEvent)(function () {
|
|
480
|
-
open && isAdapted || setOpen(!open);
|
|
481
|
-
}),
|
|
482
|
-
hasCustomAnchor,
|
|
483
|
-
anchorTo,
|
|
484
|
-
onCustomAnchorAdd: React.useCallback(function () {
|
|
485
|
-
return setHasCustomAnchor(!0);
|
|
486
|
-
}, []),
|
|
487
|
-
onCustomAnchorRemove: React.useCallback(function () {
|
|
488
|
-
return setHasCustomAnchor(!1);
|
|
489
|
-
}, []),
|
|
490
|
-
keepChildrenMounted
|
|
491
|
-
},
|
|
492
|
-
memoizedChildren = React.useMemo(function () {
|
|
493
|
-
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverContext.Provider, {
|
|
494
|
-
scope,
|
|
495
|
-
...popoverContext,
|
|
496
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverSheetController, {
|
|
497
|
-
context: popoverContext,
|
|
498
|
-
onOpenChange: setOpen,
|
|
499
|
-
children
|
|
500
|
-
})
|
|
584
|
+
})
|
|
585
|
+
});
|
|
586
|
+
}), {
|
|
587
|
+
Anchor: PopoverAnchor,
|
|
588
|
+
Arrow: PopoverArrow,
|
|
589
|
+
Trigger: PopoverTrigger,
|
|
590
|
+
Content: PopoverContent,
|
|
591
|
+
Close: PopoverClose,
|
|
592
|
+
Adapt: import_adapt.Adapt,
|
|
593
|
+
ScrollView: PopoverScrollView,
|
|
594
|
+
FocusScope: import_focus_scope.FocusScopeController
|
|
595
|
+
});
|
|
596
|
+
var PopoverInner = /* @__PURE__ */React.forwardRef(function PopoverInner2(props, forwardedRef) {
|
|
597
|
+
var {
|
|
598
|
+
children,
|
|
599
|
+
open: openProp,
|
|
600
|
+
defaultOpen,
|
|
601
|
+
onOpenChange,
|
|
602
|
+
scope = DEFAULT_SCOPE,
|
|
603
|
+
keepChildrenMounted: keepChildrenMountedProp,
|
|
604
|
+
hoverable,
|
|
605
|
+
disableFocus,
|
|
606
|
+
disableDismissable,
|
|
607
|
+
zIndex,
|
|
608
|
+
id,
|
|
609
|
+
adaptScope,
|
|
610
|
+
...restProps
|
|
611
|
+
} = props;
|
|
612
|
+
var triggerRef = React.useRef(null);
|
|
613
|
+
var [hasCustomAnchor, setHasCustomAnchor] = React.useState(false);
|
|
614
|
+
var viaRef = React.useRef(void 0);
|
|
615
|
+
var [keepChildrenMounted] = (0, import_use_controllable_state.useControllableState)({
|
|
616
|
+
prop: keepChildrenMountedProp,
|
|
617
|
+
defaultProp: false,
|
|
618
|
+
transition: keepChildrenMountedProp === "lazy"
|
|
619
|
+
});
|
|
620
|
+
var [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
|
|
621
|
+
prop: openProp,
|
|
622
|
+
defaultProp: defaultOpen || false,
|
|
623
|
+
onChange: function (val) {
|
|
624
|
+
onOpenChange === null || onOpenChange === void 0 || onOpenChange(val, viaRef.current);
|
|
625
|
+
}
|
|
626
|
+
});
|
|
627
|
+
React.useEffect(function () {
|
|
628
|
+
if (!open) return;
|
|
629
|
+
openPopovers.add(setOpen);
|
|
630
|
+
return function () {
|
|
631
|
+
openPopovers.delete(setOpen);
|
|
632
|
+
};
|
|
633
|
+
}, [open, setOpen]);
|
|
634
|
+
var handleOpenChange = (0, import_core.useEvent)(function (val, via) {
|
|
635
|
+
viaRef.current = via;
|
|
636
|
+
setOpen(val);
|
|
637
|
+
});
|
|
638
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(adaptScope);
|
|
639
|
+
var floatingContext = (0, import_useFloatingContext.useFloatingContext)({
|
|
640
|
+
open,
|
|
641
|
+
setOpen: handleOpenChange,
|
|
642
|
+
disable: isAdapted,
|
|
643
|
+
hoverable,
|
|
644
|
+
disableFocus
|
|
645
|
+
});
|
|
646
|
+
var [anchorTo, setAnchorToRaw] = React.useState();
|
|
647
|
+
var setAnchorTo = (0, import_core.useCreateShallowSetState)(setAnchorToRaw);
|
|
648
|
+
React.useImperativeHandle(forwardedRef, function () {
|
|
649
|
+
return {
|
|
650
|
+
anchorTo: setAnchorTo,
|
|
651
|
+
toggle: function () {
|
|
652
|
+
return setOpen(function (prev) {
|
|
653
|
+
return !prev;
|
|
501
654
|
});
|
|
502
|
-
},
|
|
503
|
-
|
|
655
|
+
},
|
|
656
|
+
open: function () {
|
|
657
|
+
return setOpen(true);
|
|
658
|
+
},
|
|
659
|
+
close: function () {
|
|
660
|
+
return setOpen(false);
|
|
661
|
+
},
|
|
662
|
+
setOpen
|
|
663
|
+
};
|
|
664
|
+
});
|
|
665
|
+
var contentId = React.useId();
|
|
666
|
+
var onOpenToggle = (0, import_core.useEvent)(function () {
|
|
667
|
+
if (open && isAdapted) return;
|
|
668
|
+
setOpen(!open);
|
|
669
|
+
});
|
|
670
|
+
var onCustomAnchorAdd = React.useCallback(function () {
|
|
671
|
+
return setHasCustomAnchor(true);
|
|
672
|
+
}, []);
|
|
673
|
+
var onCustomAnchorRemove = React.useCallback(function () {
|
|
674
|
+
return setHasCustomAnchor(false);
|
|
675
|
+
}, []);
|
|
676
|
+
var contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_popper.Popper, {
|
|
677
|
+
open,
|
|
678
|
+
passThrough: isAdapted,
|
|
679
|
+
scope,
|
|
680
|
+
stayInFrame: true,
|
|
681
|
+
...restProps,
|
|
682
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverContextProvider, {
|
|
683
|
+
scope,
|
|
684
|
+
open,
|
|
685
|
+
onOpenChange: handleOpenChange,
|
|
686
|
+
onOpenToggle,
|
|
687
|
+
triggerRef,
|
|
688
|
+
id,
|
|
689
|
+
contentId,
|
|
690
|
+
hasCustomAnchor,
|
|
691
|
+
onCustomAnchorAdd,
|
|
692
|
+
onCustomAnchorRemove,
|
|
693
|
+
anchorTo,
|
|
694
|
+
adaptScope,
|
|
695
|
+
breakpointActive: isAdapted,
|
|
696
|
+
keepChildrenMounted,
|
|
697
|
+
disableDismissable,
|
|
698
|
+
hoverable,
|
|
699
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverSheetController, {
|
|
700
|
+
onOpenChange: setOpen,
|
|
504
701
|
open,
|
|
505
|
-
passThrough: isAdapted,
|
|
506
702
|
scope,
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
});
|
|
703
|
+
children
|
|
704
|
+
})
|
|
705
|
+
})
|
|
706
|
+
});
|
|
707
|
+
var result = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
708
|
+
children: import_constants.isWeb ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_floating.FloatingOverrideContext.Provider, {
|
|
709
|
+
value: floatingContext,
|
|
710
|
+
children: contents
|
|
711
|
+
}) : contents
|
|
517
712
|
});
|
|
713
|
+
if (zIndex !== void 0) return /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverZIndexContext.Provider, {
|
|
714
|
+
value: zIndex,
|
|
715
|
+
children: result
|
|
716
|
+
});
|
|
717
|
+
return result;
|
|
718
|
+
});
|
|
518
719
|
function getState(open) {
|
|
519
720
|
return open ? "open" : "closed";
|
|
520
721
|
}
|
|
521
722
|
var PopoverSheetController = function (param) {
|
|
723
|
+
var {
|
|
724
|
+
open,
|
|
725
|
+
scope,
|
|
726
|
+
...props
|
|
727
|
+
} = param;
|
|
728
|
+
var context = usePopoverContext(scope);
|
|
729
|
+
var showSheet = useShowPopoverSheet(context, open);
|
|
730
|
+
var breakpointActive = context === null || context === void 0 ? void 0 : context.breakpointActive;
|
|
731
|
+
var getShowSheet = (0, import_core.useGet)(showSheet);
|
|
732
|
+
var [isAdaptFullyHidden, setIsAdaptFullyHidden] = React.useState(!open);
|
|
733
|
+
if (open && isAdaptFullyHidden) setIsAdaptFullyHidden(false);
|
|
734
|
+
var handleSheetAnimationComplete = React.useCallback(function (param2) {
|
|
522
735
|
var {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
736
|
+
open: isOpen
|
|
737
|
+
} = param2;
|
|
738
|
+
if (!isOpen) setIsAdaptFullyHidden(true);
|
|
739
|
+
}, []);
|
|
740
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_controller.SheetController, {
|
|
741
|
+
onOpenChange: function (val) {
|
|
742
|
+
if (getShowSheet()) {
|
|
743
|
+
var _props_onOpenChange;
|
|
744
|
+
(_props_onOpenChange = props.onOpenChange) === null || _props_onOpenChange === void 0 || _props_onOpenChange.call(props, val);
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
onAnimationComplete: handleSheetAnimationComplete,
|
|
748
|
+
open,
|
|
749
|
+
hidden: !breakpointActive,
|
|
750
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(PopoverAdaptHiddenContext.Provider, {
|
|
751
|
+
value: isAdaptFullyHidden,
|
|
538
752
|
children: props.children
|
|
539
|
-
})
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
753
|
+
})
|
|
754
|
+
});
|
|
755
|
+
};
|
|
756
|
+
var useShowPopoverSheet = function (context, open) {
|
|
757
|
+
var isAdapted = (0, import_adapt.useAdaptIsActive)(context.adaptScope);
|
|
758
|
+
return open === false ? false : isAdapted;
|
|
759
|
+
};
|
|
545
760
|
//# sourceMappingURL=Popover.native.js.map
|