@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.
- package/README.md +22 -0
- package/native/index.d.mts +255 -0
- package/native/index.d.ts +255 -0
- package/native/index.js +712 -0
- package/native/index.js.map +1 -0
- package/native/index.mjs +688 -0
- package/native/index.mjs.map +1 -0
- package/package.json +60 -0
- package/web/index.d.mts +255 -0
- package/web/index.d.ts +255 -0
- package/web/index.js +842 -0
- package/web/index.js.map +1 -0
- package/web/index.mjs +808 -0
- package/web/index.mjs.map +1 -0
package/web/index.js
ADDED
|
@@ -0,0 +1,842 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
POPOVER_BREAKPOINTS: () => POPOVER_BREAKPOINTS,
|
|
34
|
+
Popover: () => Popover,
|
|
35
|
+
PopoverTitleBar: () => PopoverTitleBar,
|
|
36
|
+
resolveDevice: () => resolveDevice,
|
|
37
|
+
useDeviceType: () => useDeviceType,
|
|
38
|
+
usePopover: () => usePopover,
|
|
39
|
+
usePopoverDrag: () => usePopoverDrag
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(index_exports);
|
|
42
|
+
|
|
43
|
+
// src/Popover.tsx
|
|
44
|
+
var import_react7 = require("react");
|
|
45
|
+
|
|
46
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
47
|
+
var import_react2 = __toESM(require("react"));
|
|
48
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
49
|
+
|
|
50
|
+
// ../../foundation/primitives-web/src/filterDOMProps.ts
|
|
51
|
+
var import_react = __toESM(require("react"));
|
|
52
|
+
|
|
53
|
+
// ../../../node_modules/@emotion/memoize/dist/memoize.esm.js
|
|
54
|
+
function memoize(fn) {
|
|
55
|
+
var cache = {};
|
|
56
|
+
return function(arg) {
|
|
57
|
+
if (cache[arg] === void 0) cache[arg] = fn(arg);
|
|
58
|
+
return cache[arg];
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
var memoize_esm_default = memoize;
|
|
62
|
+
|
|
63
|
+
// ../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
|
|
64
|
+
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
|
|
65
|
+
var index = memoize_esm_default(
|
|
66
|
+
function(prop) {
|
|
67
|
+
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
|
|
68
|
+
}
|
|
69
|
+
/* Z+1 */
|
|
70
|
+
);
|
|
71
|
+
var is_prop_valid_esm_default = index;
|
|
72
|
+
|
|
73
|
+
// ../../foundation/primitives-web/src/filterDOMProps.ts
|
|
74
|
+
var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
|
|
75
|
+
// RN-only event handlers (pass isPropValid's on* pattern)
|
|
76
|
+
"onPress",
|
|
77
|
+
"onChangeText",
|
|
78
|
+
"onLayout",
|
|
79
|
+
"onMoveShouldSetResponder",
|
|
80
|
+
"onResponderGrant",
|
|
81
|
+
"onResponderMove",
|
|
82
|
+
"onResponderRelease",
|
|
83
|
+
"onResponderTerminate",
|
|
84
|
+
// SVG attributes that pass isPropValid
|
|
85
|
+
"strokeWidth",
|
|
86
|
+
// CSS properties that pass isPropValid but are used as component props
|
|
87
|
+
"overflow",
|
|
88
|
+
"opacity",
|
|
89
|
+
"cursor",
|
|
90
|
+
"fontSize",
|
|
91
|
+
"fontWeight",
|
|
92
|
+
"fontFamily",
|
|
93
|
+
"textDecoration",
|
|
94
|
+
// Cross-platform layout prop that Text consumes as CSS, never as an
|
|
95
|
+
// attribute. Pinned explicitly because it is now spread into the styled
|
|
96
|
+
// component rather than destructured away before it can reach the DOM.
|
|
97
|
+
"numberOfLines"
|
|
98
|
+
]);
|
|
99
|
+
function shouldForwardProp(key) {
|
|
100
|
+
if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
|
|
101
|
+
return is_prop_valid_esm_default(key);
|
|
102
|
+
}
|
|
103
|
+
function createFilteredElement(defaultTag) {
|
|
104
|
+
const Component = import_react.default.forwardRef(
|
|
105
|
+
({ children, elementType, ...props }, ref) => {
|
|
106
|
+
const Tag = elementType || defaultTag;
|
|
107
|
+
const htmlProps = {};
|
|
108
|
+
for (const key of Object.keys(props)) {
|
|
109
|
+
if (shouldForwardProp(key)) {
|
|
110
|
+
htmlProps[key] = props[key];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return import_react.default.createElement(
|
|
114
|
+
Tag,
|
|
115
|
+
{ ref, ...htmlProps },
|
|
116
|
+
children
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
Component.displayName = `Filtered(${defaultTag})`;
|
|
121
|
+
return Component;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// ../../foundation/primitives-web/src/Box.tsx
|
|
125
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
126
|
+
var FilteredDiv = createFilteredElement("div");
|
|
127
|
+
var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
|
|
128
|
+
display: flex;
|
|
129
|
+
box-sizing: border-box;
|
|
130
|
+
background-color: ${(props) => props.backgroundColor || "transparent"};
|
|
131
|
+
border-color: ${(props) => props.borderColor || "transparent"};
|
|
132
|
+
border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
|
|
133
|
+
|
|
134
|
+
${(props) => props.borderBottomWidth !== void 0 && `
|
|
135
|
+
border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
|
|
136
|
+
border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
|
|
137
|
+
border-bottom-style: solid;
|
|
138
|
+
`}
|
|
139
|
+
${(props) => props.borderTopWidth !== void 0 && `
|
|
140
|
+
border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
|
|
141
|
+
border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
|
|
142
|
+
border-top-style: solid;
|
|
143
|
+
`}
|
|
144
|
+
${(props) => props.borderLeftWidth !== void 0 && `
|
|
145
|
+
border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
|
|
146
|
+
border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
|
|
147
|
+
border-left-style: solid;
|
|
148
|
+
`}
|
|
149
|
+
${(props) => props.borderRightWidth !== void 0 && `
|
|
150
|
+
border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
|
|
151
|
+
border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
|
|
152
|
+
border-right-style: solid;
|
|
153
|
+
`}
|
|
154
|
+
|
|
155
|
+
border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
|
|
156
|
+
border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
|
|
157
|
+
height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
|
|
158
|
+
width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
|
|
159
|
+
min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
|
|
160
|
+
min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
|
|
161
|
+
max-width: ${(props) => typeof props.maxWidth === "number" ? `${props.maxWidth}px` : props.maxWidth || "none"};
|
|
162
|
+
max-height: ${(props) => typeof props.maxHeight === "number" ? `${props.maxHeight}px` : props.maxHeight || "none"};
|
|
163
|
+
|
|
164
|
+
padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
|
|
165
|
+
${(props) => props.paddingHorizontal && `
|
|
166
|
+
padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
|
|
167
|
+
padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
|
|
168
|
+
`}
|
|
169
|
+
${(props) => props.paddingVertical && `
|
|
170
|
+
padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
|
|
171
|
+
padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
|
|
172
|
+
`}
|
|
173
|
+
${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
|
|
174
|
+
${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
|
|
175
|
+
${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
|
|
176
|
+
${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
|
|
177
|
+
|
|
178
|
+
margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
|
|
179
|
+
${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
|
|
180
|
+
${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
|
|
181
|
+
${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
|
|
182
|
+
${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
|
|
183
|
+
|
|
184
|
+
flex-direction: ${(props) => props.flexDirection || "column"};
|
|
185
|
+
flex-wrap: ${(props) => props.flexWrap || "nowrap"};
|
|
186
|
+
align-items: ${(props) => props.alignItems || "stretch"};
|
|
187
|
+
justify-content: ${(props) => props.justifyContent || "flex-start"};
|
|
188
|
+
cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
|
|
189
|
+
position: ${(props) => props.position || "static"};
|
|
190
|
+
top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
|
|
191
|
+
bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
|
|
192
|
+
left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
|
|
193
|
+
right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
|
|
194
|
+
flex: ${(props) => props.flex};
|
|
195
|
+
flex-shrink: ${(props) => props.flexShrink ?? 1};
|
|
196
|
+
gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
|
|
197
|
+
align-self: ${(props) => props.alignSelf || "auto"};
|
|
198
|
+
/* Only emit overflow-x/y when explicitly set. Defaulting them to
|
|
199
|
+
visible after overflow would override the shorthand and break
|
|
200
|
+
clipping (e.g. OtherCard bottom-right promo image). */
|
|
201
|
+
overflow: ${(props) => props.overflow || "visible"};
|
|
202
|
+
${(props) => props.overflowX != null ? `overflow-x: ${props.overflowX};` : ""}
|
|
203
|
+
${(props) => props.overflowY != null ? `overflow-y: ${props.overflowY};` : ""}
|
|
204
|
+
z-index: ${(props) => props.zIndex};
|
|
205
|
+
opacity: ${(props) => props.opacity != null ? props.opacity : props.disabled ? 0.5 : 1};
|
|
206
|
+
pointer-events: ${(props) => props.disabled ? "none" : "auto"};
|
|
207
|
+
|
|
208
|
+
&:hover {
|
|
209
|
+
${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
|
|
210
|
+
${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
&:active {
|
|
214
|
+
${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
|
|
215
|
+
}
|
|
216
|
+
`;
|
|
217
|
+
var Box = import_react2.default.forwardRef(
|
|
218
|
+
({
|
|
219
|
+
children,
|
|
220
|
+
onPress,
|
|
221
|
+
onKeyDown,
|
|
222
|
+
onKeyUp,
|
|
223
|
+
role,
|
|
224
|
+
"aria-label": ariaLabel,
|
|
225
|
+
"aria-labelledby": ariaLabelledBy,
|
|
226
|
+
"aria-current": ariaCurrent,
|
|
227
|
+
"aria-disabled": ariaDisabled,
|
|
228
|
+
"aria-live": ariaLive,
|
|
229
|
+
"aria-busy": ariaBusy,
|
|
230
|
+
"aria-describedby": ariaDescribedBy,
|
|
231
|
+
"aria-expanded": ariaExpanded,
|
|
232
|
+
"aria-haspopup": ariaHasPopup,
|
|
233
|
+
"aria-pressed": ariaPressed,
|
|
234
|
+
"aria-controls": ariaControls,
|
|
235
|
+
tabIndex,
|
|
236
|
+
as,
|
|
237
|
+
src,
|
|
238
|
+
alt,
|
|
239
|
+
onError,
|
|
240
|
+
onLoad,
|
|
241
|
+
type,
|
|
242
|
+
disabled,
|
|
243
|
+
id,
|
|
244
|
+
testID,
|
|
245
|
+
"data-testid": dataTestId,
|
|
246
|
+
...props
|
|
247
|
+
}, ref) => {
|
|
248
|
+
if (as === "img" && src) {
|
|
249
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
250
|
+
"img",
|
|
251
|
+
{
|
|
252
|
+
src,
|
|
253
|
+
alt: alt || "",
|
|
254
|
+
onError,
|
|
255
|
+
onLoad,
|
|
256
|
+
"data-testid": dataTestId || testID,
|
|
257
|
+
style: {
|
|
258
|
+
display: "block",
|
|
259
|
+
objectFit: "cover",
|
|
260
|
+
width: typeof props.width === "number" ? `${props.width}px` : props.width,
|
|
261
|
+
height: typeof props.height === "number" ? `${props.height}px` : props.height,
|
|
262
|
+
borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
|
|
263
|
+
position: props.position,
|
|
264
|
+
top: typeof props.top === "number" ? `${props.top}px` : props.top,
|
|
265
|
+
left: typeof props.left === "number" ? `${props.left}px` : props.left,
|
|
266
|
+
right: typeof props.right === "number" ? `${props.right}px` : props.right,
|
|
267
|
+
bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom,
|
|
268
|
+
...props.style
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
274
|
+
StyledBox,
|
|
275
|
+
{
|
|
276
|
+
ref,
|
|
277
|
+
elementType: as,
|
|
278
|
+
id,
|
|
279
|
+
type: as === "button" ? type || "button" : void 0,
|
|
280
|
+
disabled: as === "button" ? disabled : void 0,
|
|
281
|
+
onClick: onPress,
|
|
282
|
+
onKeyDown,
|
|
283
|
+
onKeyUp,
|
|
284
|
+
role,
|
|
285
|
+
"aria-label": ariaLabel,
|
|
286
|
+
"aria-labelledby": ariaLabelledBy,
|
|
287
|
+
"aria-current": ariaCurrent,
|
|
288
|
+
"aria-disabled": ariaDisabled,
|
|
289
|
+
"aria-busy": ariaBusy,
|
|
290
|
+
"aria-describedby": ariaDescribedBy,
|
|
291
|
+
"aria-expanded": ariaExpanded,
|
|
292
|
+
"aria-haspopup": ariaHasPopup,
|
|
293
|
+
"aria-pressed": ariaPressed,
|
|
294
|
+
"aria-controls": ariaControls,
|
|
295
|
+
"aria-live": ariaLive,
|
|
296
|
+
tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
|
|
297
|
+
"data-testid": dataTestId || testID,
|
|
298
|
+
...props,
|
|
299
|
+
children
|
|
300
|
+
}
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
Box.displayName = "Box";
|
|
305
|
+
|
|
306
|
+
// src/Popover.tsx
|
|
307
|
+
var import_xui_core2 = require("@xsolla/xui-core");
|
|
308
|
+
|
|
309
|
+
// src/PopoverRoot.web.tsx
|
|
310
|
+
var import_react3 = require("react");
|
|
311
|
+
var import_react_dom = __toESM(require("react-dom"));
|
|
312
|
+
var import_xui_core = require("@xsolla/xui-core");
|
|
313
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
314
|
+
var OUTER_PADDING = 20;
|
|
315
|
+
var PopoverRoot = (0, import_react3.memo)(
|
|
316
|
+
({
|
|
317
|
+
children,
|
|
318
|
+
open,
|
|
319
|
+
onExited,
|
|
320
|
+
onBackdropClick,
|
|
321
|
+
scrimColor,
|
|
322
|
+
fullScreen,
|
|
323
|
+
position,
|
|
324
|
+
animationDuration,
|
|
325
|
+
testID
|
|
326
|
+
}) => {
|
|
327
|
+
const [visible, setVisible] = (0, import_react3.useState)(false);
|
|
328
|
+
const popoverLayer = (0, import_xui_core.useOverlayLayer)() + import_xui_core.MODAL_LAYER_STEP;
|
|
329
|
+
(0, import_react3.useEffect)(() => {
|
|
330
|
+
if (!open) return;
|
|
331
|
+
const frame = requestAnimationFrame(() => setVisible(true));
|
|
332
|
+
return () => cancelAnimationFrame(frame);
|
|
333
|
+
}, [open]);
|
|
334
|
+
(0, import_react3.useEffect)(() => {
|
|
335
|
+
if (open) return;
|
|
336
|
+
setVisible(false);
|
|
337
|
+
const timer = setTimeout(onExited, animationDuration);
|
|
338
|
+
return () => clearTimeout(timer);
|
|
339
|
+
}, [open, animationDuration, onExited]);
|
|
340
|
+
const locksScroll = fullScreen || Boolean(scrimColor);
|
|
341
|
+
(0, import_react3.useEffect)(() => {
|
|
342
|
+
if (!locksScroll || typeof document === "undefined") return;
|
|
343
|
+
const original = document.body.style.overflow;
|
|
344
|
+
document.body.style.overflow = "hidden";
|
|
345
|
+
return () => {
|
|
346
|
+
document.body.style.overflow = original;
|
|
347
|
+
};
|
|
348
|
+
}, [locksScroll]);
|
|
349
|
+
if (typeof document === "undefined") return null;
|
|
350
|
+
const positioned = !fullScreen && position !== void 0;
|
|
351
|
+
return import_react_dom.default.createPortal(
|
|
352
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
353
|
+
"div",
|
|
354
|
+
{
|
|
355
|
+
"data-testid": testID,
|
|
356
|
+
style: {
|
|
357
|
+
position: "fixed",
|
|
358
|
+
inset: 0,
|
|
359
|
+
zIndex: popoverLayer,
|
|
360
|
+
padding: fullScreen || positioned ? 0 : OUTER_PADDING,
|
|
361
|
+
display: "flex",
|
|
362
|
+
alignItems: fullScreen ? "stretch" : "center",
|
|
363
|
+
justifyContent: "center",
|
|
364
|
+
// Without a scrim the page behind stays interactive, so the
|
|
365
|
+
// full-viewport wrapper must not swallow presses meant for it.
|
|
366
|
+
// The panel itself re-enables pointer events below.
|
|
367
|
+
pointerEvents: scrimColor ? void 0 : "none"
|
|
368
|
+
},
|
|
369
|
+
children: [
|
|
370
|
+
scrimColor && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
371
|
+
"div",
|
|
372
|
+
{
|
|
373
|
+
style: {
|
|
374
|
+
position: "absolute",
|
|
375
|
+
inset: 0,
|
|
376
|
+
background: scrimColor,
|
|
377
|
+
opacity: visible ? 1 : 0,
|
|
378
|
+
cursor: onBackdropClick ? "pointer" : "default",
|
|
379
|
+
transition: `opacity ${animationDuration}ms ease`
|
|
380
|
+
},
|
|
381
|
+
onClick: onBackdropClick,
|
|
382
|
+
"aria-hidden": "true"
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
386
|
+
"div",
|
|
387
|
+
{
|
|
388
|
+
style: {
|
|
389
|
+
position: positioned ? "absolute" : "relative",
|
|
390
|
+
left: positioned ? position.x : void 0,
|
|
391
|
+
top: positioned ? position.y : void 0,
|
|
392
|
+
zIndex: 1,
|
|
393
|
+
pointerEvents: "auto",
|
|
394
|
+
display: "flex",
|
|
395
|
+
maxHeight: "100%",
|
|
396
|
+
width: fullScreen ? "100%" : void 0,
|
|
397
|
+
opacity: visible ? 1 : 0,
|
|
398
|
+
transform: visible ? "scale(1)" : "scale(0.95)",
|
|
399
|
+
transition: `opacity ${animationDuration}ms ease, transform ${animationDuration}ms ease`
|
|
400
|
+
},
|
|
401
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_core.OverlayLayerProvider, { value: popoverLayer, children })
|
|
402
|
+
}
|
|
403
|
+
)
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
),
|
|
407
|
+
document.body
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
);
|
|
411
|
+
PopoverRoot.displayName = "PopoverRoot";
|
|
412
|
+
|
|
413
|
+
// src/PopoverTitleBar.tsx
|
|
414
|
+
var import_react4 = require("react");
|
|
415
|
+
var import_xui_button = require("@xsolla/xui-button");
|
|
416
|
+
var import_xui_icons_base = require("@xsolla/xui-icons-base");
|
|
417
|
+
var import_xui_typography = require("@xsolla/xui-typography");
|
|
418
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
419
|
+
var PopoverTitleBar = (0, import_react4.memo)(
|
|
420
|
+
({
|
|
421
|
+
title,
|
|
422
|
+
draggable,
|
|
423
|
+
dragHandleProps,
|
|
424
|
+
pinned,
|
|
425
|
+
onPinnedChange,
|
|
426
|
+
onClose,
|
|
427
|
+
testID
|
|
428
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
429
|
+
"div",
|
|
430
|
+
{
|
|
431
|
+
"data-testid": testID,
|
|
432
|
+
style: {
|
|
433
|
+
flexShrink: 0,
|
|
434
|
+
width: "100%",
|
|
435
|
+
display: "flex",
|
|
436
|
+
flexDirection: "row",
|
|
437
|
+
alignItems: "center",
|
|
438
|
+
gap: 8,
|
|
439
|
+
cursor: draggable ? "grab" : void 0
|
|
440
|
+
},
|
|
441
|
+
...draggable ? dragHandleProps : {},
|
|
442
|
+
children: [
|
|
443
|
+
draggable && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
444
|
+
"span",
|
|
445
|
+
{
|
|
446
|
+
"data-xui-popover-drag-handle": "",
|
|
447
|
+
role: "button",
|
|
448
|
+
tabIndex: 0,
|
|
449
|
+
"aria-label": "Move popover",
|
|
450
|
+
style: { display: "inline-flex", flexShrink: 0 },
|
|
451
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_icons_base.Drag, {})
|
|
452
|
+
}
|
|
453
|
+
),
|
|
454
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1, minWidth: 0, overflow: "hidden" }, children: title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_typography.Typography, { variant: "bodyLgAccent", noWrap: true, children: title }) }),
|
|
455
|
+
onPinnedChange && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
456
|
+
import_xui_button.IconButton,
|
|
457
|
+
{
|
|
458
|
+
variant: "secondary",
|
|
459
|
+
tone: "mono",
|
|
460
|
+
size: "xs",
|
|
461
|
+
icon: pinned ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_icons_base.Unpin, {}) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_icons_base.Pin, {}),
|
|
462
|
+
onPress: () => onPinnedChange(!pinned),
|
|
463
|
+
"aria-label": pinned ? "Unpin popover" : "Pin popover",
|
|
464
|
+
"aria-pressed": pinned
|
|
465
|
+
}
|
|
466
|
+
),
|
|
467
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
468
|
+
import_xui_button.IconButton,
|
|
469
|
+
{
|
|
470
|
+
variant: "secondary",
|
|
471
|
+
tone: "mono",
|
|
472
|
+
size: "xs",
|
|
473
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_icons_base.Remove, {}),
|
|
474
|
+
onPress: onClose,
|
|
475
|
+
"aria-label": "Close popover"
|
|
476
|
+
}
|
|
477
|
+
)
|
|
478
|
+
]
|
|
479
|
+
}
|
|
480
|
+
)
|
|
481
|
+
);
|
|
482
|
+
PopoverTitleBar.displayName = "PopoverTitleBar";
|
|
483
|
+
|
|
484
|
+
// src/usePopoverDrag.ts
|
|
485
|
+
var import_react5 = require("react");
|
|
486
|
+
var KEYBOARD_STEP = 16;
|
|
487
|
+
var EDGE_MARGIN = 8;
|
|
488
|
+
var isInteractive = (target) => target instanceof Element && target.closest("button, a, input") !== null;
|
|
489
|
+
var clampToViewport = (position, panel) => {
|
|
490
|
+
if (!panel || typeof window === "undefined") return position;
|
|
491
|
+
const { width, height } = panel.getBoundingClientRect();
|
|
492
|
+
const maxX = Math.max(EDGE_MARGIN, window.innerWidth - width - EDGE_MARGIN);
|
|
493
|
+
const maxY = Math.max(EDGE_MARGIN, window.innerHeight - height - EDGE_MARGIN);
|
|
494
|
+
return {
|
|
495
|
+
x: Math.min(Math.max(position.x, EDGE_MARGIN), maxX),
|
|
496
|
+
y: Math.min(Math.max(position.y, EDGE_MARGIN), maxY)
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
var usePopoverDrag = ({
|
|
500
|
+
enabled,
|
|
501
|
+
initialPosition,
|
|
502
|
+
onPositionChange
|
|
503
|
+
}) => {
|
|
504
|
+
const panelRef = (0, import_react5.useRef)(null);
|
|
505
|
+
const [position, setPosition] = (0, import_react5.useState)(
|
|
506
|
+
initialPosition
|
|
507
|
+
);
|
|
508
|
+
const [isDragging, setIsDragging] = (0, import_react5.useState)(false);
|
|
509
|
+
const grabOffset = (0, import_react5.useRef)({ x: 0, y: 0 });
|
|
510
|
+
(0, import_react5.useEffect)(() => {
|
|
511
|
+
if (!enabled) setPosition(void 0);
|
|
512
|
+
}, [enabled]);
|
|
513
|
+
const commit = (0, import_react5.useCallback)(
|
|
514
|
+
(next) => {
|
|
515
|
+
const clamped = clampToViewport(next, panelRef.current);
|
|
516
|
+
setPosition(clamped);
|
|
517
|
+
onPositionChange?.(clamped);
|
|
518
|
+
},
|
|
519
|
+
[onPositionChange]
|
|
520
|
+
);
|
|
521
|
+
const onPointerDown = (0, import_react5.useCallback)(
|
|
522
|
+
(event) => {
|
|
523
|
+
if (!enabled || event.button !== 0) return;
|
|
524
|
+
if (isInteractive(event.target)) return;
|
|
525
|
+
const panel = panelRef.current;
|
|
526
|
+
if (!panel) return;
|
|
527
|
+
event.preventDefault();
|
|
528
|
+
const rect = panel.getBoundingClientRect();
|
|
529
|
+
grabOffset.current = {
|
|
530
|
+
x: event.clientX - rect.left,
|
|
531
|
+
y: event.clientY - rect.top
|
|
532
|
+
};
|
|
533
|
+
setIsDragging(true);
|
|
534
|
+
},
|
|
535
|
+
[enabled]
|
|
536
|
+
);
|
|
537
|
+
const onKeyDown = (0, import_react5.useCallback)(
|
|
538
|
+
(event) => {
|
|
539
|
+
if (!enabled) return;
|
|
540
|
+
if (!(event.target instanceof Element) || !event.target.closest("[data-xui-popover-drag-handle]")) {
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
const deltas = {
|
|
544
|
+
ArrowUp: { x: 0, y: -KEYBOARD_STEP },
|
|
545
|
+
ArrowDown: { x: 0, y: KEYBOARD_STEP },
|
|
546
|
+
ArrowLeft: { x: -KEYBOARD_STEP, y: 0 },
|
|
547
|
+
ArrowRight: { x: KEYBOARD_STEP, y: 0 }
|
|
548
|
+
};
|
|
549
|
+
const delta = deltas[event.key];
|
|
550
|
+
if (!delta) return;
|
|
551
|
+
event.preventDefault();
|
|
552
|
+
const rect = panelRef.current?.getBoundingClientRect();
|
|
553
|
+
const base = position ?? { x: rect?.left ?? 0, y: rect?.top ?? 0 };
|
|
554
|
+
commit({ x: base.x + delta.x, y: base.y + delta.y });
|
|
555
|
+
},
|
|
556
|
+
[commit, enabled, position]
|
|
557
|
+
);
|
|
558
|
+
(0, import_react5.useEffect)(() => {
|
|
559
|
+
if (!isDragging || typeof document === "undefined") return;
|
|
560
|
+
const handleMove = (event) => {
|
|
561
|
+
commit({
|
|
562
|
+
x: event.clientX - grabOffset.current.x,
|
|
563
|
+
y: event.clientY - grabOffset.current.y
|
|
564
|
+
});
|
|
565
|
+
};
|
|
566
|
+
const stop = () => setIsDragging(false);
|
|
567
|
+
document.addEventListener("pointermove", handleMove);
|
|
568
|
+
document.addEventListener("pointerup", stop);
|
|
569
|
+
document.addEventListener("pointercancel", stop);
|
|
570
|
+
return () => {
|
|
571
|
+
document.removeEventListener("pointermove", handleMove);
|
|
572
|
+
document.removeEventListener("pointerup", stop);
|
|
573
|
+
document.removeEventListener("pointercancel", stop);
|
|
574
|
+
};
|
|
575
|
+
}, [commit, isDragging]);
|
|
576
|
+
return {
|
|
577
|
+
position: enabled ? position : void 0,
|
|
578
|
+
panelRef,
|
|
579
|
+
dragHandleProps: { onPointerDown, onKeyDown },
|
|
580
|
+
isDragging
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
// src/useDeviceType.ts
|
|
585
|
+
var import_react6 = require("react");
|
|
586
|
+
var POPOVER_BREAKPOINTS = {
|
|
587
|
+
/** Widths at or below this are `mobile` (Figma: "Mobile: 320-768px"). */
|
|
588
|
+
mobileMax: 768,
|
|
589
|
+
/** Widths at or below this, but above `mobileMax`, are `tablet` (Figma: "Tablet: 769-1023px"). */
|
|
590
|
+
tabletMax: 1023
|
|
591
|
+
};
|
|
592
|
+
var resolveDevice = (width) => {
|
|
593
|
+
if (width <= POPOVER_BREAKPOINTS.mobileMax) return "mobile";
|
|
594
|
+
if (width <= POPOVER_BREAKPOINTS.tabletMax) return "tablet";
|
|
595
|
+
return "desktop";
|
|
596
|
+
};
|
|
597
|
+
var useDeviceType = (override) => {
|
|
598
|
+
const [device, setDevice] = (0, import_react6.useState)(
|
|
599
|
+
() => typeof window === "undefined" ? "desktop" : resolveDevice(window.innerWidth)
|
|
600
|
+
);
|
|
601
|
+
(0, import_react6.useEffect)(() => {
|
|
602
|
+
if (override || typeof window === "undefined") return;
|
|
603
|
+
const update = () => setDevice(resolveDevice(window.innerWidth));
|
|
604
|
+
update();
|
|
605
|
+
window.addEventListener("resize", update);
|
|
606
|
+
return () => window.removeEventListener("resize", update);
|
|
607
|
+
}, [override]);
|
|
608
|
+
return override ?? device;
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
// src/Popover.tsx
|
|
612
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
613
|
+
var FOCUSABLE_SELECTORS = 'button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
614
|
+
var DEFAULT_WIDTH = 400;
|
|
615
|
+
var PANEL_PADDING = 16;
|
|
616
|
+
var SECTION_GAP = 24;
|
|
617
|
+
var PANEL_RADIUS = import_xui_core2.radiusScale["200"];
|
|
618
|
+
var BACKDROP_BLUR = "blur(24px)";
|
|
619
|
+
var ANIMATION_DURATION = 200;
|
|
620
|
+
var isElementVisible = (el) => {
|
|
621
|
+
if (el.offsetParent === null && getComputedStyle(el).position !== "fixed")
|
|
622
|
+
return false;
|
|
623
|
+
const style = getComputedStyle(el);
|
|
624
|
+
return style.visibility !== "hidden" && style.display !== "none";
|
|
625
|
+
};
|
|
626
|
+
var getFocusableElements = (container) => Array.from(
|
|
627
|
+
container.querySelectorAll(FOCUSABLE_SELECTORS)
|
|
628
|
+
).filter(isElementVisible);
|
|
629
|
+
var Popover = (0, import_react7.forwardRef)(
|
|
630
|
+
({
|
|
631
|
+
open = false,
|
|
632
|
+
onClose,
|
|
633
|
+
device: deviceProp,
|
|
634
|
+
width = DEFAULT_WIDTH,
|
|
635
|
+
draggable = false,
|
|
636
|
+
initialPosition,
|
|
637
|
+
onPositionChange,
|
|
638
|
+
title,
|
|
639
|
+
pinned,
|
|
640
|
+
onPinnedChange,
|
|
641
|
+
showCloseButton = true,
|
|
642
|
+
titleBar,
|
|
643
|
+
header,
|
|
644
|
+
children,
|
|
645
|
+
footer,
|
|
646
|
+
closeOnOverlayClick = true,
|
|
647
|
+
closeOnEscape = true,
|
|
648
|
+
scrim = true,
|
|
649
|
+
backgroundColor,
|
|
650
|
+
blur = true,
|
|
651
|
+
styled: styledProps,
|
|
652
|
+
initialFocusRef,
|
|
653
|
+
"aria-label": ariaLabel,
|
|
654
|
+
testID,
|
|
655
|
+
themeMode,
|
|
656
|
+
themeProductContext = "b2c"
|
|
657
|
+
}, ref) => {
|
|
658
|
+
const { theme } = (0, import_xui_core2.useResolvedTheme)({ themeMode, themeProductContext });
|
|
659
|
+
const device = useDeviceType(deviceProp);
|
|
660
|
+
const fullScreen = device === "mobile";
|
|
661
|
+
const canDrag = draggable && !fullScreen;
|
|
662
|
+
const dismissOnScrim = closeOnOverlayClick && !pinned && !fullScreen;
|
|
663
|
+
const [mounted, setMounted] = (0, import_react7.useState)(open);
|
|
664
|
+
const dialogRef = (0, import_react7.useRef)(null);
|
|
665
|
+
const previousActiveElement = (0, import_react7.useRef)(null);
|
|
666
|
+
const { position, panelRef, dragHandleProps } = usePopoverDrag({
|
|
667
|
+
enabled: canDrag,
|
|
668
|
+
initialPosition,
|
|
669
|
+
onPositionChange
|
|
670
|
+
});
|
|
671
|
+
(0, import_react7.useEffect)(() => {
|
|
672
|
+
if (open) setMounted(true);
|
|
673
|
+
}, [open]);
|
|
674
|
+
(0, import_react7.useEffect)(() => {
|
|
675
|
+
if (!open || typeof document === "undefined") return;
|
|
676
|
+
previousActiveElement.current = document.activeElement;
|
|
677
|
+
const focusTarget = initialFocusRef?.current || dialogRef.current && getFocusableElements(dialogRef.current)[0];
|
|
678
|
+
if (focusTarget) focusTarget.focus();
|
|
679
|
+
else dialogRef.current?.focus();
|
|
680
|
+
}, [open, initialFocusRef]);
|
|
681
|
+
(0, import_react7.useEffect)(() => {
|
|
682
|
+
if (!open || !closeOnEscape || !onClose) return;
|
|
683
|
+
if (typeof document === "undefined") return;
|
|
684
|
+
const handleKeyDown2 = (event) => {
|
|
685
|
+
if (event.key === "Escape") onClose();
|
|
686
|
+
};
|
|
687
|
+
document.addEventListener("keydown", handleKeyDown2);
|
|
688
|
+
return () => document.removeEventListener("keydown", handleKeyDown2);
|
|
689
|
+
}, [open, closeOnEscape, onClose]);
|
|
690
|
+
const handleKeyDown = (0, import_react7.useCallback)((event) => {
|
|
691
|
+
if (event.key !== "Tab" || !dialogRef.current) return;
|
|
692
|
+
if (typeof document === "undefined") return;
|
|
693
|
+
const focusableElements = getFocusableElements(dialogRef.current);
|
|
694
|
+
const firstElement = focusableElements[0];
|
|
695
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
696
|
+
if (!firstElement) {
|
|
697
|
+
event.preventDefault();
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
if (event.shiftKey && document.activeElement === firstElement) {
|
|
701
|
+
event.preventDefault();
|
|
702
|
+
lastElement.focus();
|
|
703
|
+
} else if (!event.shiftKey && document.activeElement === lastElement) {
|
|
704
|
+
event.preventDefault();
|
|
705
|
+
firstElement.focus();
|
|
706
|
+
}
|
|
707
|
+
}, []);
|
|
708
|
+
const setPanelNode = (0, import_react7.useCallback)(
|
|
709
|
+
(node) => {
|
|
710
|
+
dialogRef.current = node;
|
|
711
|
+
panelRef.current = node;
|
|
712
|
+
if (typeof ref === "function") ref(node);
|
|
713
|
+
else if (ref) ref.current = node;
|
|
714
|
+
},
|
|
715
|
+
[panelRef, ref]
|
|
716
|
+
);
|
|
717
|
+
const handleExited = (0, import_react7.useCallback)(() => {
|
|
718
|
+
setMounted(false);
|
|
719
|
+
previousActiveElement.current?.focus();
|
|
720
|
+
}, []);
|
|
721
|
+
if (!mounted) return null;
|
|
722
|
+
const closeControl = showCloseButton ? onClose : void 0;
|
|
723
|
+
const hasDefaultTitleBar = !titleBar && (title || closeControl || canDrag);
|
|
724
|
+
const accessibleName = ariaLabel ?? (typeof title === "string" ? title : void 0);
|
|
725
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
726
|
+
PopoverRoot,
|
|
727
|
+
{
|
|
728
|
+
open,
|
|
729
|
+
onExited: handleExited,
|
|
730
|
+
onBackdropClick: dismissOnScrim ? onClose : void 0,
|
|
731
|
+
scrimColor: scrim && !fullScreen ? theme.colors.layer?.scrim ?? "rgba(0, 0, 0, 0.75)" : void 0,
|
|
732
|
+
fullScreen,
|
|
733
|
+
position,
|
|
734
|
+
animationDuration: ANIMATION_DURATION,
|
|
735
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
736
|
+
Box,
|
|
737
|
+
{
|
|
738
|
+
testID,
|
|
739
|
+
ref: setPanelNode,
|
|
740
|
+
role: "dialog",
|
|
741
|
+
"aria-modal": fullScreen || scrim ? "true" : void 0,
|
|
742
|
+
"aria-label": accessibleName,
|
|
743
|
+
"data-popover-device": device,
|
|
744
|
+
"data-popover-pinned": pinned ? "true" : void 0,
|
|
745
|
+
tabIndex: -1,
|
|
746
|
+
onKeyDown: handleKeyDown,
|
|
747
|
+
style: {
|
|
748
|
+
boxSizing: "border-box",
|
|
749
|
+
display: "flex",
|
|
750
|
+
flexDirection: "column",
|
|
751
|
+
alignItems: "center",
|
|
752
|
+
gap: SECTION_GAP,
|
|
753
|
+
width: fullScreen ? "100%" : width,
|
|
754
|
+
maxWidth: "100%",
|
|
755
|
+
height: fullScreen ? "100%" : void 0,
|
|
756
|
+
maxHeight: "100%",
|
|
757
|
+
outline: "none",
|
|
758
|
+
color: theme.colors.content.primary,
|
|
759
|
+
backgroundColor: backgroundColor ?? theme.colors.background.primary,
|
|
760
|
+
paddingLeft: PANEL_PADDING,
|
|
761
|
+
paddingRight: PANEL_PADDING,
|
|
762
|
+
// The Figma mobile frame carries only a bottom inset — its top bars
|
|
763
|
+
// are full-bleed, and its children supply their own side padding.
|
|
764
|
+
// A slot component cannot assume the caller re-pads for one
|
|
765
|
+
// breakpoint, so the sides stay inset and only the top is dropped.
|
|
766
|
+
paddingTop: fullScreen ? 0 : PANEL_PADDING,
|
|
767
|
+
paddingBottom: PANEL_PADDING,
|
|
768
|
+
borderRadius: fullScreen ? 0 : PANEL_RADIUS,
|
|
769
|
+
border: fullScreen ? void 0 : `1px solid ${theme.colors.border.secondary}`,
|
|
770
|
+
boxShadow: fullScreen ? void 0 : theme.shadow.popover,
|
|
771
|
+
backdropFilter: !fullScreen && blur ? BACKDROP_BLUR : void 0,
|
|
772
|
+
...styledProps
|
|
773
|
+
},
|
|
774
|
+
children: [
|
|
775
|
+
titleBar ?? (hasDefaultTitleBar ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
776
|
+
PopoverTitleBar,
|
|
777
|
+
{
|
|
778
|
+
title,
|
|
779
|
+
draggable: canDrag,
|
|
780
|
+
dragHandleProps,
|
|
781
|
+
pinned,
|
|
782
|
+
onPinnedChange,
|
|
783
|
+
onClose: closeControl,
|
|
784
|
+
testID: testID ? `${testID}-title-bar` : void 0
|
|
785
|
+
}
|
|
786
|
+
) : null),
|
|
787
|
+
header && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flexShrink: 0, width: "100%" }, children: header }),
|
|
788
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
789
|
+
"div",
|
|
790
|
+
{
|
|
791
|
+
style: {
|
|
792
|
+
flex: 1,
|
|
793
|
+
minHeight: 0,
|
|
794
|
+
width: "100%",
|
|
795
|
+
overflowY: "auto",
|
|
796
|
+
overscrollBehavior: "contain"
|
|
797
|
+
},
|
|
798
|
+
children
|
|
799
|
+
}
|
|
800
|
+
),
|
|
801
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flexShrink: 0, width: "100%" }, children: footer })
|
|
802
|
+
]
|
|
803
|
+
}
|
|
804
|
+
)
|
|
805
|
+
}
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
);
|
|
809
|
+
Popover.displayName = "Popover";
|
|
810
|
+
|
|
811
|
+
// src/usePopover.ts
|
|
812
|
+
var import_react8 = require("react");
|
|
813
|
+
function usePopover(options) {
|
|
814
|
+
const [isOpen, setIsOpen] = (0, import_react8.useState)(false);
|
|
815
|
+
const open = (0, import_react8.useCallback)(() => {
|
|
816
|
+
setIsOpen(true);
|
|
817
|
+
options?.onOpen?.();
|
|
818
|
+
}, [options]);
|
|
819
|
+
const close = (0, import_react8.useCallback)(() => {
|
|
820
|
+
setIsOpen(false);
|
|
821
|
+
options?.onClose?.();
|
|
822
|
+
}, [options]);
|
|
823
|
+
const toggle = (0, import_react8.useCallback)(() => {
|
|
824
|
+
setIsOpen((previous) => {
|
|
825
|
+
if (previous) options?.onClose?.();
|
|
826
|
+
else options?.onOpen?.();
|
|
827
|
+
return !previous;
|
|
828
|
+
});
|
|
829
|
+
}, [options]);
|
|
830
|
+
return { isOpen, open, close, toggle };
|
|
831
|
+
}
|
|
832
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
833
|
+
0 && (module.exports = {
|
|
834
|
+
POPOVER_BREAKPOINTS,
|
|
835
|
+
Popover,
|
|
836
|
+
PopoverTitleBar,
|
|
837
|
+
resolveDevice,
|
|
838
|
+
useDeviceType,
|
|
839
|
+
usePopover,
|
|
840
|
+
usePopoverDrag
|
|
841
|
+
});
|
|
842
|
+
//# sourceMappingURL=index.js.map
|