@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.
@@ -0,0 +1,64 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, RefObject } from 'react';
3
+ import { ThemeOverrideProps } from '@xsolla/xui-core';
4
+
5
+ type DrawerSize = "sm" | "md" | "lg";
6
+ type DrawerFooterAlign = "center" | "right";
7
+ /** @deprecated Use individual `title` and `onBack` props instead */
8
+ interface LegacyDrawerHeader {
9
+ title?: ReactNode;
10
+ onBack?: () => void;
11
+ }
12
+ interface DrawerProps extends ThemeOverrideProps {
13
+ /** Whether the drawer is open */
14
+ open?: boolean;
15
+ /** @deprecated Use `open` instead */
16
+ isOpen?: boolean;
17
+ /** Called when the drawer should close */
18
+ onClose?: () => void;
19
+ /** Width preset: sm=480px, md=620px, lg=1056px */
20
+ size?: DrawerSize;
21
+ /** Title text displayed in the header (18px compact/Medium, ellipsis) */
22
+ title?: ReactNode;
23
+ /** @deprecated Use `title` and `onBack` props instead */
24
+ header?: LegacyDrawerHeader;
25
+ /** Renders a back arrow button in the header when provided */
26
+ onBack?: () => void;
27
+ /** Optional action element in the header, rendered between title and close button */
28
+ headerAction?: ReactNode;
29
+ /** Whether clicking the scrim backdrop closes the drawer. Defaults to true. */
30
+ closeOnOverlayClick?: boolean;
31
+ /** Whether pressing Escape closes the drawer. Defaults to true. */
32
+ closeOnEscape?: boolean;
33
+ /** Footer content (typically a ButtonGroup) */
34
+ footer?: ReactNode;
35
+ /** @deprecated Use `footer` instead */
36
+ bottom?: ReactNode;
37
+ /** Alignment of footer content. Defaults to "right". */
38
+ footerAlign?: DrawerFooterAlign;
39
+ /** Show a drop shadow above the footer. Defaults to false. */
40
+ footerShadow?: boolean;
41
+ /** Whether footer buttons stretch to full width. Defaults to true. */
42
+ footerFullWidth?: boolean;
43
+ /** Optional stepper sidebar rendered to the left of the content panel */
44
+ stepper?: ReactNode;
45
+ /** Main drawer content */
46
+ children: ReactNode;
47
+ /** Ref to element that should receive focus when the drawer opens */
48
+ initialFocusRef?: RefObject<HTMLElement>;
49
+ }
50
+
51
+ declare const Drawer: react.ForwardRefExoticComponent<DrawerProps & react.RefAttributes<HTMLDivElement>>;
52
+
53
+ interface UseDrawerOptions {
54
+ onOpen?: () => void;
55
+ onClose?: () => void;
56
+ }
57
+ interface UseDrawerReturn {
58
+ isOpen: boolean;
59
+ open: () => void;
60
+ close: () => void;
61
+ }
62
+ declare function useDrawer(options?: UseDrawerOptions): UseDrawerReturn;
63
+
64
+ export { Drawer, type DrawerFooterAlign, type DrawerProps, type DrawerSize, type LegacyDrawerHeader, type UseDrawerOptions, type UseDrawerReturn, useDrawer };
@@ -0,0 +1,64 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, RefObject } from 'react';
3
+ import { ThemeOverrideProps } from '@xsolla/xui-core';
4
+
5
+ type DrawerSize = "sm" | "md" | "lg";
6
+ type DrawerFooterAlign = "center" | "right";
7
+ /** @deprecated Use individual `title` and `onBack` props instead */
8
+ interface LegacyDrawerHeader {
9
+ title?: ReactNode;
10
+ onBack?: () => void;
11
+ }
12
+ interface DrawerProps extends ThemeOverrideProps {
13
+ /** Whether the drawer is open */
14
+ open?: boolean;
15
+ /** @deprecated Use `open` instead */
16
+ isOpen?: boolean;
17
+ /** Called when the drawer should close */
18
+ onClose?: () => void;
19
+ /** Width preset: sm=480px, md=620px, lg=1056px */
20
+ size?: DrawerSize;
21
+ /** Title text displayed in the header (18px compact/Medium, ellipsis) */
22
+ title?: ReactNode;
23
+ /** @deprecated Use `title` and `onBack` props instead */
24
+ header?: LegacyDrawerHeader;
25
+ /** Renders a back arrow button in the header when provided */
26
+ onBack?: () => void;
27
+ /** Optional action element in the header, rendered between title and close button */
28
+ headerAction?: ReactNode;
29
+ /** Whether clicking the scrim backdrop closes the drawer. Defaults to true. */
30
+ closeOnOverlayClick?: boolean;
31
+ /** Whether pressing Escape closes the drawer. Defaults to true. */
32
+ closeOnEscape?: boolean;
33
+ /** Footer content (typically a ButtonGroup) */
34
+ footer?: ReactNode;
35
+ /** @deprecated Use `footer` instead */
36
+ bottom?: ReactNode;
37
+ /** Alignment of footer content. Defaults to "right". */
38
+ footerAlign?: DrawerFooterAlign;
39
+ /** Show a drop shadow above the footer. Defaults to false. */
40
+ footerShadow?: boolean;
41
+ /** Whether footer buttons stretch to full width. Defaults to true. */
42
+ footerFullWidth?: boolean;
43
+ /** Optional stepper sidebar rendered to the left of the content panel */
44
+ stepper?: ReactNode;
45
+ /** Main drawer content */
46
+ children: ReactNode;
47
+ /** Ref to element that should receive focus when the drawer opens */
48
+ initialFocusRef?: RefObject<HTMLElement>;
49
+ }
50
+
51
+ declare const Drawer: react.ForwardRefExoticComponent<DrawerProps & react.RefAttributes<HTMLDivElement>>;
52
+
53
+ interface UseDrawerOptions {
54
+ onOpen?: () => void;
55
+ onClose?: () => void;
56
+ }
57
+ interface UseDrawerReturn {
58
+ isOpen: boolean;
59
+ open: () => void;
60
+ close: () => void;
61
+ }
62
+ declare function useDrawer(options?: UseDrawerOptions): UseDrawerReturn;
63
+
64
+ export { Drawer, type DrawerFooterAlign, type DrawerProps, type DrawerSize, type LegacyDrawerHeader, type UseDrawerOptions, type UseDrawerReturn, useDrawer };
@@ -0,0 +1,586 @@
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_react4 = require("react");
40
+
41
+ // ../../foundation/primitives-native/src/Box.tsx
42
+ var import_react_native = require("react-native");
43
+ var import_jsx_runtime = require("react/jsx-runtime");
44
+ var Box = ({
45
+ children,
46
+ onPress,
47
+ onLayout,
48
+ onMoveShouldSetResponder,
49
+ onResponderGrant,
50
+ onResponderMove,
51
+ onResponderRelease,
52
+ onResponderTerminate,
53
+ backgroundColor,
54
+ borderColor,
55
+ borderWidth,
56
+ borderBottomWidth,
57
+ borderBottomColor,
58
+ borderTopWidth,
59
+ borderTopColor,
60
+ borderLeftWidth,
61
+ borderLeftColor,
62
+ borderRightWidth,
63
+ borderRightColor,
64
+ borderRadius,
65
+ borderStyle,
66
+ height,
67
+ padding,
68
+ paddingHorizontal,
69
+ paddingVertical,
70
+ margin,
71
+ marginTop,
72
+ marginBottom,
73
+ marginLeft,
74
+ marginRight,
75
+ flexDirection,
76
+ alignItems,
77
+ justifyContent,
78
+ position,
79
+ top,
80
+ bottom,
81
+ left,
82
+ right,
83
+ width,
84
+ minWidth,
85
+ minHeight,
86
+ maxWidth,
87
+ maxHeight,
88
+ flex,
89
+ overflow,
90
+ zIndex,
91
+ hoverStyle,
92
+ pressStyle,
93
+ style,
94
+ "data-testid": dataTestId,
95
+ testID,
96
+ as,
97
+ src,
98
+ alt,
99
+ ...rest
100
+ }) => {
101
+ const getContainerStyle = (pressed) => ({
102
+ backgroundColor: pressed && pressStyle?.backgroundColor ? pressStyle.backgroundColor : backgroundColor,
103
+ borderColor,
104
+ borderWidth,
105
+ borderBottomWidth,
106
+ borderBottomColor,
107
+ borderTopWidth,
108
+ borderTopColor,
109
+ borderLeftWidth,
110
+ borderLeftColor,
111
+ borderRightWidth,
112
+ borderRightColor,
113
+ borderRadius,
114
+ borderStyle,
115
+ overflow,
116
+ zIndex,
117
+ height,
118
+ width,
119
+ minWidth,
120
+ minHeight,
121
+ maxWidth,
122
+ maxHeight,
123
+ padding,
124
+ paddingHorizontal,
125
+ paddingVertical,
126
+ margin,
127
+ marginTop,
128
+ marginBottom,
129
+ marginLeft,
130
+ marginRight,
131
+ flexDirection,
132
+ alignItems,
133
+ justifyContent,
134
+ position,
135
+ top,
136
+ bottom,
137
+ left,
138
+ right,
139
+ flex,
140
+ ...style
141
+ });
142
+ const finalTestID = dataTestId || testID;
143
+ const {
144
+ role,
145
+ tabIndex,
146
+ onKeyDown,
147
+ onKeyUp,
148
+ "aria-label": _ariaLabel,
149
+ "aria-labelledby": _ariaLabelledBy,
150
+ "aria-current": _ariaCurrent,
151
+ "aria-disabled": _ariaDisabled,
152
+ "aria-live": _ariaLive,
153
+ className,
154
+ "data-testid": _dataTestId,
155
+ ...nativeRest
156
+ } = rest;
157
+ if (as === "img" && src) {
158
+ const imageStyle = {
159
+ width,
160
+ height,
161
+ borderRadius,
162
+ position,
163
+ top,
164
+ bottom,
165
+ left,
166
+ right,
167
+ ...style
168
+ };
169
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
170
+ import_react_native.Image,
171
+ {
172
+ source: { uri: src },
173
+ style: imageStyle,
174
+ testID: finalTestID,
175
+ resizeMode: "cover",
176
+ ...nativeRest
177
+ }
178
+ );
179
+ }
180
+ if (onPress) {
181
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
182
+ import_react_native.Pressable,
183
+ {
184
+ onPress,
185
+ onLayout,
186
+ onMoveShouldSetResponder,
187
+ onResponderGrant,
188
+ onResponderMove,
189
+ onResponderRelease,
190
+ onResponderTerminate,
191
+ style: ({ pressed }) => getContainerStyle(pressed),
192
+ testID: finalTestID,
193
+ ...nativeRest,
194
+ children
195
+ }
196
+ );
197
+ }
198
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
199
+ import_react_native.View,
200
+ {
201
+ style: getContainerStyle(),
202
+ testID: finalTestID,
203
+ onLayout,
204
+ onMoveShouldSetResponder,
205
+ onResponderGrant,
206
+ onResponderMove,
207
+ onResponderRelease,
208
+ onResponderTerminate,
209
+ ...nativeRest,
210
+ children
211
+ }
212
+ );
213
+ };
214
+
215
+ // src/Drawer.tsx
216
+ var import_xui_core = require("@xsolla/xui-core");
217
+
218
+ // src/DrawerRoot.native.tsx
219
+ var import_react = require("react");
220
+ var DrawerRoot = (0, import_react.memo)((_props) => {
221
+ return null;
222
+ });
223
+ DrawerRoot.displayName = "DrawerRoot";
224
+
225
+ // src/DrawerHeader.tsx
226
+ var import_react2 = require("react");
227
+ var import_xui_button = require("@xsolla/xui-button");
228
+ var import_xui_icons_base = require("@xsolla/xui-icons-base");
229
+ var import_xui_typography = require("@xsolla/xui-typography");
230
+ var import_jsx_runtime2 = require("react/jsx-runtime");
231
+ var DrawerHeader = (0, import_react2.memo)(
232
+ ({
233
+ title,
234
+ onBack,
235
+ onClose,
236
+ headerAction,
237
+ paddingX,
238
+ paddingY,
239
+ gap
240
+ }) => {
241
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
242
+ "div",
243
+ {
244
+ style: {
245
+ flexShrink: 0,
246
+ height: 80,
247
+ width: "100%",
248
+ display: "flex",
249
+ flexDirection: "row",
250
+ alignItems: "center",
251
+ paddingLeft: paddingX,
252
+ paddingRight: paddingX,
253
+ paddingTop: paddingY,
254
+ paddingBottom: paddingY,
255
+ gap,
256
+ boxSizing: "border-box"
257
+ },
258
+ children: [
259
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
260
+ "div",
261
+ {
262
+ style: {
263
+ flex: 1,
264
+ minWidth: 0,
265
+ display: "flex",
266
+ flexDirection: "row",
267
+ alignItems: "center",
268
+ gap: 16
269
+ },
270
+ children: [
271
+ onBack && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
272
+ import_xui_button.IconButton,
273
+ {
274
+ variant: "secondary",
275
+ tone: "mono",
276
+ size: "xs",
277
+ icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_icons_base.ArrowLeft, {}),
278
+ onPress: onBack,
279
+ "aria-label": "Go back"
280
+ }
281
+ ),
282
+ title && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { flex: 1, minWidth: 0, overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_typography.Typography, { variant: "bodyLgAccent", noWrap: true, children: title }) })
283
+ ]
284
+ }
285
+ ),
286
+ headerAction && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { flexShrink: 0 }, children: headerAction }),
287
+ onClose && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
288
+ import_xui_button.IconButton,
289
+ {
290
+ variant: "secondary",
291
+ tone: "mono",
292
+ size: "xs",
293
+ icon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_xui_icons_base.Remove, {}),
294
+ onPress: onClose,
295
+ "aria-label": "Close drawer"
296
+ }
297
+ )
298
+ ]
299
+ }
300
+ );
301
+ }
302
+ );
303
+ DrawerHeader.displayName = "DrawerHeader";
304
+
305
+ // src/DrawerFooter.tsx
306
+ var import_react3 = __toESM(require("react"));
307
+ var import_jsx_runtime3 = require("react/jsx-runtime");
308
+ var flattenChildren = (children) => {
309
+ const result = [];
310
+ import_react3.default.Children.forEach(children, (child) => {
311
+ if (import_react3.default.isValidElement(child) && child.type === import_react3.default.Fragment) {
312
+ result.push(
313
+ ...flattenChildren(
314
+ child.props.children
315
+ )
316
+ );
317
+ } else if (child !== null && child !== void 0) {
318
+ result.push(child);
319
+ }
320
+ });
321
+ return result;
322
+ };
323
+ var DrawerFooter = (0, import_react3.memo)(
324
+ ({ children, align, shadow, fullWidth }) => {
325
+ const justifyContent = align === "center" ? "center" : "flex-end";
326
+ const renderedChildren = fullWidth ? flattenChildren(children).map(
327
+ (child, i) => import_react3.default.isValidElement(child) ? import_react3.default.cloneElement(
328
+ child,
329
+ {
330
+ key: child.key ?? i,
331
+ fullWidth: true
332
+ }
333
+ ) : child
334
+ ) : children;
335
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
336
+ "div",
337
+ {
338
+ style: {
339
+ flexShrink: 0,
340
+ width: "100%",
341
+ boxShadow: shadow ? "0px 2px 25px 0px rgba(7, 7, 8, 0.15)" : "none"
342
+ },
343
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
344
+ "div",
345
+ {
346
+ style: {
347
+ display: "flex",
348
+ flexDirection: "row",
349
+ justifyContent: fullWidth ? "stretch" : justifyContent,
350
+ padding: 16,
351
+ gap: 8
352
+ },
353
+ children: renderedChildren
354
+ }
355
+ )
356
+ }
357
+ );
358
+ }
359
+ );
360
+ DrawerFooter.displayName = "DrawerFooter";
361
+
362
+ // src/Drawer.tsx
363
+ var import_jsx_runtime4 = require("react/jsx-runtime");
364
+ var FOCUSABLE_SELECTORS = 'button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
365
+ var isElementVisible = (el) => {
366
+ if (el.offsetParent === null && getComputedStyle(el).position !== "fixed")
367
+ return false;
368
+ const style = getComputedStyle(el);
369
+ return style.visibility !== "hidden" && style.display !== "none";
370
+ };
371
+ var getFocusableElements = (container) => Array.from(
372
+ container.querySelectorAll(FOCUSABLE_SELECTORS)
373
+ ).filter(isElementVisible);
374
+ var DRAWER_WIDTHS = {
375
+ sm: 480,
376
+ md: 620,
377
+ lg: 1056
378
+ };
379
+ var Drawer = (0, import_react4.forwardRef)(
380
+ ({
381
+ open: openProp,
382
+ isOpen,
383
+ onClose,
384
+ size = "md",
385
+ title: titleProp,
386
+ header: headerProp,
387
+ onBack: onBackProp,
388
+ headerAction,
389
+ closeOnOverlayClick = true,
390
+ closeOnEscape = true,
391
+ footer: footerProp,
392
+ bottom,
393
+ footerAlign = "right",
394
+ footerShadow = false,
395
+ footerFullWidth = true,
396
+ stepper,
397
+ children,
398
+ initialFocusRef,
399
+ themeMode,
400
+ themeProductContext
401
+ }, ref) => {
402
+ const open = openProp ?? isOpen ?? false;
403
+ const title = titleProp ?? headerProp?.title;
404
+ const onBack = onBackProp ?? headerProp?.onBack;
405
+ const footer = footerProp ?? bottom;
406
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
407
+ const sizing = theme.sizing.drawer();
408
+ const [mounted, setMounted] = (0, import_react4.useState)(open);
409
+ (0, import_react4.useEffect)(() => {
410
+ if (open) setMounted(true);
411
+ }, [open]);
412
+ const drawerRef = (0, import_react4.useRef)(null);
413
+ const closeButtonRef = (0, import_react4.useRef)(null);
414
+ const previousActiveElement = (0, import_react4.useRef)(null);
415
+ (0, import_react4.useEffect)(() => {
416
+ if (!open) return;
417
+ if (typeof document === "undefined") return;
418
+ previousActiveElement.current = document.activeElement;
419
+ const focusTarget = initialFocusRef?.current || closeButtonRef.current || drawerRef.current && getFocusableElements(drawerRef.current)[0];
420
+ if (focusTarget) {
421
+ focusTarget.focus();
422
+ } else {
423
+ drawerRef.current?.focus();
424
+ }
425
+ }, [open, initialFocusRef]);
426
+ (0, import_react4.useEffect)(() => {
427
+ if (!open || !closeOnEscape || !onClose) return;
428
+ if (typeof document === "undefined") return;
429
+ const handleKeyDown2 = (event) => {
430
+ if (event.key === "Escape") onClose();
431
+ };
432
+ document.addEventListener("keydown", handleKeyDown2);
433
+ return () => document.removeEventListener("keydown", handleKeyDown2);
434
+ }, [open, closeOnEscape, onClose]);
435
+ const handleKeyDown = (0, import_react4.useCallback)((event) => {
436
+ if (event.key !== "Tab" || !drawerRef.current) return;
437
+ if (typeof document === "undefined") return;
438
+ const focusableElements = getFocusableElements(drawerRef.current);
439
+ const firstElement = focusableElements[0];
440
+ const lastElement = focusableElements[focusableElements.length - 1];
441
+ if (!firstElement) {
442
+ event.preventDefault();
443
+ return;
444
+ }
445
+ if (event.shiftKey && document.activeElement === firstElement) {
446
+ event.preventDefault();
447
+ lastElement.focus();
448
+ } else if (!event.shiftKey && document.activeElement === lastElement) {
449
+ event.preventDefault();
450
+ firstElement.focus();
451
+ }
452
+ }, []);
453
+ if (!mounted) return null;
454
+ const contentWidth = DRAWER_WIDTHS[size];
455
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
456
+ DrawerRoot,
457
+ {
458
+ open,
459
+ onExited: () => {
460
+ setMounted(false);
461
+ previousActiveElement.current?.focus();
462
+ },
463
+ onBackdropClick: closeOnOverlayClick ? onClose : void 0,
464
+ scrimColor: sizing.scrimColor,
465
+ outerPadding: sizing.outerPadding,
466
+ animationDuration: sizing.animationDuration,
467
+ zIndex: sizing.zIndex,
468
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
469
+ "div",
470
+ {
471
+ style: {
472
+ height: "100%",
473
+ display: "flex",
474
+ flexDirection: "row",
475
+ alignItems: "stretch",
476
+ backgroundColor: theme.colors.background.primary,
477
+ borderRadius: sizing.containerRadius,
478
+ overflow: "hidden",
479
+ gap: stepper ? sizing.stepperContentGap : 0
480
+ },
481
+ children: [
482
+ stepper && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
483
+ "div",
484
+ {
485
+ style: {
486
+ flexShrink: 0,
487
+ alignSelf: "stretch",
488
+ backgroundColor: theme.colors.background.secondary,
489
+ borderRadius: sizing.contentRadius,
490
+ padding: sizing.stepperPadding,
491
+ display: "flex",
492
+ flexDirection: "column"
493
+ },
494
+ children: stepper
495
+ }
496
+ ),
497
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
498
+ Box,
499
+ {
500
+ ref: (node) => {
501
+ drawerRef.current = node;
502
+ if (typeof ref === "function") ref(node);
503
+ else if (ref)
504
+ ref.current = node;
505
+ },
506
+ role: "dialog",
507
+ "aria-modal": "true",
508
+ "aria-label": typeof title === "string" ? title : void 0,
509
+ tabIndex: -1,
510
+ onKeyDown: handleKeyDown,
511
+ style: {
512
+ width: contentWidth,
513
+ height: "100%",
514
+ flexShrink: 0,
515
+ display: "flex",
516
+ flexDirection: "column",
517
+ outline: "none",
518
+ color: theme.colors.content.primary
519
+ },
520
+ children: [
521
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
522
+ DrawerHeader,
523
+ {
524
+ title,
525
+ onBack,
526
+ onClose,
527
+ headerAction,
528
+ paddingX: sizing.headerPaddingX,
529
+ paddingY: sizing.headerPaddingY,
530
+ gap: sizing.headerGap
531
+ }
532
+ ),
533
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
534
+ Box,
535
+ {
536
+ style: {
537
+ flex: 1,
538
+ minHeight: 0,
539
+ overflowY: "auto",
540
+ paddingLeft: sizing.contentPaddingX,
541
+ paddingRight: sizing.contentPaddingX
542
+ },
543
+ children
544
+ }
545
+ ),
546
+ footer ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
547
+ DrawerFooter,
548
+ {
549
+ align: footerAlign,
550
+ shadow: footerShadow,
551
+ fullWidth: footerFullWidth,
552
+ children: footer
553
+ }
554
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flexShrink: 0, height: 32 } })
555
+ ]
556
+ }
557
+ )
558
+ ]
559
+ }
560
+ )
561
+ }
562
+ );
563
+ }
564
+ );
565
+ Drawer.displayName = "Drawer";
566
+
567
+ // src/useDrawer.ts
568
+ var import_react5 = require("react");
569
+ function useDrawer(options) {
570
+ const [isOpen, setIsOpen] = (0, import_react5.useState)(false);
571
+ const open = (0, import_react5.useCallback)(() => {
572
+ setIsOpen(true);
573
+ options?.onOpen?.();
574
+ }, [options]);
575
+ const close = (0, import_react5.useCallback)(() => {
576
+ setIsOpen(false);
577
+ options?.onClose?.();
578
+ }, [options]);
579
+ return { isOpen, open, close };
580
+ }
581
+ // Annotate the CommonJS export names for ESM import in node:
582
+ 0 && (module.exports = {
583
+ Drawer,
584
+ useDrawer
585
+ });
586
+ //# sourceMappingURL=index.js.map