@tamagui/popover 1.89.26 → 1.89.27-1708113113238

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.
@@ -33,322 +33,416 @@ __export(Popover_exports, {
33
33
  usePopoverContext: () => usePopoverContext
34
34
  });
35
35
  module.exports = __toCommonJS(Popover_exports);
36
- var import_polyfill_dev = require("@tamagui/polyfill-dev"), import_adapt = require("@tamagui/adapt"), import_animate = require("@tamagui/animate"), import_animate_presence = require("@tamagui/animate-presence"), import_aria_hidden = require("@tamagui/aria-hidden"), import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_floating = require("@tamagui/floating"), import_focus_scope = require("@tamagui/focus-scope"), import_helpers = require("@tamagui/helpers"), 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_native = require("react-native"), import_useFloatingContext = require("./useFloatingContext"), import_jsx_runtime = require("react/jsx-runtime");
37
- const POPOVER_SCOPE = "PopoverScope", PopoverContext = (0, import_core.createStyledContext)({}), usePopoverContext = PopoverContext.useStyledContext, PopoverAnchor = React.forwardRef(function(props, forwardedRef) {
38
- const { __scopePopover, ...rest } = props, context = usePopoverContext(__scopePopover), { onCustomAnchorAdd, onCustomAnchorRemove } = context || {};
39
- return React.useEffect(() => (onCustomAnchorAdd(), () => onCustomAnchorRemove()), [onCustomAnchorAdd, onCustomAnchorRemove]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
40
- import_popper.PopperAnchor,
41
- {
42
- __scopePopper: __scopePopover || POPOVER_SCOPE,
43
- ...rest,
44
- ref: forwardedRef
36
+ var import_polyfill_dev = require("@tamagui/polyfill-dev"), import_adapt = require("@tamagui/adapt"), import_animate = require("@tamagui/animate"), import_animate_presence = require("@tamagui/animate-presence"), import_aria_hidden = require("@tamagui/aria-hidden"), import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_floating = require("@tamagui/floating"), import_focus_scope = require("@tamagui/focus-scope"), import_helpers = require("@tamagui/helpers"), 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_native = require("react-native"), import_useFloatingContext = require("./useFloatingContext");
37
+ function _array_like_to_array(arr, len) {
38
+ (len == null || len > arr.length) && (len = arr.length);
39
+ for (var i = 0, arr2 = new Array(len); i < len; i++)
40
+ arr2[i] = arr[i];
41
+ return arr2;
42
+ }
43
+ function _array_with_holes(arr) {
44
+ if (Array.isArray(arr))
45
+ return arr;
46
+ }
47
+ function _define_property(obj, key, value) {
48
+ return key in obj ? Object.defineProperty(obj, key, {
49
+ value,
50
+ enumerable: !0,
51
+ configurable: !0,
52
+ writable: !0
53
+ }) : obj[key] = value, obj;
54
+ }
55
+ function _iterable_to_array_limit(arr, i) {
56
+ var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
57
+ if (_i != null) {
58
+ var _arr = [], _n = !0, _d = !1, _s, _e;
59
+ try {
60
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
61
+ ;
62
+ } catch (err) {
63
+ _d = !0, _e = err;
64
+ } finally {
65
+ try {
66
+ !_n && _i.return != null && _i.return();
67
+ } finally {
68
+ if (_d)
69
+ throw _e;
70
+ }
45
71
  }
46
- );
47
- }), PopoverTrigger = React.forwardRef(function(props, forwardedRef) {
48
- const { __scopePopover, ...rest } = props, context = usePopoverContext(__scopePopover), anchorTo = context.anchorTo, composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
72
+ return _arr;
73
+ }
74
+ }
75
+ function _non_iterable_rest() {
76
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
77
+ }
78
+ function _object_spread(target) {
79
+ for (var i = 1; i < arguments.length; i++) {
80
+ var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
81
+ typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
82
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
83
+ }))), ownKeys2.forEach(function(key) {
84
+ _define_property(target, key, source[key]);
85
+ });
86
+ }
87
+ return target;
88
+ }
89
+ function ownKeys(object, enumerableOnly) {
90
+ var keys = Object.keys(object);
91
+ if (Object.getOwnPropertySymbols) {
92
+ var symbols = Object.getOwnPropertySymbols(object);
93
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
94
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
95
+ })), keys.push.apply(keys, symbols);
96
+ }
97
+ return keys;
98
+ }
99
+ function _object_spread_props(target, source) {
100
+ return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
101
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
102
+ }), target;
103
+ }
104
+ function _object_without_properties(source, excluded) {
105
+ if (source == null)
106
+ return {};
107
+ var target = _object_without_properties_loose(source, excluded), key, i;
108
+ if (Object.getOwnPropertySymbols) {
109
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
110
+ for (i = 0; i < sourceSymbolKeys.length; i++)
111
+ key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
112
+ }
113
+ return target;
114
+ }
115
+ function _object_without_properties_loose(source, excluded) {
116
+ if (source == null)
117
+ return {};
118
+ var target = {}, sourceKeys = Object.keys(source), key, i;
119
+ for (i = 0; i < sourceKeys.length; i++)
120
+ key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
121
+ return target;
122
+ }
123
+ function _sliced_to_array(arr, i) {
124
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
125
+ }
126
+ function _unsupported_iterable_to_array(o, minLen) {
127
+ if (o) {
128
+ if (typeof o == "string")
129
+ return _array_like_to_array(o, minLen);
130
+ var n = Object.prototype.toString.call(o).slice(8, -1);
131
+ if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
132
+ return Array.from(n);
133
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
134
+ return _array_like_to_array(o, minLen);
135
+ }
136
+ }
137
+ var POPOVER_SCOPE = "PopoverScope", PopoverContext = (0, import_core.createStyledContext)({}), usePopoverContext = PopoverContext.useStyledContext, PopoverAnchor = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
138
+ var __scopePopover = props.__scopePopover, rest = _object_without_properties(props, [
139
+ "__scopePopover"
140
+ ]), context = usePopoverContext(__scopePopover), _ref = context || {}, onCustomAnchorAdd = _ref.onCustomAnchorAdd, onCustomAnchorRemove = _ref.onCustomAnchorRemove;
141
+ return React.useEffect(function() {
142
+ return onCustomAnchorAdd(), function() {
143
+ return onCustomAnchorRemove();
144
+ };
145
+ }, [
146
+ onCustomAnchorAdd,
147
+ onCustomAnchorRemove
148
+ ]), /* @__PURE__ */ React.createElement(import_popper.PopperAnchor, _object_spread_props(_object_spread({
149
+ __scopePopper: __scopePopover || POPOVER_SCOPE
150
+ }, rest), {
151
+ ref: forwardedRef
152
+ }));
153
+ }), PopoverTrigger = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
154
+ var __scopePopover = props.__scopePopover, rest = _object_without_properties(props, [
155
+ "__scopePopover"
156
+ ]), context = usePopoverContext(__scopePopover), anchorTo = context.anchorTo, composedTriggerRef = (0, import_compose_refs.useComposedRefs)(forwardedRef, context.triggerRef);
49
157
  if (anchorTo) {
50
- let virtualRef = {
51
- current: {
52
- getBoundingClientRect: () => import_constants.isWeb ? DOMRect.fromRect(anchorTo) : anchorTo,
53
- ...!import_constants.isWeb && {
54
- measure: (c) => c(anchorTo == null ? void 0 : anchorTo.x, anchorTo == null ? void 0 : anchorTo.y, anchorTo == null ? void 0 : anchorTo.width, anchorTo == null ? void 0 : anchorTo.height),
55
- measureInWindow: (c) => c(anchorTo == null ? void 0 : anchorTo.x, anchorTo == null ? void 0 : anchorTo.y, anchorTo == null ? void 0 : anchorTo.width, anchorTo == null ? void 0 : anchorTo.height)
158
+ var virtualRef = {
159
+ current: _object_spread({
160
+ getBoundingClientRect: function() {
161
+ return import_constants.isWeb ? DOMRect.fromRect(anchorTo) : anchorTo;
56
162
  }
57
- }
163
+ }, !import_constants.isWeb && {
164
+ measure: function(c) {
165
+ return c(anchorTo == null ? void 0 : anchorTo.x, anchorTo == null ? void 0 : anchorTo.y, anchorTo == null ? void 0 : anchorTo.width, anchorTo == null ? void 0 : anchorTo.height);
166
+ },
167
+ measureInWindow: function(c) {
168
+ return c(anchorTo == null ? void 0 : anchorTo.x, anchorTo == null ? void 0 : anchorTo.y, anchorTo == null ? void 0 : anchorTo.width, anchorTo == null ? void 0 : anchorTo.height);
169
+ }
170
+ })
58
171
  };
59
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
60
- import_popper.PopperAnchor,
61
- {
62
- virtualRef,
63
- __scopePopper: __scopePopover || POPOVER_SCOPE
64
- }
65
- );
172
+ return /* @__PURE__ */ React.createElement(import_popper.PopperAnchor, {
173
+ virtualRef,
174
+ __scopePopper: __scopePopover || POPOVER_SCOPE
175
+ });
66
176
  }
67
177
  if (!props.children)
68
178
  return null;
69
- const trigger = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
- import_core.View,
71
- {
72
- "aria-haspopup": "dialog",
73
- "aria-expanded": context.open,
74
- "data-state": getState(context.open),
75
- ...rest,
76
- ref: composedTriggerRef,
77
- onPress: (0, import_helpers.composeEventHandlers)(props.onPress, context.onOpenToggle)
78
- }
79
- );
80
- return context.hasCustomAnchor ? trigger : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperAnchor, { __scopePopper: __scopePopover || POPOVER_SCOPE, asChild: !0, children: trigger });
81
- }), PopoverContent = import_popper.PopperContentFrame.extractable(
82
- React.forwardRef(function(props, forwardedRef) {
83
- const {
84
- allowPinchZoom,
85
- trapFocus,
86
- disableRemoveScroll = !0,
87
- zIndex,
88
- __scopePopover,
89
- ...contentImplProps
90
- } = props, context = usePopoverContext(__scopePopover), contentRef = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef), isRightClickOutsideRef = React.useRef(!1), [isFullyHidden, setIsFullyHidden] = React.useState(!context.open);
91
- return context.open && isFullyHidden && setIsFullyHidden(!1), React.useEffect(() => {
92
- if (!context.open)
93
- return;
94
- const content = contentRef.current;
179
+ var trigger = /* @__PURE__ */ React.createElement(import_core.View, _object_spread_props(_object_spread({
180
+ "aria-haspopup": "dialog",
181
+ "aria-expanded": context.open,
182
+ // TODO not matching
183
+ // aria-controls={context.contentId}
184
+ "data-state": getState(context.open)
185
+ }, rest), {
186
+ // @ts-ignore
187
+ ref: composedTriggerRef,
188
+ onPress: (0, import_helpers.composeEventHandlers)(props.onPress, context.onOpenToggle)
189
+ }));
190
+ return context.hasCustomAnchor ? trigger : /* @__PURE__ */ React.createElement(import_popper.PopperAnchor, {
191
+ __scopePopper: __scopePopover || POPOVER_SCOPE,
192
+ asChild: !0
193
+ }, trigger);
194
+ }), PopoverContent = import_popper.PopperContentFrame.extractable(/* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
195
+ var allowPinchZoom = props.allowPinchZoom, trapFocus = props.trapFocus, _props_disableRemoveScroll = props.disableRemoveScroll, disableRemoveScroll = _props_disableRemoveScroll === void 0 ? !0 : _props_disableRemoveScroll, zIndex = props.zIndex, __scopePopover = props.__scopePopover, contentImplProps = _object_without_properties(props, [
196
+ "allowPinchZoom",
197
+ "trapFocus",
198
+ "disableRemoveScroll",
199
+ "zIndex",
200
+ "__scopePopover"
201
+ ]), context = usePopoverContext(__scopePopover), contentRef = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, contentRef), isRightClickOutsideRef = React.useRef(!1), _React_useState = _sliced_to_array(React.useState(!context.open), 2), isFullyHidden = _React_useState[0], setIsFullyHidden = _React_useState[1];
202
+ return context.open && isFullyHidden && setIsFullyHidden(!1), React.useEffect(function() {
203
+ if (context.open) {
204
+ var content = contentRef.current;
95
205
  if (content)
96
206
  return (0, import_aria_hidden.hideOthers)(content);
97
- }, [context.open]), !context.keepChildrenMounted && isFullyHidden ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContentPortal, { __scopePopover, 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)(
98
- PopoverContentImpl,
99
- {
100
- ...contentImplProps,
101
- disableRemoveScroll,
102
- ref: composedRefs,
103
- setIsFullyHidden,
104
- __scopePopover,
105
- trapFocus: trapFocus ?? context.open,
106
- disableOutsidePointerEvents: !0,
107
- onCloseAutoFocus: (0, import_helpers.composeEventHandlers)(props.onCloseAutoFocus, (event) => {
108
- var _a;
109
- event.preventDefault(), isRightClickOutsideRef.current || (_a = context.triggerRef.current) == null || _a.focus();
110
- }),
111
- onPointerDownOutside: (0, import_helpers.composeEventHandlers)(
112
- props.onPointerDownOutside,
113
- (event) => {
114
- const originalEvent = event.detail.originalEvent, ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0, isRightClick = originalEvent.button === 2 || ctrlLeftClick;
115
- isRightClickOutsideRef.current = isRightClick;
116
- },
117
- { checkDefaultPrevented: !1 }
118
- ),
119
- onFocusOutside: (0, import_helpers.composeEventHandlers)(
120
- props.onFocusOutside,
121
- (event) => event.preventDefault(),
122
- { checkDefaultPrevented: !1 }
123
- )
124
- }
125
- ) }) });
126
- })
127
- );
128
- function PopoverRepropagateContext(props) {
129
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_popper.PopperContext.Provider, { scope: props.scope, ...props.popperContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContext.Provider, { ...props.context, children: props.children }) });
130
- }
131
- function PopoverContentPortal(props) {
132
- const { __scopePopover } = props, zIndex = props.zIndex ?? 15e4, context = usePopoverContext(__scopePopover), popperContext = (0, import_popper.usePopperContext)(__scopePopover || POPOVER_SCOPE), themeName = (0, import_core.useThemeName)();
133
- let contents = props.children;
134
- return (import_react_native.Platform.OS === "android" || import_react_native.Platform.OS === "ios") && (contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
135
- PopoverRepropagateContext,
136
- {
137
- scope: __scopePopover || POPOVER_SCOPE,
138
- popperContext,
139
- context,
140
- children: props.children
141
207
  }
142
- )), /* @__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: [
143
- !!context.open && !context.breakpointActive && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
144
- import_stacks.YStack,
145
- {
146
- fullscreen: !0,
147
- onPress: (0, import_helpers.composeEventHandlers)(props.onPress, context.onOpenToggle)
148
- }
149
- ),
150
- contents
151
- ] }) });
152
- }
153
- const PopoverContentImpl = React.forwardRef(function(props, forwardedRef) {
154
- const {
155
- trapFocus,
208
+ }, [
209
+ context.open
210
+ ]), !context.keepChildrenMounted && isFullyHidden ? null : /* @__PURE__ */ React.createElement(PopoverContentPortal, {
156
211
  __scopePopover,
157
- onOpenAutoFocus,
158
- onCloseAutoFocus,
159
- disableOutsidePointerEvents,
160
- disableFocusScope,
161
- onEscapeKeyDown,
162
- onPointerDownOutside,
163
- onFocusOutside,
164
- onInteractOutside,
165
- children,
212
+ zIndex: props.zIndex
213
+ }, /* @__PURE__ */ React.createElement(import_core.Stack, {
214
+ pointerEvents: context.open ? "auto" : "none"
215
+ }, /* @__PURE__ */ React.createElement(PopoverContentImpl, _object_spread_props(_object_spread({}, contentImplProps), {
166
216
  disableRemoveScroll,
167
- freezeContentsWhenHidden,
217
+ ref: composedRefs,
168
218
  setIsFullyHidden,
169
- ...contentProps
170
- } = props, context = usePopoverContext(__scopePopover), { open, keepChildrenMounted } = context, popperContext = (0, import_popper.usePopperContext)(__scopePopover || POPOVER_SCOPE), contents = React.useMemo(() => import_constants.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "contents" }, children }) : children, [children]);
171
- if (context.breakpointActive) {
172
- const childrenWithoutScrollView = React.Children.toArray(children).map((child) => React.isValidElement(child) && child.type === import_react_native.ScrollView ? child.props.children : child);
173
- let content = childrenWithoutScrollView;
174
- return import_react_native.Platform.OS === "android" || import_react_native.Platform.OS === "ios" ? content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
175
- import_popper.PopperContext.Provider,
176
- {
177
- scope: __scopePopover || POPOVER_SCOPE,
178
- ...popperContext,
179
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.ResetPresence, { children: childrenWithoutScrollView })
219
+ __scopePopover,
220
+ // we make sure we're not trapping once it's been closed
221
+ // (closed !== unmounted when animating out)
222
+ trapFocus: trapFocus ?? context.open,
223
+ disableOutsidePointerEvents: !0,
224
+ onCloseAutoFocus: (0, import_helpers.composeEventHandlers)(props.onCloseAutoFocus, function(event) {
225
+ var _context_triggerRef_current;
226
+ event.preventDefault(), isRightClickOutsideRef.current || (_context_triggerRef_current = context.triggerRef.current) === null || _context_triggerRef_current === void 0 || _context_triggerRef_current.focus();
227
+ }),
228
+ onPointerDownOutside: (0, import_helpers.composeEventHandlers)(props.onPointerDownOutside, function(event) {
229
+ var originalEvent = event.detail.originalEvent, ctrlLeftClick = originalEvent.button === 0 && originalEvent.ctrlKey === !0, isRightClick = originalEvent.button === 2 || ctrlLeftClick;
230
+ isRightClickOutsideRef.current = isRightClick;
231
+ }, {
232
+ checkDefaultPrevented: !1
233
+ }),
234
+ // When focus is trapped, a `focusout` event may still happen.
235
+ // We make sure we don't trigger our `onDismiss` in such case.
236
+ onFocusOutside: (0, import_helpers.composeEventHandlers)(props.onFocusOutside, function(event) {
237
+ return event.preventDefault();
238
+ }, {
239
+ checkDefaultPrevented: !1
240
+ })
241
+ }))));
242
+ }));
243
+ function PopoverRepropagateContext(props) {
244
+ return /* @__PURE__ */ React.createElement(import_popper.PopperContext.Provider, _object_spread({
245
+ scope: props.scope
246
+ }, props.popperContext), /* @__PURE__ */ React.createElement(PopoverContext.Provider, props.context, props.children));
247
+ }
248
+ function PopoverContentPortal(props) {
249
+ var __scopePopover = props.__scopePopover, _props_zIndex, zIndex = (_props_zIndex = props.zIndex) !== null && _props_zIndex !== void 0 ? _props_zIndex : 15e4, context = usePopoverContext(__scopePopover), popperContext = (0, import_popper.usePopperContext)(__scopePopover || POPOVER_SCOPE), themeName = (0, import_core.useThemeName)(), contents = props.children;
250
+ return (import_react_native.Platform.OS === "android" || import_react_native.Platform.OS === "ios") && (contents = /* @__PURE__ */ React.createElement(PopoverRepropagateContext, {
251
+ scope: __scopePopover || POPOVER_SCOPE,
252
+ popperContext,
253
+ context
254
+ }, props.children)), /* @__PURE__ */ React.createElement(import_portal.Portal, {
255
+ zIndex
256
+ }, /* @__PURE__ */ React.createElement(import_core.Theme, {
257
+ forceClassName: !0,
258
+ name: themeName
259
+ }, !!context.open && !context.breakpointActive && /* @__PURE__ */ React.createElement(import_stacks.YStack, {
260
+ fullscreen: !0,
261
+ onPress: (0, import_helpers.composeEventHandlers)(props.onPress, context.onOpenToggle)
262
+ }), contents));
263
+ }
264
+ var PopoverContentImpl = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
265
+ var trapFocus = props.trapFocus, __scopePopover = props.__scopePopover, onOpenAutoFocus = props.onOpenAutoFocus, onCloseAutoFocus = props.onCloseAutoFocus, disableOutsidePointerEvents = props.disableOutsidePointerEvents, disableFocusScope = props.disableFocusScope, onEscapeKeyDown = props.onEscapeKeyDown, onPointerDownOutside = props.onPointerDownOutside, onFocusOutside = props.onFocusOutside, onInteractOutside = props.onInteractOutside, children = props.children, disableRemoveScroll = props.disableRemoveScroll, freezeContentsWhenHidden = props.freezeContentsWhenHidden, setIsFullyHidden = props.setIsFullyHidden, contentProps = _object_without_properties(props, [
266
+ "trapFocus",
267
+ "__scopePopover",
268
+ "onOpenAutoFocus",
269
+ "onCloseAutoFocus",
270
+ "disableOutsidePointerEvents",
271
+ "disableFocusScope",
272
+ "onEscapeKeyDown",
273
+ "onPointerDownOutside",
274
+ "onFocusOutside",
275
+ "onInteractOutside",
276
+ "children",
277
+ "disableRemoveScroll",
278
+ "freezeContentsWhenHidden",
279
+ "setIsFullyHidden"
280
+ ]), context = usePopoverContext(__scopePopover), open = context.open, keepChildrenMounted = context.keepChildrenMounted, popperContext = (0, import_popper.usePopperContext)(__scopePopover || POPOVER_SCOPE), contents = React.useMemo(function() {
281
+ return import_constants.isWeb ? /* @__PURE__ */ React.createElement("div", {
282
+ style: {
283
+ display: "contents"
180
284
  }
181
- ) : content = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.ResetPresence, { children: content }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalItem, { hostName: `${context.id}PopoverContents`, children: content });
285
+ }, children) : children;
286
+ }, [
287
+ children
288
+ ]);
289
+ if (context.breakpointActive) {
290
+ var childrenWithoutScrollView = React.Children.toArray(children).map(function(child) {
291
+ return /* @__PURE__ */ React.isValidElement(child) && child.type === import_react_native.ScrollView ? child.props.children : child;
292
+ }), content = childrenWithoutScrollView;
293
+ return import_react_native.Platform.OS === "android" || import_react_native.Platform.OS === "ios" ? content = /* @__PURE__ */ React.createElement(import_popper.PopperContext.Provider, _object_spread({
294
+ scope: __scopePopover || POPOVER_SCOPE
295
+ }, popperContext), /* @__PURE__ */ React.createElement(import_animate_presence.ResetPresence, null, childrenWithoutScrollView)) : content = /* @__PURE__ */ React.createElement(import_animate_presence.ResetPresence, null, content), /* @__PURE__ */ React.createElement(import_portal.PortalItem, {
296
+ hostName: "".concat(context.id, "PopoverContents")
297
+ }, content);
182
298
  }
