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