@xsolla/xui-b2c-popover 0.209.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.
@@ -0,0 +1,688 @@
1
+ // src/Popover.tsx
2
+ import { forwardRef, useCallback as useCallback2, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
3
+
4
+ // ../../foundation/primitives-native/src/Box.tsx
5
+ import {
6
+ View,
7
+ Pressable,
8
+ Image
9
+ } from "react-native";
10
+ import { jsx } from "react/jsx-runtime";
11
+ var roleToAccessibilityRole = {
12
+ button: "button",
13
+ link: "link",
14
+ img: "image",
15
+ image: "image",
16
+ summary: "summary",
17
+ switch: "switch",
18
+ checkbox: "checkbox",
19
+ radio: "radio",
20
+ heading: "header",
21
+ text: "text",
22
+ search: "search",
23
+ alert: "alert",
24
+ none: "none",
25
+ presentation: "none",
26
+ progressbar: "progressbar",
27
+ scrollbar: "scrollbar",
28
+ adjustable: "adjustable",
29
+ tab: "tab",
30
+ menu: "menu",
31
+ menuitem: "menuitem",
32
+ list: "list",
33
+ timer: "timer"
34
+ };
35
+ var toGapValue = (gap) => {
36
+ if (gap === void 0) return void 0;
37
+ if (typeof gap === "number") return gap;
38
+ const pxMatch = /^(\d+(?:\.\d+)?)px$/.exec(gap);
39
+ if (pxMatch) return Number(pxMatch[1]);
40
+ const asNumber = Number(gap);
41
+ return Number.isFinite(asNumber) ? asNumber : void 0;
42
+ };
43
+ var Box = ({
44
+ children,
45
+ onPress,
46
+ onLayout,
47
+ onMoveShouldSetResponder,
48
+ onResponderGrant,
49
+ onResponderMove,
50
+ onResponderRelease,
51
+ onResponderTerminate,
52
+ backgroundColor,
53
+ borderColor,
54
+ borderWidth,
55
+ borderBottomWidth,
56
+ borderBottomColor,
57
+ borderTopWidth,
58
+ borderTopColor,
59
+ borderLeftWidth,
60
+ borderLeftColor,
61
+ borderRightWidth,
62
+ borderRightColor,
63
+ borderRadius,
64
+ borderStyle,
65
+ height,
66
+ padding,
67
+ paddingHorizontal,
68
+ paddingVertical,
69
+ margin,
70
+ marginTop,
71
+ marginBottom,
72
+ marginLeft,
73
+ marginRight,
74
+ flexDirection,
75
+ flexWrap,
76
+ alignItems,
77
+ justifyContent,
78
+ alignSelf,
79
+ position,
80
+ top,
81
+ bottom,
82
+ left,
83
+ right,
84
+ width,
85
+ minWidth,
86
+ minHeight,
87
+ maxWidth,
88
+ maxHeight,
89
+ flex,
90
+ flexShrink,
91
+ gap,
92
+ overflow,
93
+ opacity,
94
+ zIndex,
95
+ hoverStyle,
96
+ pressStyle,
97
+ style,
98
+ disabled,
99
+ "data-testid": dataTestId,
100
+ testID,
101
+ as,
102
+ src,
103
+ alt,
104
+ ...rest
105
+ }) => {
106
+ const getContainerStyle = (pressed) => ({
107
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
108
+ borderColor,
109
+ borderWidth,
110
+ borderBottomWidth,
111
+ borderBottomColor,
112
+ borderTopWidth,
113
+ borderTopColor,
114
+ borderLeftWidth,
115
+ borderLeftColor,
116
+ borderRightWidth,
117
+ borderRightColor,
118
+ borderRadius,
119
+ borderStyle,
120
+ overflow,
121
+ opacity: opacity ?? (disabled ? 0.5 : void 0),
122
+ zIndex,
123
+ height,
124
+ width,
125
+ minWidth,
126
+ minHeight,
127
+ maxWidth,
128
+ maxHeight,
129
+ padding,
130
+ paddingHorizontal,
131
+ paddingVertical,
132
+ margin,
133
+ marginTop,
134
+ marginBottom,
135
+ marginLeft,
136
+ marginRight,
137
+ flexDirection,
138
+ flexWrap,
139
+ alignItems,
140
+ justifyContent,
141
+ alignSelf,
142
+ position,
143
+ top,
144
+ bottom,
145
+ left,
146
+ right,
147
+ flex,
148
+ flexShrink,
149
+ gap: toGapValue(gap),
150
+ ...style
151
+ });
152
+ const finalTestID = dataTestId || testID;
153
+ const {
154
+ role,
155
+ tabIndex,
156
+ onKeyDown,
157
+ onKeyUp,
158
+ "aria-label": ariaLabel,
159
+ "aria-labelledby": _ariaLabelledBy,
160
+ "aria-current": _ariaCurrent,
161
+ "aria-disabled": ariaDisabled,
162
+ "aria-live": ariaLive,
163
+ "aria-busy": ariaBusy,
164
+ className,
165
+ "data-testid": _dataTestId,
166
+ cursor: _cursor,
167
+ type: _type,
168
+ ...nativeRest
169
+ } = rest;
170
+ const accessibilityRole = typeof role === "string" && roleToAccessibilityRole[role] || (as === "button" ? "button" : void 0);
171
+ const isDisabled = Boolean(disabled || ariaDisabled);
172
+ const accessibilityState = {
173
+ disabled: isDisabled || void 0,
174
+ busy: Boolean(ariaBusy) || void 0
175
+ };
176
+ const accessibilityLiveRegion = ariaLive === "polite" || ariaLive === "assertive" ? ariaLive : void 0;
177
+ if (as === "img" && src) {
178
+ const imageStyle = {
179
+ width,
180
+ height,
181
+ borderRadius,
182
+ position,
183
+ top,
184
+ bottom,
185
+ left,
186
+ right,
187
+ ...style
188
+ };
189
+ return /* @__PURE__ */ jsx(
190
+ Image,
191
+ {
192
+ source: { uri: src },
193
+ style: imageStyle,
194
+ testID: finalTestID,
195
+ accessibilityLabel: typeof ariaLabel === "string" ? ariaLabel : alt,
196
+ resizeMode: "cover",
197
+ ...nativeRest
198
+ }
199
+ );
200
+ }
201
+ if (onPress || as === "button") {
202
+ return /* @__PURE__ */ jsx(
203
+ Pressable,
204
+ {
205
+ onPress: !isDisabled && onPress ? onPress : void 0,
206
+ disabled: isDisabled,
207
+ onLayout,
208
+ onMoveShouldSetResponder,
209
+ onResponderGrant,
210
+ onResponderMove,
211
+ onResponderRelease,
212
+ onResponderTerminate,
213
+ style: ({ pressed }) => getContainerStyle(pressed),
214
+ testID: finalTestID,
215
+ accessibilityRole,
216
+ accessibilityLabel: typeof ariaLabel === "string" ? ariaLabel : void 0,
217
+ accessibilityState,
218
+ accessibilityLiveRegion,
219
+ ...nativeRest,
220
+ children
221
+ }
222
+ );
223
+ }
224
+ return /* @__PURE__ */ jsx(
225
+ View,
226
+ {
227
+ style: getContainerStyle(),
228
+ testID: finalTestID,
229
+ onLayout,
230
+ onMoveShouldSetResponder,
231
+ onResponderGrant,
232
+ onResponderMove,
233
+ onResponderRelease,
234
+ onResponderTerminate,
235
+ accessibilityRole,
236
+ accessibilityLabel: typeof ariaLabel === "string" ? ariaLabel : void 0,
237
+ accessibilityState,
238
+ accessibilityLiveRegion,
239
+ ...nativeRest,
240
+ children
241
+ }
242
+ );
243
+ };
244
+
245
+ // src/Popover.tsx
246
+ import { radiusScale, useResolvedTheme } from "@xsolla/xui-core";
247
+
248
+ // src/PopoverRoot.native.tsx
249
+ import { memo } from "react";
250
+ var PopoverRoot = memo((_props) => {
251
+ return null;
252
+ });
253
+ PopoverRoot.displayName = "PopoverRoot";
254
+
255
+ // src/PopoverTitleBar.tsx
256
+ import { memo as memo2 } from "react";
257
+ import { IconButton } from "@xsolla/xui-button";
258
+ import { Drag, Pin, Remove, Unpin } from "@xsolla/xui-icons-base";
259
+ import { Typography } from "@xsolla/xui-typography";
260
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
261
+ var PopoverTitleBar = memo2(
262
+ ({
263
+ title,
264
+ draggable,
265
+ dragHandleProps,
266
+ pinned,
267
+ onPinnedChange,
268
+ onClose,
269
+ testID
270
+ }) => /* @__PURE__ */ jsxs(
271
+ "div",
272
+ {
273
+ "data-testid": testID,
274
+ style: {
275
+ flexShrink: 0,
276
+ width: "100%",
277
+ display: "flex",
278
+ flexDirection: "row",
279
+ alignItems: "center",
280
+ gap: 8,
281
+ cursor: draggable ? "grab" : void 0
282
+ },
283
+ ...draggable ? dragHandleProps : {},
284
+ children: [
285
+ draggable && /* @__PURE__ */ jsx2(
286
+ "span",
287
+ {
288
+ "data-xui-popover-drag-handle": "",
289
+ role: "button",
290
+ tabIndex: 0,
291
+ "aria-label": "Move popover",
292
+ style: { display: "inline-flex", flexShrink: 0 },
293
+ children: /* @__PURE__ */ jsx2(Drag, {})
294
+ }
295
+ ),
296
+ /* @__PURE__ */ jsx2("div", { style: { flex: 1, minWidth: 0, overflow: "hidden" }, children: title && /* @__PURE__ */ jsx2(Typography, { variant: "bodyLgAccent", noWrap: true, children: title }) }),
297
+ onPinnedChange && /* @__PURE__ */ jsx2(
298
+ IconButton,
299
+ {
300
+ variant: "secondary",
301
+ tone: "mono",
302
+ size: "xs",
303
+ icon: pinned ? /* @__PURE__ */ jsx2(Unpin, {}) : /* @__PURE__ */ jsx2(Pin, {}),
304
+ onPress: () => onPinnedChange(!pinned),
305
+ "aria-label": pinned ? "Unpin popover" : "Pin popover",
306
+ "aria-pressed": pinned
307
+ }
308
+ ),
309
+ onClose && /* @__PURE__ */ jsx2(
310
+ IconButton,
311
+ {
312
+ variant: "secondary",
313
+ tone: "mono",
314
+ size: "xs",
315
+ icon: /* @__PURE__ */ jsx2(Remove, {}),
316
+ onPress: onClose,
317
+ "aria-label": "Close popover"
318
+ }
319
+ )
320
+ ]
321
+ }
322
+ )
323
+ );
324
+ PopoverTitleBar.displayName = "PopoverTitleBar";
325
+
326
+ // src/usePopoverDrag.ts
327
+ import {
328
+ useCallback,
329
+ useEffect,
330
+ useRef,
331
+ useState
332
+ } from "react";
333
+ var KEYBOARD_STEP = 16;
334
+ var EDGE_MARGIN = 8;
335
+ var isInteractive = (target) => target instanceof Element && target.closest("button, a, input") !== null;
336
+ var clampToViewport = (position, panel) => {
337
+ if (!panel || typeof window === "undefined") return position;
338
+ const { width, height } = panel.getBoundingClientRect();
339
+ const maxX = Math.max(EDGE_MARGIN, window.innerWidth - width - EDGE_MARGIN);
340
+ const maxY = Math.max(EDGE_MARGIN, window.innerHeight - height - EDGE_MARGIN);
341
+ return {
342
+ x: Math.min(Math.max(position.x, EDGE_MARGIN), maxX),
343
+ y: Math.min(Math.max(position.y, EDGE_MARGIN), maxY)
344
+ };
345
+ };
346
+ var usePopoverDrag = ({
347
+ enabled,
348
+ initialPosition,
349
+ onPositionChange
350
+ }) => {
351
+ const panelRef = useRef(null);
352
+ const [position, setPosition] = useState(
353
+ initialPosition
354
+ );
355
+ const [isDragging, setIsDragging] = useState(false);
356
+ const grabOffset = useRef({ x: 0, y: 0 });
357
+ useEffect(() => {
358
+ if (!enabled) setPosition(void 0);
359
+ }, [enabled]);
360
+ const commit = useCallback(
361
+ (next) => {
362
+ const clamped = clampToViewport(next, panelRef.current);
363
+ setPosition(clamped);
364
+ onPositionChange?.(clamped);
365
+ },
366
+ [onPositionChange]
367
+ );
368
+ const onPointerDown = useCallback(
369
+ (event) => {
370
+ if (!enabled || event.button !== 0) return;
371
+ if (isInteractive(event.target)) return;
372
+ const panel = panelRef.current;
373
+ if (!panel) return;
374
+ event.preventDefault();
375
+ const rect = panel.getBoundingClientRect();
376
+ grabOffset.current = {
377
+ x: event.clientX - rect.left,
378
+ y: event.clientY - rect.top
379
+ };
380
+ setIsDragging(true);
381
+ },
382
+ [enabled]
383
+ );
384
+ const onKeyDown = useCallback(
385
+ (event) => {
386
+ if (!enabled) return;
387
+ if (!(event.target instanceof Element) || !event.target.closest("[data-xui-popover-drag-handle]")) {
388
+ return;
389
+ }
390
+ const deltas = {
391
+ ArrowUp: { x: 0, y: -KEYBOARD_STEP },
392
+ ArrowDown: { x: 0, y: KEYBOARD_STEP },
393
+ ArrowLeft: { x: -KEYBOARD_STEP, y: 0 },
394
+ ArrowRight: { x: KEYBOARD_STEP, y: 0 }
395
+ };
396
+ const delta = deltas[event.key];
397
+ if (!delta) return;
398
+ event.preventDefault();
399
+ const rect = panelRef.current?.getBoundingClientRect();
400
+ const base = position ?? { x: rect?.left ?? 0, y: rect?.top ?? 0 };
401
+ commit({ x: base.x + delta.x, y: base.y + delta.y });
402
+ },
403
+ [commit, enabled, position]
404
+ );
405
+ useEffect(() => {
406
+ if (!isDragging || typeof document === "undefined") return;
407
+ const handleMove = (event) => {
408
+ commit({
409
+ x: event.clientX - grabOffset.current.x,
410
+ y: event.clientY - grabOffset.current.y
411
+ });
412
+ };
413
+ const stop = () => setIsDragging(false);
414
+ document.addEventListener("pointermove", handleMove);
415
+ document.addEventListener("pointerup", stop);
416
+ document.addEventListener("pointercancel", stop);
417
+ return () => {
418
+ document.removeEventListener("pointermove", handleMove);
419
+ document.removeEventListener("pointerup", stop);
420
+ document.removeEventListener("pointercancel", stop);
421
+ };
422
+ }, [commit, isDragging]);
423
+ return {
424
+ position: enabled ? position : void 0,
425
+ panelRef,
426
+ dragHandleProps: { onPointerDown, onKeyDown },
427
+ isDragging
428
+ };
429
+ };
430
+
431
+ // src/useDeviceType.ts
432
+ import { useEffect as useEffect2, useState as useState2 } from "react";
433
+ var POPOVER_BREAKPOINTS = {
434
+ /** Widths at or below this are `mobile` (Figma: "Mobile: 320-768px"). */
435
+ mobileMax: 768,
436
+ /** Widths at or below this, but above `mobileMax`, are `tablet` (Figma: "Tablet: 769-1023px"). */
437
+ tabletMax: 1023
438
+ };
439
+ var resolveDevice = (width) => {
440
+ if (width <= POPOVER_BREAKPOINTS.mobileMax) return "mobile";
441
+ if (width <= POPOVER_BREAKPOINTS.tabletMax) return "tablet";
442
+ return "desktop";
443
+ };
444
+ var useDeviceType = (override) => {
445
+ const [device, setDevice] = useState2(
446
+ () => typeof window === "undefined" ? "desktop" : resolveDevice(window.innerWidth)
447
+ );
448
+ useEffect2(() => {
449
+ if (override || typeof window === "undefined") return;
450
+ const update = () => setDevice(resolveDevice(window.innerWidth));
451
+ update();
452
+ window.addEventListener("resize", update);
453
+ return () => window.removeEventListener("resize", update);
454
+ }, [override]);
455
+ return override ?? device;
456
+ };
457
+
458
+ // src/Popover.tsx
459
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
460
+ var FOCUSABLE_SELECTORS = 'button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
461
+ var DEFAULT_WIDTH = 400;
462
+ var PANEL_PADDING = 16;
463
+ var SECTION_GAP = 24;
464
+ var PANEL_RADIUS = radiusScale["200"];
465
+ var BACKDROP_BLUR = "blur(24px)";
466
+ var ANIMATION_DURATION = 200;
467
+ var isElementVisible = (el) => {
468
+ if (el.offsetParent === null && getComputedStyle(el).position !== "fixed")
469
+ return false;
470
+ const style = getComputedStyle(el);
471
+ return style.visibility !== "hidden" && style.display !== "none";
472
+ };
473
+ var getFocusableElements = (container) => Array.from(
474
+ container.querySelectorAll(FOCUSABLE_SELECTORS)
475
+ ).filter(isElementVisible);
476
+ var Popover = forwardRef(
477
+ ({
478
+ open = false,
479
+ onClose,
480
+ device: deviceProp,
481
+ width = DEFAULT_WIDTH,
482
+ draggable = false,
483
+ initialPosition,
484
+ onPositionChange,
485
+ title,
486
+ pinned,
487
+ onPinnedChange,
488
+ showCloseButton = true,
489
+ titleBar,
490
+ header,
491
+ children,
492
+ footer,
493
+ closeOnOverlayClick = true,
494
+ closeOnEscape = true,
495
+ scrim = true,
496
+ backgroundColor,
497
+ blur = true,
498
+ styled: styledProps,
499
+ initialFocusRef,
500
+ "aria-label": ariaLabel,
501
+ testID,
502
+ themeMode,
503
+ themeProductContext = "b2c"
504
+ }, ref) => {
505
+ const { theme } = useResolvedTheme({ themeMode, themeProductContext });
506
+ const device = useDeviceType(deviceProp);
507
+ const fullScreen = device === "mobile";
508
+ const canDrag = draggable && !fullScreen;
509
+ const dismissOnScrim = closeOnOverlayClick && !pinned && !fullScreen;
510
+ const [mounted, setMounted] = useState3(open);
511
+ const dialogRef = useRef2(null);
512
+ const previousActiveElement = useRef2(null);
513
+ const { position, panelRef, dragHandleProps } = usePopoverDrag({
514
+ enabled: canDrag,
515
+ initialPosition,
516
+ onPositionChange
517
+ });
518
+ useEffect3(() => {
519
+ if (open) setMounted(true);
520
+ }, [open]);
521
+ useEffect3(() => {
522
+ if (!open || typeof document === "undefined") return;
523
+ previousActiveElement.current = document.activeElement;
524
+ const focusTarget = initialFocusRef?.current || dialogRef.current && getFocusableElements(dialogRef.current)[0];
525
+ if (focusTarget) focusTarget.focus();
526
+ else dialogRef.current?.focus();
527
+ }, [open, initialFocusRef]);
528
+ useEffect3(() => {
529
+ if (!open || !closeOnEscape || !onClose) return;
530
+ if (typeof document === "undefined") return;
531
+ const handleKeyDown2 = (event) => {
532
+ if (event.key === "Escape") onClose();
533
+ };
534
+ document.addEventListener("keydown", handleKeyDown2);
535
+ return () => document.removeEventListener("keydown", handleKeyDown2);
536
+ }, [open, closeOnEscape, onClose]);
537
+ const handleKeyDown = useCallback2((event) => {
538
+ if (event.key !== "Tab" || !dialogRef.current) return;
539
+ if (typeof document === "undefined") return;
540
+ const focusableElements = getFocusableElements(dialogRef.current);
541
+ const firstElement = focusableElements[0];
542
+ const lastElement = focusableElements[focusableElements.length - 1];
543
+ if (!firstElement) {
544
+ event.preventDefault();
545
+ return;
546
+ }
547
+ if (event.shiftKey && document.activeElement === firstElement) {
548
+ event.preventDefault();
549
+ lastElement.focus();
550
+ } else if (!event.shiftKey && document.activeElement === lastElement) {
551
+ event.preventDefault();
552
+ firstElement.focus();
553
+ }
554
+ }, []);
555
+ const setPanelNode = useCallback2(
556
+ (node) => {
557
+ dialogRef.current = node;
558
+ panelRef.current = node;
559
+ if (typeof ref === "function") ref(node);
560
+ else if (ref) ref.current = node;
561
+ },
562
+ [panelRef, ref]
563
+ );
564
+ const handleExited = useCallback2(() => {
565
+ setMounted(false);
566
+ previousActiveElement.current?.focus();
567
+ }, []);
568
+ if (!mounted) return null;
569
+ const closeControl = showCloseButton ? onClose : void 0;
570
+ const hasDefaultTitleBar = !titleBar && (title || closeControl || canDrag);
571
+ const accessibleName = ariaLabel ?? (typeof title === "string" ? title : void 0);
572
+ return /* @__PURE__ */ jsx3(
573
+ PopoverRoot,
574
+ {
575
+ open,
576
+ onExited: handleExited,
577
+ onBackdropClick: dismissOnScrim ? onClose : void 0,
578
+ scrimColor: scrim && !fullScreen ? theme.colors.layer?.scrim ?? "rgba(0, 0, 0, 0.75)" : void 0,
579
+ fullScreen,
580
+ position,
581
+ animationDuration: ANIMATION_DURATION,
582
+ children: /* @__PURE__ */ jsxs2(
583
+ Box,
584
+ {
585
+ testID,
586
+ ref: setPanelNode,
587
+ role: "dialog",
588
+ "aria-modal": fullScreen || scrim ? "true" : void 0,
589
+ "aria-label": accessibleName,
590
+ "data-popover-device": device,
591
+ "data-popover-pinned": pinned ? "true" : void 0,
592
+ tabIndex: -1,
593
+ onKeyDown: handleKeyDown,
594
+ style: {
595
+ boxSizing: "border-box",
596
+ display: "flex",
597
+ flexDirection: "column",
598
+ alignItems: "center",
599
+ gap: SECTION_GAP,
600
+ width: fullScreen ? "100%" : width,
601
+ maxWidth: "100%",
602
+ height: fullScreen ? "100%" : void 0,
603
+ maxHeight: "100%",
604
+ outline: "none",
605
+ color: theme.colors.content.primary,
606
+ backgroundColor: backgroundColor ?? theme.colors.background.primary,
607
+ paddingLeft: PANEL_PADDING,
608
+ paddingRight: PANEL_PADDING,
609
+ // The Figma mobile frame carries only a bottom inset — its top bars
610
+ // are full-bleed, and its children supply their own side padding.
611
+ // A slot component cannot assume the caller re-pads for one
612
+ // breakpoint, so the sides stay inset and only the top is dropped.
613
+ paddingTop: fullScreen ? 0 : PANEL_PADDING,
614
+ paddingBottom: PANEL_PADDING,
615
+ borderRadius: fullScreen ? 0 : PANEL_RADIUS,
616
+ border: fullScreen ? void 0 : `1px solid ${theme.colors.border.secondary}`,
617
+ boxShadow: fullScreen ? void 0 : theme.shadow.popover,
618
+ backdropFilter: !fullScreen && blur ? BACKDROP_BLUR : void 0,
619
+ ...styledProps
620
+ },
621
+ children: [
622
+ titleBar ?? (hasDefaultTitleBar ? /* @__PURE__ */ jsx3(
623
+ PopoverTitleBar,
624
+ {
625
+ title,
626
+ draggable: canDrag,
627
+ dragHandleProps,
628
+ pinned,
629
+ onPinnedChange,
630
+ onClose: closeControl,
631
+ testID: testID ? `${testID}-title-bar` : void 0
632
+ }
633
+ ) : null),
634
+ header && /* @__PURE__ */ jsx3("div", { style: { flexShrink: 0, width: "100%" }, children: header }),
635
+ /* @__PURE__ */ jsx3(
636
+ "div",
637
+ {
638
+ style: {
639
+ flex: 1,
640
+ minHeight: 0,
641
+ width: "100%",
642
+ overflowY: "auto",
643
+ overscrollBehavior: "contain"
644
+ },
645
+ children
646
+ }
647
+ ),
648
+ footer && /* @__PURE__ */ jsx3("div", { style: { flexShrink: 0, width: "100%" }, children: footer })
649
+ ]
650
+ }
651
+ )
652
+ }
653
+ );
654
+ }
655
+ );
656
+ Popover.displayName = "Popover";
657
+
658
+ // src/usePopover.ts
659
+ import { useCallback as useCallback3, useState as useState4 } from "react";
660
+ function usePopover(options) {
661
+ const [isOpen, setIsOpen] = useState4(false);
662
+ const open = useCallback3(() => {
663
+ setIsOpen(true);
664
+ options?.onOpen?.();
665
+ }, [options]);
666
+ const close = useCallback3(() => {
667
+ setIsOpen(false);
668
+ options?.onClose?.();
669
+ }, [options]);
670
+ const toggle = useCallback3(() => {
671
+ setIsOpen((previous) => {
672
+ if (previous) options?.onClose?.();
673
+ else options?.onOpen?.();
674
+ return !previous;
675
+ });
676
+ }, [options]);
677
+ return { isOpen, open, close, toggle };
678
+ }
679
+ export {
680
+ POPOVER_BREAKPOINTS,
681
+ Popover,
682
+ PopoverTitleBar,
683
+ resolveDevice,
684
+ useDeviceType,
685
+ usePopover,
686
+ usePopoverDrag
687
+ };
688
+ //# sourceMappingURL=index.mjs.map