183
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
184
- import_animate.Animate,
185
- {
186
- type: "presence",
187
- present: !!open,
188
- keepChildrenMounted,
189
- onExitComplete: () => {
190
- setIsFullyHidden && setIsFullyHidden(!0);
191
- },
192
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
193
- import_popper.PopperContent,
194
- {
195
- __scopePopper: __scopePopover || POPOVER_SCOPE,
196
- "data-state": getState(open),
197
- id: context.contentId,
198
- ref: forwardedRef,
199
- ...contentProps,
200
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
201
- import_remove_scroll.RemoveScroll,
202
- {
203
- enabled: disableRemoveScroll ? !1 : open,
204
- allowPinchZoom: !0,
205
- removeScrollBar: !1,
206
- style: {
207
- display: "contents"
208
- },
209
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.ResetPresence, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
210
- import_focus_scope.FocusScope,
211
- {
212
- loop: !0,
213
- enabled: disableFocusScope ? !1 : open,
214
- trapped: trapFocus,
215
- onMountAutoFocus: onOpenAutoFocus,
216
- onUnmountAutoFocus: onCloseAutoFocus,
217
- children: contents
218
- }
219
- ) })
220
- }
221
- )
222
- },
223
- context.contentId
224
- )
299
+ return /* @__PURE__ */ React.createElement(import_animate.Animate, {
300
+ type: "presence",
301
+ present: !!open,
302
+ keepChildrenMounted,
303
+ onExitComplete: function() {
304
+ setIsFullyHidden && setIsFullyHidden(!0);
225
305
  }
226
- );
227
- }), PopoverClose = React.forwardRef(function(props, forwardedRef) {
228
- const { __scopePopover, ...rest } = props, context = usePopoverContext(__scopePopover);
229
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
230
- import_stacks.YStack,
231
- {
232
- ...rest,
233
- ref: forwardedRef,
234
- componentName: "PopoverClose",
235
- onPress: (0, import_helpers.composeEventHandlers)(
236
- props.onPress,
237
- () => context.onOpenChange(!1, "press")
238
- )
306
+ }, /* @__PURE__ */ React.createElement(import_popper.PopperContent, _object_spread({
307
+ __scopePopper: __scopePopover || POPOVER_SCOPE,
308
+ key: context.contentId,
309
+ "data-state": getState(open),
310
+ id: context.contentId,
311
+ ref: forwardedRef
312
+ }, contentProps), /* @__PURE__ */ React.createElement(import_remove_scroll.RemoveScroll, {
313
+ enabled: disableRemoveScroll ? !1 : open,
314
+ allowPinchZoom: !0,
315
+ // causes lots of bugs on touch web on site
316
+ removeScrollBar: !1,
317
+ style: {
318
+ display: "contents"
239
319
  }
240
- );
241
- }), PopoverArrow = import_popper.PopperArrow.styleable(
242
- function(props, forwardedRef) {
243
- const { __scopePopover, ...rest } = props, context = usePopoverContext(__scopePopover);
244
- return useSheetBreakpointActive(context.sheetBreakpoint) ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
245
- import_popper.PopperArrow,
246
- {
247
- __scopePopper: __scopePopover || POPOVER_SCOPE,
248
- componentName: "PopoverArrow",
249
- ...rest,
250
- ref: forwardedRef
251
- }
252
- );
253
- }
254
- ), Popover = (0, import_helpers.withStaticProperties)(
255
- React.forwardRef(
256
- (props, forwardedRef) => {
257
- const {
258
- children,
259
- open: openProp,
260
- defaultOpen,
261
- onOpenChange,
262
- __scopePopover,
263
- keepChildrenMounted,
264
- hoverable,
265
- disableFocus,
266
- ...restProps
267
- } = props, id = React.useId(), { when, AdaptProvider } = (0, import_adapt.useAdaptParent)({
268
- Contents: React.useCallback(() => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.PortalHost, { name: `${id}PopoverContents` }), [])
269
- }), sheetBreakpoint = when, triggerRef = React.useRef(null), [hasCustomAnchor, setHasCustomAnchor] = React.useState(!1), viaRef = React.useRef(), [open, setOpen] = (0, import_use_controllable_state.useControllableState)({
270
- prop: openProp,
271
- defaultProp: defaultOpen || !1,
272
- onChange: (val) => {
273
- onOpenChange == null || onOpenChange(val, viaRef.current);
274
- }
275
- }), sheetActive = useSheetBreakpointActive(sheetBreakpoint), floatingContext = (0, import_useFloatingContext.useFloatingContext)({
276
- open,
277
- setOpen: (val, via) => {
278
- viaRef.current = via, setOpen(val);
279
- },
280
- disable: sheetActive,
281
- hoverable,
282
- disableFocus
283
- }), [anchorTo, setAnchorTo] = React.useState();
284
- React.useImperativeHandle(forwardedRef, () => ({
285
- anchorTo: setAnchorTo
286
- }));
287
- const popoverContext = {
288
- id,
289
- sheetBreakpoint,
290
- contentId: React.useId(),
291
- triggerRef,
292
- open,
293
- breakpointActive: sheetActive,
294
- onOpenChange: (val, via) => {
295
- viaRef.current = via, setOpen(val);
296
- },
297
- onOpenToggle: (0, import_core.useEvent)(() => {
298
- open && sheetActive || setOpen(!open);
299
- }),
300
- hasCustomAnchor,
301
- anchorTo,
302
- onCustomAnchorAdd: React.useCallback(() => setHasCustomAnchor(!0), []),
303
- onCustomAnchorRemove: React.useCallback(() => setHasCustomAnchor(!1), []),
304
- keepChildrenMounted
305
- }, contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
306
- import_popper.Popper,
307
- {
308
- __scopePopper: __scopePopover || POPOVER_SCOPE,
309
- stayInFrame: !0,
310
- ...restProps,
311
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverContext.Provider, { scope: __scopePopover, ...popoverContext, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PopoverSheetController, { onOpenChange: setOpen, children }) })
312
- }
313
- );
314
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AdaptProvider, { children: import_constants.isWeb ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_floating.FloatingOverrideContext.Provider, { value: floatingContext, children: contents }) : contents });
320
+ }, /* @__PURE__ */ React.createElement(import_animate_presence.ResetPresence, null, /* @__PURE__ */ React.createElement(import_focus_scope.FocusScope, {
321
+ loop: !0,
322
+ enabled: disableFocusScope ? !1 : open,
323
+ trapped: trapFocus,
324
+ onMountAutoFocus: onOpenAutoFocus,
325
+ onUnmountAutoFocus: onCloseAutoFocus
326
+ }, contents)))));
327
+ }), PopoverClose = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
328
+ var __scopePopover = props.__scopePopover, rest = _object_without_properties(props, [
329
+ "__scopePopover"
330
+ ]), context = usePopoverContext(__scopePopover);
331
+ return /* @__PURE__ */ React.createElement(import_stacks.YStack, _object_spread_props(_object_spread({}, rest), {
332
+ ref: forwardedRef,
333
+ componentName: "PopoverClose",
334
+ onPress: (0, import_helpers.composeEventHandlers)(props.onPress, function() {
335
+ return context.onOpenChange(!1, "press");
336
+ })
337
+ }));
338
+ }), PopoverArrow = import_popper.PopperArrow.styleable(function(props, forwardedRef) {
339
+ var __scopePopover = props.__scopePopover, rest = _object_without_properties(props, [
340
+ "__scopePopover"
341
+ ]), context = usePopoverContext(__scopePopover), sheetActive = useSheetBreakpointActive(context.sheetBreakpoint);
342
+ return sheetActive ? null : /* @__PURE__ */ React.createElement(import_popper.PopperArrow, _object_spread_props(_object_spread({
343
+ __scopePopper: __scopePopover || POPOVER_SCOPE,
344
+ componentName: "PopoverArrow"
345
+ }, rest), {
346
+ ref: forwardedRef
347
+ }));
348
+ }), Popover = (0, import_helpers.withStaticProperties)(/* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
349
+ var children = props.children, openProp = props.open, defaultOpen = props.defaultOpen, onOpenChange = props.onOpenChange, __scopePopover = props.__scopePopover, keepChildrenMounted = props.keepChildrenMounted, hoverable = props.hoverable, disableFocus = props.disableFocus, restProps = _object_without_properties(props, [
350
+ "children",
351
+ "open",
352
+ "defaultOpen",
353
+ "onOpenChange",
354
+ "__scopePopover",
355
+ "keepChildrenMounted",
356
+ "hoverable",
357
+ "disableFocus"
358
+ ]), id = React.useId(), _useAdaptParent = (0, import_adapt.useAdaptParent)({
359
+ Contents: React.useCallback(function() {
360
+ return /* @__PURE__ */ React.createElement(import_portal.PortalHost, {
361
+ name: "".concat(id, "PopoverContents")
362
+ });
363
+ }, [])
364
+ }), when = _useAdaptParent.when, AdaptProvider = _useAdaptParent.AdaptProvider, sheetBreakpoint = when, triggerRef = React.useRef(null), _React_useState = _sliced_to_array(React.useState(!1), 2), hasCustomAnchor = _React_useState[0], setHasCustomAnchor = _React_useState[1], viaRef = React.useRef(), _useControllableState = _sliced_to_array((0, import_use_controllable_state.useControllableState)({
365
+ prop: openProp,
366
+ defaultProp: defaultOpen || !1,
367
+ onChange: function(val) {
368
+ onOpenChange == null || onOpenChange(val, viaRef.current);
315
369
  }
316
- ),
317
- {
318
- Anchor: PopoverAnchor,
319
- Arrow: PopoverArrow,
320
- Trigger: PopoverTrigger,
321
- Content: PopoverContent,
322
- Close: PopoverClose,
323
- Adapt: import_adapt.Adapt,
324
- ScrollView: import_react_native.ScrollView,
325
- Sheet: import_sheet.Sheet.Controlled
326
- }
327
- );
370
+ }), 2), open = _useControllableState[0], setOpen = _useControllableState[1], sheetActive = useSheetBreakpointActive(sheetBreakpoint), floatingContext = (0, import_useFloatingContext.useFloatingContext)({
371
+ open,
372
+ setOpen: function(val, via) {
373
+ viaRef.current = via, setOpen(val);
374
+ },
375
+ disable: sheetActive,
376
+ hoverable,
377
+ disableFocus
378
+ }), _React_useState1 = _sliced_to_array(React.useState(), 2), anchorTo = _React_useState1[0], setAnchorTo = _React_useState1[1];
379
+ React.useImperativeHandle(forwardedRef, function() {
380
+ return {
381
+ anchorTo: setAnchorTo
382
+ };
383
+ });
384
+ var popoverContext = {
385
+ id,
386
+ sheetBreakpoint,
387
+ contentId: React.useId(),
388
+ triggerRef,
389
+ open,
390
+ breakpointActive: sheetActive,
391
+ onOpenChange: function(val, via) {
392
+ viaRef.current = via, setOpen(val);
393
+ },
394
+ onOpenToggle: (0, import_core.useEvent)(function() {
395
+ open && sheetActive || setOpen(!open);
396
+ }),
397
+ hasCustomAnchor,
398
+ anchorTo,
399
+ onCustomAnchorAdd: React.useCallback(function() {
400
+ return setHasCustomAnchor(!0);
401
+ }, []),
402
+ onCustomAnchorRemove: React.useCallback(function() {
403
+ return setHasCustomAnchor(!1);
404
+ }, []),
405
+ keepChildrenMounted
406
+ }, contents = /* @__PURE__ */ React.createElement(import_popper.Popper, _object_spread({
407
+ __scopePopper: __scopePopover || POPOVER_SCOPE,
408
+ stayInFrame: !0
409
+ }, restProps), /* @__PURE__ */ React.createElement(PopoverContext.Provider, _object_spread({
410
+ scope: __scopePopover
411
+ }, popoverContext), /* @__PURE__ */ React.createElement(PopoverSheetController, {
412
+ onOpenChange: setOpen
413
+ }, children)));
414
+ return /* @__PURE__ */ React.createElement(AdaptProvider, null, import_constants.isWeb ? /* @__PURE__ */ React.createElement(import_floating.FloatingOverrideContext.Provider, {
415
+ value: floatingContext
416
+ }, contents) : contents);
417
+ }), {
418
+ Anchor: PopoverAnchor,
419
+ Arrow: PopoverArrow,
420
+ Trigger: PopoverTrigger,
421
+ Content: PopoverContent,
422
+ Close: PopoverClose,
423
+ Adapt: import_adapt.Adapt,
424
+ ScrollView: import_react_native.ScrollView,
425
+ Sheet: import_sheet.Sheet.Controlled
426
+ });
328
427
  function getState(open) {
329
428
  return open ? "open" : "closed";
330
429
  }
