@xsolla/xui-b2b-drawer 0.147.1

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/web/index.js ADDED
@@ -0,0 +1,746 @@
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
+ Drawer: () => Drawer,
34
+ useDrawer: () => useDrawer
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // src/Drawer.tsx
39
+ var import_react6 = require("react");
40
+
41
+ // ../../foundation/primitives-web/src/Box.tsx
42
+ var import_react2 = __toESM(require("react"));
43
+ var import_styled_components = __toESM(require("styled-components"));
44
+
45
+ // ../../foundation/primitives-web/src/filterDOMProps.ts
46
+ var import_react = __toESM(require("react"));
47
+
48
+ // ../../../node_modules/@emotion/memoize/dist/memoize.esm.js
49
+ function memoize(fn) {
50
+ var cache = {};
51
+ return function(arg) {
52
+ if (cache[arg] === void 0) cache[arg] = fn(arg);
53
+ return cache[arg];
54
+ };
55
+ }
56
+ var memoize_esm_default = memoize;
57
+
58
+ // ../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
59
+ 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)-.*))$/;
60
+ var index = memoize_esm_default(
61
+ function(prop) {
62
+ return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
63
+ }
64
+ /* Z+1 */
65
+ );
66
+ var is_prop_valid_esm_default = index;
67
+
68
+ // ../../foundation/primitives-web/src/filterDOMProps.ts
69
+ var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
70
+ // RN-only event handlers (pass isPropValid's on* pattern)
71
+ "onPress",
72
+ "onChangeText",
73
+ "onLayout",
74
+ "onMoveShouldSetResponder",
75
+ "onResponderGrant",
76
+ "onResponderMove",
77
+ "onResponderRelease",
78
+ "onResponderTerminate",
79
+ // SVG attributes that pass isPropValid
80
+ "strokeWidth",
81
+ // CSS properties that pass isPropValid but are used as component props
82
+ "overflow",
83
+ "cursor",
84
+ "fontSize",
85
+ "fontWeight",
86
+ "fontFamily",
87
+ "textDecoration"
88
+ ]);
89
+ function shouldForwardProp(key) {
90
+ if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
91
+ return is_prop_valid_esm_default(key);
92
+ }
93
+ function createFilteredElement(defaultTag) {
94
+ const Component = import_react.default.forwardRef(
95
+ ({ children, elementType, ...props }, ref) => {
96
+ const Tag = elementType || defaultTag;
97
+ const htmlProps = {};
98
+ for (const key of Object.keys(props)) {
99
+ if (shouldForwardProp(key)) {
100
+ htmlProps[key] = props[key];
101
+ }
102
+ }
103
+ return import_react.default.createElement(
104
+ Tag,
105
+ { ref, ...htmlProps },
106
+ children
107
+ );
108
+ }
109
+ );
110
+ Component.displayName = `Filtered(${defaultTag})`;
111
+ return Component;
112
+ }
113
+
114
+ // ../../foundation/primitives-web/src/Box.tsx
115
+ var import_jsx_runtime = require("react/jsx-runtime");
116
+ var FilteredDiv = createFilteredElement("div");
117
+ var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
118
+ display: flex;
119
+ box-sizing: border-box;
120
+ background-color: ${(props) => props.backgroundColor || "transparent"};
121
+ border-color: ${(props) => props.borderColor || "transparent"};
122
+ border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
123
+
124
+ ${(props) => props.borderBottomWidth !== void 0 && `
125
+ border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
126
+ border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
127
+ border-bottom-style: solid;
128
+ `}
129
+ ${(props) => props.borderTopWidth !== void 0 && `
130
+ border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
131
+ border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
132
+ border-top-style: solid;
133
+ `}
134
+ ${(props) => props.borderLeftWidth !== void 0 && `
135
+ border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
136
+ border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
137
+ border-left-style: solid;
138
+ `}
139
+ ${(props) => props.borderRightWidth !== void 0 && `
140
+ border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
141
+ border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
142
+ border-right-style: solid;
143
+ `}
144
+
145
+ border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
146
+ border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
147
+ height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
148
+ width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
149
+ min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
150
+ min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
151
+ max-width: ${(props) => typeof props.maxWidth === "number" ? `${props.maxWidth}px` : props.maxWidth || "none"};
152
+ max-height: ${(props) => typeof props.maxHeight === "number" ? `${props.maxHeight}px` : props.maxHeight || "none"};
153
+
154
+ padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
155
+ ${(props) => props.paddingHorizontal && `
156
+ padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
157
+ padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
158
+ `}
159
+ ${(props) => props.paddingVertical && `
160
+ padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
161
+ padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
162
+ `}
163
+ ${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
164
+ ${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
165
+ ${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
166
+ ${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
167
+
168
+ margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
169
+ ${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
170
+ ${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
171
+ ${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
172
+ ${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
173
+
174
+ flex-direction: ${(props) => props.flexDirection || "column"};
175
+ flex-wrap: ${(props) => props.flexWrap || "nowrap"};
176
+ align-items: ${(props) => props.alignItems || "stretch"};
177
+ justify-content: ${(props) => props.justifyContent || "flex-start"};
178
+ cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
179
+ position: ${(props) => props.position || "static"};
180
+ top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
181
+ bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
182
+ left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
183
+ right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
184
+ flex: ${(props) => props.flex};
185
+ flex-shrink: ${(props) => props.flexShrink ?? 1};
186
+ gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
187
+ align-self: ${(props) => props.alignSelf || "auto"};
188
+ overflow: ${(props) => props.overflow || "visible"};
189
+ overflow-x: ${(props) => props.overflowX || "visible"};
190
+ overflow-y: ${(props) => props.overflowY || "visible"};
191
+ z-index: ${(props) => props.zIndex};
192
+ opacity: ${(props) => props.disabled ? 0.5 : 1};
193
+ pointer-events: ${(props) => props.disabled ? "none" : "auto"};
194
+
195
+ &:hover {
196
+ ${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
197
+ ${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
198
+ }
199
+
200
+ &:active {
201
+ ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
202
+ }
203
+ `;
204
+ var Box = import_react2.default.forwardRef(
205
+ ({
206
+ children,
207
+ onPress,
208
+ onKeyDown,
209
+ onKeyUp,
210
+ role,
211
+ "aria-label": ariaLabel,
212
+ "aria-labelledby": ariaLabelledBy,
213
+ "aria-current": ariaCurrent,
214
+ "aria-disabled": ariaDisabled,
215
+ "aria-live": ariaLive,
216
+ "aria-busy": ariaBusy,
217
+ "aria-describedby": ariaDescribedBy,
218
+ "aria-expanded": ariaExpanded,
219
+ "aria-haspopup": ariaHasPopup,
220
+ "aria-pressed": ariaPressed,
221
+ "aria-controls": ariaControls,
222
+ tabIndex,
223
+ as,
224
+ src,
225
+ alt,
226
+ type,
227
+ disabled,
228
+ id,
229
+ testID,
230
+ "data-testid": dataTestId,
231
+ ...props
232
+ }, ref) => {
233
+ if (as === "img" && src) {
234
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
235
+ "img",
236
+ {
237
+ src,
238
+ alt: alt || "",
239
+ style: {
240
+ display: "block",
241
+ objectFit: "cover",
242
+ width: typeof props.width === "number" ? `${props.width}px` : props.width,
243
+ height: typeof props.height === "number" ? `${props.height}px` : props.height,
244
+ borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
245
+ position: props.position,
246
+ top: typeof props.top === "number" ? `${props.top}px` : props.top,
247
+ left: typeof props.left === "number" ? `${props.left}px` : props.left,
248
+ right: typeof props.right === "number" ? `${props.right}px` : props.right,
249
+ bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom
250
+ }
251
+ }
252
+ );
253
+ }
254
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
255
+ StyledBox,
256
+ {
257
+ ref,
258
+ elementType: as,
259
+ id,
260
+ type: as === "button" ? type || "button" : void 0,
261
+ disabled: as === "button" ? disabled : void 0,
262
+ onClick: onPress,
263
+ onKeyDown,
264
+ onKeyUp,
265
+ role,
266
+ "aria-label": ariaLabel,
267
+ "aria-labelledby": ariaLabelledBy,
268
+ "aria-current": ariaCurrent,
269
+ "aria-disabled": ariaDisabled,
270
+ "aria-busy": ariaBusy,
271
+ "aria-describedby": ariaDescribedBy,
272
+ "aria-expanded": ariaExpanded,
273
+ "aria-haspopup": ariaHasPopup,
274
+ "aria-pressed": ariaPressed,
275
+ "aria-controls": ariaControls,
276
+ "aria-live": ariaLive,
277
+ tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
278
+ "data-testid": dataTestId || testID,
279
+ ...props,
280
+ children
281
+ }
282
+ );
283
+ }
284
+ );
285
+ Box.displayName = "Box";
286
+
287
+ // src/Drawer.tsx
288
+ var import_xui_core = require("@xsolla/xui-core");
289
+
290
+ // src/DrawerRoot.web.tsx
291
+ var import_react3 = require("react");
292
+ var import_react_dom = __toESM(require("react-dom"));
293
+ var import_jsx_runtime2 = require("react/jsx-runtime");
294
+ var DrawerRoot = (0, import_react3.memo)(
295
+ ({
296
+ children,
297
+ onBackdropClick,
298
+ scrimColor,
299
+ outerPadding,
300
+ animationDuration,
301
+ zIndex,
302
+ open,
303
+ onExited
304
+ }) => {
305
+ const [visible, setVisible] = (0, import_react3.useState)(false);
306
+ (0, import_react3.useEffect)(() => {
307
+ if (!open) return;
308
+ const raf = requestAnimationFrame(() => setVisible(true));
309
+ return () => cancelAnimationFrame(raf);
310
+ }, [open]);
311
+ (0, import_react3.useEffect)(() => {
312
+ if (!open) {
313
+ setVisible(false);
314
+ const timer = setTimeout(onExited, animationDuration);
315
+ return () => clearTimeout(timer);
316
+ }
317
+ }, [open, animationDuration, onExited]);
318
+ (0, import_react3.useEffect)(() => {
319
+ const original = document.body.style.overflow;
320
+ document.body.style.overflow = "hidden";
321
+ return () => {
322
+ document.body.style.overflow = original;
323
+ };
324
+ }, []);
325
+ if (typeof document === "undefined") return null;
326
+ return import_react_dom.default.createPortal(
327
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
328
+ "div",
329
+ {
330
+ style: {
331
+ position: "fixed",
332
+ top: 0,
333
+ left: 0,
334
+ right: 0,
335
+ bottom: 0,
336
+ zIndex,
337
+ padding: outerPadding,
338
+ display: "flex",
339
+ alignItems: "stretch",
340
+ justifyContent: "flex-end"
341
+ },
342
+ children: [
343
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
344
+ "div",
345
+ {
346
+ style: {
347
+ position: "absolute",
348
+ top: 0,
349
+ left: 0,
350
+ right: 0,
351
+ bottom: 0,
352
+ background: scrimColor,
353
+ opacity: visible ? 1 : 0,
354
+ cursor: onBackdropClick ? "pointer" : "default",
355
+ transition: `opacity ${animationDuration}ms ease`
356
+ },
357
+ onClick: onBackdropClick,
358
+ "aria-hidden": "true"
359
+ }
360
+ ),
361
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
362
+ "div",
363
+ {
364
+ style: {
365
+ position: "relative",
366
+ zIndex: 1,
367
+ height: "100%",
368
+ display: "flex",
369
+ alignItems: "stretch",
370
+ transform: visible ? "translateX(0)" : "translateX(100%)",
371
+ transition: `transform ${animationDuration}ms ease`
372
+ },
373
+ children
374
+ }
375
+ )
376
+ ]
377
+ }
378
+ ),
379
+ document.body
380
+ );
381
+ }
382
+ );
383
+ DrawerRoot.displayName = "DrawerRoot";
384
+
385
+ // src/DrawerHeader.tsx
386
+ var import_react4 = require("react");
387
+ var import_xui_button = require("@xsolla/xui-button");
388
+ var import_xui_icons_base = require("@xsolla/xui-icons-base");
389
+ var import_xui_typography = require("@xsolla/xui-typography");
390
+ var import_jsx_runtime3 = require("react/jsx-runtime");
391
+ var DrawerHeader = (0, import_react4.memo)(
392
+ ({
393
+ title,
394
+ onBack,
395
+ onClose,
396
+ headerAction,
397
+ paddingX,
398
+ paddingY,
399
+ gap
400
+ }) => {
401
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
402
+ "div",
403
+ {
404
+ style: {
405
+ flexShrink: 0,
406
+ height: 80,
407
+ width: "100%",
408
+ display: "flex",
409
+ flexDirection: "row",
410
+ alignItems: "center",
411
+ paddingLeft: paddingX,
412
+ paddingRight: paddingX,
413
+ paddingTop: paddingY,
414
+ paddingBottom: paddingY,
415
+ gap,
416
+ boxSizing: "border-box"
417
+ },
418
+ children: [
419
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
420
+ "div",
421
+ {
422
+ style: {
423
+ flex: 1,
424
+ minWidth: 0,
425
+ display: "flex",
426
+ flexDirection: "row",
427
+ alignItems: "center",
428
+ gap: 16
429
+ },
430
+ children: [
431
+ onBack && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
432
+ import_xui_button.IconButton,
433
+ {
434
+ variant: "secondary",
435
+ tone: "mono",
436
+ size: "xs",
437
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_icons_base.ArrowLeft, {}),
438
+ onPress: onBack,
439
+ "aria-label": "Go back"
440
+ }
441
+ ),
442
+ title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1, minWidth: 0, overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_typography.Typography, { variant: "bodyLgAccent", noWrap: true, children: title }) })
443
+ ]
444
+ }
445
+ ),
446
+ headerAction && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flexShrink: 0 }, children: headerAction }),
447
+ onClose && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
448
+ import_xui_button.IconButton,
449
+ {
450
+ variant: "secondary",
451
+ tone: "mono",
452
+ size: "xs",
453
+ icon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_icons_base.Remove, {}),
454
+ onPress: onClose,
455
+ "aria-label": "Close drawer"
456
+ }
457
+ )
458
+ ]
459
+ }
460
+ );
461
+ }
462
+ );
463
+ DrawerHeader.displayName = "DrawerHeader";
464
+
465
+ // src/DrawerFooter.tsx
466
+ var import_react5 = __toESM(require("react"));
467
+ var import_jsx_runtime4 = require("react/jsx-runtime");
468
+ var flattenChildren = (children) => {
469
+ const result = [];
470
+ import_react5.default.Children.forEach(children, (child) => {
471
+ if (import_react5.default.isValidElement(child) && child.type === import_react5.default.Fragment) {
472
+ result.push(
473
+ ...flattenChildren(
474
+ child.props.children
475
+ )
476
+ );
477
+ } else if (child !== null && child !== void 0) {
478
+ result.push(child);
479
+ }
480
+ });
481
+ return result;
482
+ };
483
+ var DrawerFooter = (0, import_react5.memo)(
484
+ ({ children, align, shadow, fullWidth }) => {
485
+ const justifyContent = align === "center" ? "center" : "flex-end";
486
+ const renderedChildren = fullWidth ? flattenChildren(children).map(
487
+ (child, i) => import_react5.default.isValidElement(child) ? import_react5.default.cloneElement(
488
+ child,
489
+ {
490
+ key: child.key ?? i,
491
+ fullWidth: true
492
+ }
493
+ ) : child
494
+ ) : children;
495
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
496
+ "div",
497
+ {
498
+ style: {
499
+ flexShrink: 0,
500
+ width: "100%",
501
+ boxShadow: shadow ? "0px 2px 25px 0px rgba(7, 7, 8, 0.15)" : "none"
502
+ },
503
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
504
+ "div",
505
+ {
506
+ style: {
507
+ display: "flex",
508
+ flexDirection: "row",
509
+ justifyContent: fullWidth ? "stretch" : justifyContent,
510
+ padding: 16,
511
+ gap: 8
512
+ },
513
+ children: renderedChildren
514
+ }
515
+ )
516
+ }
517
+ );
518
+ }
519
+ );
520
+ DrawerFooter.displayName = "DrawerFooter";
521
+
522
+ // src/Drawer.tsx
523
+ var import_jsx_runtime5 = require("react/jsx-runtime");
524
+ var FOCUSABLE_SELECTORS = 'button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
525
+ var isElementVisible = (el) => {
526
+ if (el.offsetParent === null && getComputedStyle(el).position !== "fixed")
527
+ return false;
528
+ const style = getComputedStyle(el);
529
+ return style.visibility !== "hidden" && style.display !== "none";
530
+ };
531
+ var getFocusableElements = (container) => Array.from(
532
+ container.querySelectorAll(FOCUSABLE_SELECTORS)
533
+ ).filter(isElementVisible);
534
+ var DRAWER_WIDTHS = {
535
+ sm: 480,
536
+ md: 620,
537
+ lg: 1056
538
+ };
539
+ var Drawer = (0, import_react6.forwardRef)(
540
+ ({
541
+ open: openProp,
542
+ isOpen,
543
+ onClose,
544
+ size = "md",
545
+ title: titleProp,
546
+ header: headerProp,
547
+ onBack: onBackProp,
548
+ headerAction,
549
+ closeOnOverlayClick = true,
550
+ closeOnEscape = true,
551
+ footer: footerProp,
552
+ bottom,
553
+ footerAlign = "right",
554
+ footerShadow = false,
555
+ footerFullWidth = true,
556
+ stepper,
557
+ children,
558
+ initialFocusRef,
559
+ themeMode,
560
+ themeProductContext
561
+ }, ref) => {
562
+ const open = openProp ?? isOpen ?? false;
563
+ const title = titleProp ?? headerProp?.title;
564
+ const onBack = onBackProp ?? headerProp?.onBack;
565
+ const footer = footerProp ?? bottom;
566
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
567
+ const sizing = theme.sizing.drawer();
568
+ const [mounted, setMounted] = (0, import_react6.useState)(open);
569
+ (0, import_react6.useEffect)(() => {
570
+ if (open) setMounted(true);
571
+ }, [open]);
572
+ const drawerRef = (0, import_react6.useRef)(null);
573
+ const closeButtonRef = (0, import_react6.useRef)(null);
574
+ const previousActiveElement = (0, import_react6.useRef)(null);
575
+ (0, import_react6.useEffect)(() => {
576
+ if (!open) return;
577
+ if (typeof document === "undefined") return;
578
+ previousActiveElement.current = document.activeElement;
579
+ const focusTarget = initialFocusRef?.current || closeButtonRef.current || drawerRef.current && getFocusableElements(drawerRef.current)[0];
580
+ if (focusTarget) {
581
+ focusTarget.focus();
582
+ } else {
583
+ drawerRef.current?.focus();
584
+ }
585
+ }, [open, initialFocusRef]);
586
+ (0, import_react6.useEffect)(() => {
587
+ if (!open || !closeOnEscape || !onClose) return;
588
+ if (typeof document === "undefined") return;
589
+ const handleKeyDown2 = (event) => {
590
+ if (event.key === "Escape") onClose();
591
+ };
592
+ document.addEventListener("keydown", handleKeyDown2);
593
+ return () => document.removeEventListener("keydown", handleKeyDown2);
594
+ }, [open, closeOnEscape, onClose]);
595
+ const handleKeyDown = (0, import_react6.useCallback)((event) => {
596
+ if (event.key !== "Tab" || !drawerRef.current) return;
597
+ if (typeof document === "undefined") return;
598
+ const focusableElements = getFocusableElements(drawerRef.current);
599
+ const firstElement = focusableElements[0];
600
+ const lastElement = focusableElements[focusableElements.length - 1];
601
+ if (!firstElement) {
602
+ event.preventDefault();
603
+ return;
604
+ }
605
+ if (event.shiftKey && document.activeElement === firstElement) {
606
+ event.preventDefault();
607
+ lastElement.focus();
608
+ } else if (!event.shiftKey && document.activeElement === lastElement) {
609
+ event.preventDefault();
610
+ firstElement.focus();
611
+ }
612
+ }, []);
613
+ if (!mounted) return null;
614
+ const contentWidth = DRAWER_WIDTHS[size];
615
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
616
+ DrawerRoot,
617
+ {
618
+ open,
619
+ onExited: () => {
620
+ setMounted(false);
621
+ previousActiveElement.current?.focus();
622
+ },
623
+ onBackdropClick: closeOnOverlayClick ? onClose : void 0,
624
+ scrimColor: sizing.scrimColor,
625
+ outerPadding: sizing.outerPadding,
626
+ animationDuration: sizing.animationDuration,
627
+ zIndex: sizing.zIndex,
628
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
629
+ "div",
630
+ {
631
+ style: {
632
+ height: "100%",
633
+ display: "flex",
634
+ flexDirection: "row",
635
+ alignItems: "stretch",
636
+ backgroundColor: theme.colors.background.primary,
637
+ borderRadius: sizing.containerRadius,
638
+ overflow: "hidden",
639
+ gap: stepper ? sizing.stepperContentGap : 0
640
+ },
641
+ children: [
642
+ stepper && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
643
+ "div",
644
+ {
645
+ style: {
646
+ flexShrink: 0,
647
+ alignSelf: "stretch",
648
+ backgroundColor: theme.colors.background.secondary,
649
+ borderRadius: sizing.contentRadius,
650
+ padding: sizing.stepperPadding,
651
+ display: "flex",
652
+ flexDirection: "column"
653
+ },
654
+ children: stepper
655
+ }
656
+ ),
657
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
658
+ Box,
659
+ {
660
+ ref: (node) => {
661
+ drawerRef.current = node;
662
+ if (typeof ref === "function") ref(node);
663
+ else if (ref)
664
+ ref.current = node;
665
+ },
666
+ role: "dialog",
667
+ "aria-modal": "true",
668
+ "aria-label": typeof title === "string" ? title : void 0,
669
+ tabIndex: -1,
670
+ onKeyDown: handleKeyDown,
671
+ style: {
672
+ width: contentWidth,
673
+ height: "100%",
674
+ flexShrink: 0,
675
+ display: "flex",
676
+ flexDirection: "column",
677
+ outline: "none",
678
+ color: theme.colors.content.primary
679
+ },
680
+ children: [
681
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
682
+ DrawerHeader,
683
+ {
684
+ title,
685
+ onBack,
686
+ onClose,
687
+ headerAction,
688
+ paddingX: sizing.headerPaddingX,
689
+ paddingY: sizing.headerPaddingY,
690
+ gap: sizing.headerGap
691
+ }
692
+ ),
693
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
694
+ Box,
695
+ {
696
+ style: {
697
+ flex: 1,
698
+ minHeight: 0,
699
+ overflowY: "auto",
700
+ paddingLeft: sizing.contentPaddingX,
701
+ paddingRight: sizing.contentPaddingX
702
+ },
703
+ children
704
+ }
705
+ ),
706
+ footer ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
707
+ DrawerFooter,
708
+ {
709
+ align: footerAlign,
710
+ shadow: footerShadow,
711
+ fullWidth: footerFullWidth,
712
+ children: footer
713
+ }
714
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flexShrink: 0, height: 32 } })
715
+ ]
716
+ }
717
+ )
718
+ ]
719
+ }
720
+ )
721
+ }
722
+ );
723
+ }
724
+ );
725
+ Drawer.displayName = "Drawer";
726
+
727
+ // src/useDrawer.ts
728
+ var import_react7 = require("react");
729
+ function useDrawer(options) {
730
+ const [isOpen, setIsOpen] = (0, import_react7.useState)(false);
731
+ const open = (0, import_react7.useCallback)(() => {
732
+ setIsOpen(true);
733
+ options?.onOpen?.();
734
+ }, [options]);
735
+ const close = (0, import_react7.useCallback)(() => {
736
+ setIsOpen(false);
737
+ options?.onClose?.();
738
+ }, [options]);
739
+ return { isOpen, open, close };
740
+ }
741
+ // Annotate the CommonJS export names for ESM import in node:
742
+ 0 && (module.exports = {
743
+ Drawer,
744
+ useDrawer
745
+ });
746
+ //# sourceMappingURL=index.js.map