331
- const PopoverSheetController = ({
332
- __scopePopover,
333
- ...props
334
- }) => {
335
- const context = usePopoverContext(__scopePopover), showSheet = useShowPopoverSheet(context), breakpointActive = context.breakpointActive, getShowSheet = (0, import_core.useGet)(showSheet);
336
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
337
- import_sheet.SheetController,
338
- {
339
- onOpenChange: (val) => {
340
- getShowSheet() && props.onOpenChange(val);
341
- },
342
- open: context.open,
343
- hidden: breakpointActive === !1,
344
- children: props.children
345
- }
346
- );
347
- }, useSheetBreakpointActive = (breakpoint) => {
348
- const media = (0, import_core.useMedia)();
430
+ var PopoverSheetController = function(_param) {
431
+ var __scopePopover = _param.__scopePopover, props = _object_without_properties(_param, [
432
+ "__scopePopover"
433
+ ]), context = usePopoverContext(__scopePopover), showSheet = useShowPopoverSheet(context), breakpointActive = context.breakpointActive, getShowSheet = (0, import_core.useGet)(showSheet);
434
+ return /* @__PURE__ */ React.createElement(import_sheet.SheetController, {
435
+ onOpenChange: function(val) {
436
+ getShowSheet() && props.onOpenChange(val);
437
+ },
438
+ open: context.open,
439
+ hidden: breakpointActive === !1
440
+ }, props.children);
441
+ }, useSheetBreakpointActive = function(breakpoint) {
442
+ var media = (0, import_core.useMedia)();
349
443
  return typeof breakpoint == "boolean" || !breakpoint ? !!breakpoint : media[breakpoint];
350
- }, useShowPopoverSheet = (context) => {
351
- const breakpointActive = useSheetBreakpointActive(context.sheetBreakpoint);
444
+ }, useShowPopoverSheet = function(context) {
445
+ var breakpointActive = useSheetBreakpointActive(context.sheetBreakpoint);
352
446
  return context.open === !1 ? !1 : breakpointActive;
353
447
  };
354
448
  // Annotate the CommonJS export names for ESM import in node: