@rubenpazch/drawer 2.0.4 → 3.0.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/dist/Drawer.d.ts.map +1 -1
- package/dist/index.cjs.js +79 -50
- package/dist/index.esm.js +79 -50
- package/package.json +5 -3
package/dist/Drawer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../src/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../src/Drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAO3D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAC5D,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,eAAe,CAAC;AAExE,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,mCAAmC;IACnC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,yBAAyB;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,uCAAuC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iDAAiD;IACjD,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gDAAgD;IAChD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,gEAAgE;IAChE,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,uBAAuB;IACvB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAiNjC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -425,6 +425,38 @@ function requireJsxRuntime () {
|
|
|
425
425
|
|
|
426
426
|
var jsxRuntimeExports = requireJsxRuntime();
|
|
427
427
|
|
|
428
|
+
function styleInject(css, ref) {
|
|
429
|
+
if ( ref === void 0 ) ref = {};
|
|
430
|
+
var insertAt = ref.insertAt;
|
|
431
|
+
|
|
432
|
+
if (typeof document === 'undefined') { return; }
|
|
433
|
+
|
|
434
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
435
|
+
var style = document.createElement('style');
|
|
436
|
+
style.type = 'text/css';
|
|
437
|
+
|
|
438
|
+
if (insertAt === 'top') {
|
|
439
|
+
if (head.firstChild) {
|
|
440
|
+
head.insertBefore(style, head.firstChild);
|
|
441
|
+
} else {
|
|
442
|
+
head.appendChild(style);
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
head.appendChild(style);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
if (style.styleSheet) {
|
|
449
|
+
style.styleSheet.cssText = css;
|
|
450
|
+
} else {
|
|
451
|
+
style.appendChild(document.createTextNode(css));
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
var css_248z = ".Drawer-module_root__9H22a {\n position: fixed;\n inset: 0;\n z-index: 50;\n}\n\n.Drawer-module_overlay__Rargl {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.5);\n transition: opacity 300ms ease;\n}\n\n.Drawer-module_overlayHidden__TFZlN {\n opacity: 0;\n}\n\n.Drawer-module_overlayVisible__N4NrM {\n opacity: 1;\n}\n\n.Drawer-module_drawer__vfWNf {\n position: fixed;\n background: #fff;\n box-shadow:\n 0 10px 15px -3px rgba(0, 0, 0, 0.1),\n 0 4px 6px -4px rgba(0, 0, 0, 0.1);\n transition: transform 300ms ease-in-out;\n display: flex;\n flex-direction: column;\n}\n\n.Drawer-module_left__xgJYo {\n top: 0;\n left: 0;\n height: 100%;\n}\n\n.Drawer-module_right__1tmSN {\n top: 0;\n right: 0;\n height: 100%;\n}\n\n.Drawer-module_top__upIWP {\n top: 0;\n left: 0;\n width: 100%;\n}\n\n.Drawer-module_bottom__6xl26 {\n bottom: 0;\n left: 0;\n width: 100%;\n}\n\n.Drawer-module_widthSm__K6ZGK {\n width: 16rem;\n}\n\n.Drawer-module_widthMd__hLcKn {\n width: 20rem;\n}\n\n.Drawer-module_widthLg__50gKX {\n width: 24rem;\n}\n\n.Drawer-module_widthXl__7K3jw {\n width: 32rem;\n}\n\n.Drawer-module_widthFull__XarDU {\n width: 100%;\n}\n\n.Drawer-module_heightSm__Cfqo4 {\n height: 16rem;\n}\n\n.Drawer-module_heightMd__GuWSW {\n height: 20rem;\n}\n\n.Drawer-module_heightLg__Xegtp {\n height: 24rem;\n}\n\n.Drawer-module_heightXl__KXBN- {\n height: 32rem;\n}\n\n.Drawer-module_heightFull__Ql0LW {\n height: 100%;\n}\n\n.Drawer-module_translateIn__dtrHw {\n transform: translate3d(0, 0, 0);\n}\n\n.Drawer-module_translateLeftOut__D1dDk {\n transform: translate3d(-100%, 0, 0);\n}\n\n.Drawer-module_translateRightOut__l8ajr {\n transform: translate3d(100%, 0, 0);\n}\n\n.Drawer-module_translateTopOut__fo51S {\n transform: translate3d(0, -100%, 0);\n}\n\n.Drawer-module_translateBottomOut__7Mkk7 {\n transform: translate3d(0, 100%, 0);\n}\n\n.Drawer-module_header__9o-ND {\n padding: 1rem 1.5rem;\n border-bottom: 1px solid #e5e7eb;\n}\n\n.Drawer-module_headerCenter__-nLFC {\n text-align: center;\n}\n\n.Drawer-module_headerContent__dZNmL {\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n.Drawer-module_title__eq2N2 {\n font-size: 1.125rem;\n line-height: 1.75rem;\n font-weight: 600;\n color: #111827;\n flex: 1;\n}\n\n.Drawer-module_closeButton__rhBhH {\n margin-left: 1rem;\n padding: 0.25rem;\n border: none;\n border-radius: 0.5rem;\n background: transparent;\n color: #9ca3af;\n cursor: pointer;\n transition:\n color 150ms ease,\n background-color 150ms ease;\n}\n\n.Drawer-module_closeButton__rhBhH:hover {\n color: #4b5563;\n background-color: #f3f4f6;\n}\n\n.Drawer-module_body__u1caV {\n flex: 1;\n overflow-y: auto;\n padding: 1rem 1.5rem;\n}\n\n.Drawer-module_contained__PSHRt {\n max-width: 64rem;\n margin: 0 auto;\n width: 100%;\n}\n\n.Drawer-module_footer__DfyGH {\n padding: 1rem 1.5rem;\n border-top: 1px solid #e5e7eb;\n background: #f9fafb;\n display: flex;\n align-items: center;\n gap: 0.75rem;\n}\n\n.Drawer-module_footerStart__XmQAT {\n justify-content: flex-start;\n}\n\n.Drawer-module_footerCenter__v9ZJN {\n justify-content: center;\n}\n\n.Drawer-module_footerEnd__d1Ysh {\n justify-content: flex-end;\n}\n\n.Drawer-module_footerSpaceBetween__LV5m4 {\n justify-content: space-between;\n}\n";
|
|
456
|
+
var styles = {"root":"Drawer-module_root__9H22a","overlay":"Drawer-module_overlay__Rargl","overlayHidden":"Drawer-module_overlayHidden__TFZlN","overlayVisible":"Drawer-module_overlayVisible__N4NrM","drawer":"Drawer-module_drawer__vfWNf","left":"Drawer-module_left__xgJYo","right":"Drawer-module_right__1tmSN","top":"Drawer-module_top__upIWP","bottom":"Drawer-module_bottom__6xl26","widthSm":"Drawer-module_widthSm__K6ZGK","widthMd":"Drawer-module_widthMd__hLcKn","widthLg":"Drawer-module_widthLg__50gKX","widthXl":"Drawer-module_widthXl__7K3jw","widthFull":"Drawer-module_widthFull__XarDU","heightSm":"Drawer-module_heightSm__Cfqo4","heightMd":"Drawer-module_heightMd__GuWSW","heightLg":"Drawer-module_heightLg__Xegtp","heightXl":"Drawer-module_heightXl__KXBN-","heightFull":"Drawer-module_heightFull__Ql0LW","translateIn":"Drawer-module_translateIn__dtrHw","translateLeftOut":"Drawer-module_translateLeftOut__D1dDk","translateRightOut":"Drawer-module_translateRightOut__l8ajr","translateTopOut":"Drawer-module_translateTopOut__fo51S","translateBottomOut":"Drawer-module_translateBottomOut__7Mkk7","header":"Drawer-module_header__9o-ND","headerCenter":"Drawer-module_headerCenter__-nLFC","headerContent":"Drawer-module_headerContent__dZNmL","title":"Drawer-module_title__eq2N2","closeButton":"Drawer-module_closeButton__rhBhH","body":"Drawer-module_body__u1caV","contained":"Drawer-module_contained__PSHRt","footer":"Drawer-module_footer__DfyGH","footerStart":"Drawer-module_footerStart__XmQAT","footerCenter":"Drawer-module_footerCenter__v9ZJN","footerEnd":"Drawer-module_footerEnd__d1Ysh","footerSpaceBetween":"Drawer-module_footerSpaceBetween__LV5m4"};
|
|
457
|
+
styleInject(css_248z);
|
|
458
|
+
|
|
459
|
+
const classNames = (...classes) => classes.filter(Boolean).join(" ");
|
|
428
460
|
const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, children, showOverlay = true, closeOnOverlayClick = true, closeOnEscape = true, className = "", footer, headerAlign = "space-between", footerAlign = "right", contentContained = false, }) => {
|
|
429
461
|
const drawerRef = require$$0.useRef(null);
|
|
430
462
|
const [isAnimating, setIsAnimating] = require$$0.useState(false);
|
|
@@ -449,52 +481,49 @@ const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, child
|
|
|
449
481
|
return () => clearTimeout(timer);
|
|
450
482
|
}
|
|
451
483
|
}, [isOpen]);
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
top: isAnimating ? "translate-y-0" : "-translate-y-full",
|
|
494
|
-
bottom: isAnimating ? "translate-y-0" : "translate-y-full",
|
|
495
|
-
};
|
|
496
|
-
return `${base} ${positions[position]} ${sizes[position][size]} ${transforms[position]} ${className}`;
|
|
484
|
+
const positionClasses = {
|
|
485
|
+
left: styles.left,
|
|
486
|
+
right: styles.right,
|
|
487
|
+
top: styles.top,
|
|
488
|
+
bottom: styles.bottom,
|
|
489
|
+
};
|
|
490
|
+
const sizeClasses = {
|
|
491
|
+
left: {
|
|
492
|
+
sm: styles.widthSm,
|
|
493
|
+
md: styles.widthMd,
|
|
494
|
+
lg: styles.widthLg,
|
|
495
|
+
xl: styles.widthXl,
|
|
496
|
+
full: styles.widthFull,
|
|
497
|
+
},
|
|
498
|
+
right: {
|
|
499
|
+
sm: styles.widthSm,
|
|
500
|
+
md: styles.widthMd,
|
|
501
|
+
lg: styles.widthLg,
|
|
502
|
+
xl: styles.widthXl,
|
|
503
|
+
full: styles.widthFull,
|
|
504
|
+
},
|
|
505
|
+
top: {
|
|
506
|
+
sm: styles.heightSm,
|
|
507
|
+
md: styles.heightMd,
|
|
508
|
+
lg: styles.heightLg,
|
|
509
|
+
xl: styles.heightXl,
|
|
510
|
+
full: styles.heightFull,
|
|
511
|
+
},
|
|
512
|
+
bottom: {
|
|
513
|
+
sm: styles.heightSm,
|
|
514
|
+
md: styles.heightMd,
|
|
515
|
+
lg: styles.heightLg,
|
|
516
|
+
xl: styles.heightXl,
|
|
517
|
+
full: styles.heightFull,
|
|
518
|
+
},
|
|
519
|
+
};
|
|
520
|
+
const transformClasses = {
|
|
521
|
+
left: isAnimating ? styles.translateIn : styles.translateLeftOut,
|
|
522
|
+
right: isAnimating ? styles.translateIn : styles.translateRightOut,
|
|
523
|
+
top: isAnimating ? styles.translateIn : styles.translateTopOut,
|
|
524
|
+
bottom: isAnimating ? styles.translateIn : styles.translateBottomOut,
|
|
497
525
|
};
|
|
526
|
+
const getPositionClasses = () => classNames(styles.drawer, positionClasses[position], sizeClasses[position][size], transformClasses[position], className);
|
|
498
527
|
require$$0.useEffect(() => {
|
|
499
528
|
if (!isOpen || !closeOnEscape)
|
|
500
529
|
return;
|
|
@@ -531,12 +560,12 @@ const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, child
|
|
|
531
560
|
if (!shouldRender)
|
|
532
561
|
return null;
|
|
533
562
|
const footerAlignClass = {
|
|
534
|
-
left:
|
|
535
|
-
center:
|
|
536
|
-
right:
|
|
537
|
-
"space-between":
|
|
563
|
+
left: styles.footerStart,
|
|
564
|
+
center: styles.footerCenter,
|
|
565
|
+
right: styles.footerEnd,
|
|
566
|
+
"space-between": styles.footerSpaceBetween,
|
|
538
567
|
}[footerAlign];
|
|
539
|
-
return (jsxRuntimeExports.jsxs("div", { className:
|
|
568
|
+
return (jsxRuntimeExports.jsxs("div", { className: styles.root, role: "dialog", "aria-modal": "true", "aria-labelledby": title ? "drawer-title" : undefined, children: [showOverlay && (jsxRuntimeExports.jsx("div", { className: classNames(styles.overlay, isAnimating ? styles.overlayVisible : styles.overlayHidden), "data-testid": "drawer-overlay", onClick: handleOverlayClick, "aria-hidden": "true" })), jsxRuntimeExports.jsxs("div", { ref: drawerRef, tabIndex: -1, className: getPositionClasses(), "data-position": position, "data-size": size, children: [title && (jsxRuntimeExports.jsx("div", { className: classNames(styles.header, headerAlign === "center" && styles.headerCenter), children: jsxRuntimeExports.jsxs("div", { className: styles.headerContent, children: [jsxRuntimeExports.jsx("h2", { id: "drawer-title", className: styles.title, children: title }), jsxRuntimeExports.jsx("button", { onClick: onClose, className: styles.closeButton, "aria-label": "Close drawer", children: jsxRuntimeExports.jsx(icons.CloseIcon, { size: "md" }) })] }) })), jsxRuntimeExports.jsx("div", { className: styles.body, children: contentContained ? (jsxRuntimeExports.jsx("div", { className: styles.contained, children: children })) : (children) }), footer && (jsxRuntimeExports.jsx("div", { className: classNames(styles.footer, footerAlignClass), children: contentContained ? (jsxRuntimeExports.jsx("div", { className: styles.contained, children: footer })) : (footer) }))] })] }));
|
|
540
569
|
};
|
|
541
570
|
|
|
542
571
|
module.exports = Drawer;
|
package/dist/index.esm.js
CHANGED
|
@@ -423,6 +423,38 @@ function requireJsxRuntime () {
|
|
|
423
423
|
|
|
424
424
|
var jsxRuntimeExports = requireJsxRuntime();
|
|
425
425
|
|
|
426
|
+
function styleInject(css, ref) {
|
|
427
|
+
if ( ref === void 0 ) ref = {};
|
|
428
|
+
var insertAt = ref.insertAt;
|
|
429
|
+
|
|
430
|
+
if (typeof document === 'undefined') { return; }
|
|
431
|
+
|
|
432
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
433
|
+
var style = document.createElement('style');
|
|
434
|
+
style.type = 'text/css';
|
|
435
|
+
|
|
436
|
+
if (insertAt === 'top') {
|
|
437
|
+
if (head.firstChild) {
|
|
438
|
+
head.insertBefore(style, head.firstChild);
|
|
439
|
+
} else {
|
|
440
|
+
head.appendChild(style);
|
|
441
|
+
}
|
|
442
|
+
} else {
|
|
443
|
+
head.appendChild(style);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (style.styleSheet) {
|
|
447
|
+
style.styleSheet.cssText = css;
|
|
448
|
+
} else {
|
|
449
|
+
style.appendChild(document.createTextNode(css));
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
var css_248z = ".Drawer-module_root__9H22a {\n position: fixed;\n inset: 0;\n z-index: 50;\n}\n\n.Drawer-module_overlay__Rargl {\n position: fixed;\n inset: 0;\n background: rgba(0, 0, 0, 0.5);\n transition: opacity 300ms ease;\n}\n\n.Drawer-module_overlayHidden__TFZlN {\n opacity: 0;\n}\n\n.Drawer-module_overlayVisible__N4NrM {\n opacity: 1;\n}\n\n.Drawer-module_drawer__vfWNf {\n position: fixed;\n background: #fff;\n box-shadow:\n 0 10px 15px -3px rgba(0, 0, 0, 0.1),\n 0 4px 6px -4px rgba(0, 0, 0, 0.1);\n transition: transform 300ms ease-in-out;\n display: flex;\n flex-direction: column;\n}\n\n.Drawer-module_left__xgJYo {\n top: 0;\n left: 0;\n height: 100%;\n}\n\n.Drawer-module_right__1tmSN {\n top: 0;\n right: 0;\n height: 100%;\n}\n\n.Drawer-module_top__upIWP {\n top: 0;\n left: 0;\n width: 100%;\n}\n\n.Drawer-module_bottom__6xl26 {\n bottom: 0;\n left: 0;\n width: 100%;\n}\n\n.Drawer-module_widthSm__K6ZGK {\n width: 16rem;\n}\n\n.Drawer-module_widthMd__hLcKn {\n width: 20rem;\n}\n\n.Drawer-module_widthLg__50gKX {\n width: 24rem;\n}\n\n.Drawer-module_widthXl__7K3jw {\n width: 32rem;\n}\n\n.Drawer-module_widthFull__XarDU {\n width: 100%;\n}\n\n.Drawer-module_heightSm__Cfqo4 {\n height: 16rem;\n}\n\n.Drawer-module_heightMd__GuWSW {\n height: 20rem;\n}\n\n.Drawer-module_heightLg__Xegtp {\n height: 24rem;\n}\n\n.Drawer-module_heightXl__KXBN- {\n height: 32rem;\n}\n\n.Drawer-module_heightFull__Ql0LW {\n height: 100%;\n}\n\n.Drawer-module_translateIn__dtrHw {\n transform: translate3d(0, 0, 0);\n}\n\n.Drawer-module_translateLeftOut__D1dDk {\n transform: translate3d(-100%, 0, 0);\n}\n\n.Drawer-module_translateRightOut__l8ajr {\n transform: translate3d(100%, 0, 0);\n}\n\n.Drawer-module_translateTopOut__fo51S {\n transform: translate3d(0, -100%, 0);\n}\n\n.Drawer-module_translateBottomOut__7Mkk7 {\n transform: translate3d(0, 100%, 0);\n}\n\n.Drawer-module_header__9o-ND {\n padding: 1rem 1.5rem;\n border-bottom: 1px solid #e5e7eb;\n}\n\n.Drawer-module_headerCenter__-nLFC {\n text-align: center;\n}\n\n.Drawer-module_headerContent__dZNmL {\n display: flex;\n align-items: center;\n justify-content: space-between;\n}\n\n.Drawer-module_title__eq2N2 {\n font-size: 1.125rem;\n line-height: 1.75rem;\n font-weight: 600;\n color: #111827;\n flex: 1;\n}\n\n.Drawer-module_closeButton__rhBhH {\n margin-left: 1rem;\n padding: 0.25rem;\n border: none;\n border-radius: 0.5rem;\n background: transparent;\n color: #9ca3af;\n cursor: pointer;\n transition:\n color 150ms ease,\n background-color 150ms ease;\n}\n\n.Drawer-module_closeButton__rhBhH:hover {\n color: #4b5563;\n background-color: #f3f4f6;\n}\n\n.Drawer-module_body__u1caV {\n flex: 1;\n overflow-y: auto;\n padding: 1rem 1.5rem;\n}\n\n.Drawer-module_contained__PSHRt {\n max-width: 64rem;\n margin: 0 auto;\n width: 100%;\n}\n\n.Drawer-module_footer__DfyGH {\n padding: 1rem 1.5rem;\n border-top: 1px solid #e5e7eb;\n background: #f9fafb;\n display: flex;\n align-items: center;\n gap: 0.75rem;\n}\n\n.Drawer-module_footerStart__XmQAT {\n justify-content: flex-start;\n}\n\n.Drawer-module_footerCenter__v9ZJN {\n justify-content: center;\n}\n\n.Drawer-module_footerEnd__d1Ysh {\n justify-content: flex-end;\n}\n\n.Drawer-module_footerSpaceBetween__LV5m4 {\n justify-content: space-between;\n}\n";
|
|
454
|
+
var styles = {"root":"Drawer-module_root__9H22a","overlay":"Drawer-module_overlay__Rargl","overlayHidden":"Drawer-module_overlayHidden__TFZlN","overlayVisible":"Drawer-module_overlayVisible__N4NrM","drawer":"Drawer-module_drawer__vfWNf","left":"Drawer-module_left__xgJYo","right":"Drawer-module_right__1tmSN","top":"Drawer-module_top__upIWP","bottom":"Drawer-module_bottom__6xl26","widthSm":"Drawer-module_widthSm__K6ZGK","widthMd":"Drawer-module_widthMd__hLcKn","widthLg":"Drawer-module_widthLg__50gKX","widthXl":"Drawer-module_widthXl__7K3jw","widthFull":"Drawer-module_widthFull__XarDU","heightSm":"Drawer-module_heightSm__Cfqo4","heightMd":"Drawer-module_heightMd__GuWSW","heightLg":"Drawer-module_heightLg__Xegtp","heightXl":"Drawer-module_heightXl__KXBN-","heightFull":"Drawer-module_heightFull__Ql0LW","translateIn":"Drawer-module_translateIn__dtrHw","translateLeftOut":"Drawer-module_translateLeftOut__D1dDk","translateRightOut":"Drawer-module_translateRightOut__l8ajr","translateTopOut":"Drawer-module_translateTopOut__fo51S","translateBottomOut":"Drawer-module_translateBottomOut__7Mkk7","header":"Drawer-module_header__9o-ND","headerCenter":"Drawer-module_headerCenter__-nLFC","headerContent":"Drawer-module_headerContent__dZNmL","title":"Drawer-module_title__eq2N2","closeButton":"Drawer-module_closeButton__rhBhH","body":"Drawer-module_body__u1caV","contained":"Drawer-module_contained__PSHRt","footer":"Drawer-module_footer__DfyGH","footerStart":"Drawer-module_footerStart__XmQAT","footerCenter":"Drawer-module_footerCenter__v9ZJN","footerEnd":"Drawer-module_footerEnd__d1Ysh","footerSpaceBetween":"Drawer-module_footerSpaceBetween__LV5m4"};
|
|
455
|
+
styleInject(css_248z);
|
|
456
|
+
|
|
457
|
+
const classNames = (...classes) => classes.filter(Boolean).join(" ");
|
|
426
458
|
const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, children, showOverlay = true, closeOnOverlayClick = true, closeOnEscape = true, className = "", footer, headerAlign = "space-between", footerAlign = "right", contentContained = false, }) => {
|
|
427
459
|
const drawerRef = useRef(null);
|
|
428
460
|
const [isAnimating, setIsAnimating] = useState(false);
|
|
@@ -447,52 +479,49 @@ const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, child
|
|
|
447
479
|
return () => clearTimeout(timer);
|
|
448
480
|
}
|
|
449
481
|
}, [isOpen]);
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
top: isAnimating ? "translate-y-0" : "-translate-y-full",
|
|
492
|
-
bottom: isAnimating ? "translate-y-0" : "translate-y-full",
|
|
493
|
-
};
|
|
494
|
-
return `${base} ${positions[position]} ${sizes[position][size]} ${transforms[position]} ${className}`;
|
|
482
|
+
const positionClasses = {
|
|
483
|
+
left: styles.left,
|
|
484
|
+
right: styles.right,
|
|
485
|
+
top: styles.top,
|
|
486
|
+
bottom: styles.bottom,
|
|
487
|
+
};
|
|
488
|
+
const sizeClasses = {
|
|
489
|
+
left: {
|
|
490
|
+
sm: styles.widthSm,
|
|
491
|
+
md: styles.widthMd,
|
|
492
|
+
lg: styles.widthLg,
|
|
493
|
+
xl: styles.widthXl,
|
|
494
|
+
full: styles.widthFull,
|
|
495
|
+
},
|
|
496
|
+
right: {
|
|
497
|
+
sm: styles.widthSm,
|
|
498
|
+
md: styles.widthMd,
|
|
499
|
+
lg: styles.widthLg,
|
|
500
|
+
xl: styles.widthXl,
|
|
501
|
+
full: styles.widthFull,
|
|
502
|
+
},
|
|
503
|
+
top: {
|
|
504
|
+
sm: styles.heightSm,
|
|
505
|
+
md: styles.heightMd,
|
|
506
|
+
lg: styles.heightLg,
|
|
507
|
+
xl: styles.heightXl,
|
|
508
|
+
full: styles.heightFull,
|
|
509
|
+
},
|
|
510
|
+
bottom: {
|
|
511
|
+
sm: styles.heightSm,
|
|
512
|
+
md: styles.heightMd,
|
|
513
|
+
lg: styles.heightLg,
|
|
514
|
+
xl: styles.heightXl,
|
|
515
|
+
full: styles.heightFull,
|
|
516
|
+
},
|
|
517
|
+
};
|
|
518
|
+
const transformClasses = {
|
|
519
|
+
left: isAnimating ? styles.translateIn : styles.translateLeftOut,
|
|
520
|
+
right: isAnimating ? styles.translateIn : styles.translateRightOut,
|
|
521
|
+
top: isAnimating ? styles.translateIn : styles.translateTopOut,
|
|
522
|
+
bottom: isAnimating ? styles.translateIn : styles.translateBottomOut,
|
|
495
523
|
};
|
|
524
|
+
const getPositionClasses = () => classNames(styles.drawer, positionClasses[position], sizeClasses[position][size], transformClasses[position], className);
|
|
496
525
|
useEffect(() => {
|
|
497
526
|
if (!isOpen || !closeOnEscape)
|
|
498
527
|
return;
|
|
@@ -529,12 +558,12 @@ const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, child
|
|
|
529
558
|
if (!shouldRender)
|
|
530
559
|
return null;
|
|
531
560
|
const footerAlignClass = {
|
|
532
|
-
left:
|
|
533
|
-
center:
|
|
534
|
-
right:
|
|
535
|
-
"space-between":
|
|
561
|
+
left: styles.footerStart,
|
|
562
|
+
center: styles.footerCenter,
|
|
563
|
+
right: styles.footerEnd,
|
|
564
|
+
"space-between": styles.footerSpaceBetween,
|
|
536
565
|
}[footerAlign];
|
|
537
|
-
return (jsxRuntimeExports.jsxs("div", { className:
|
|
566
|
+
return (jsxRuntimeExports.jsxs("div", { className: styles.root, role: "dialog", "aria-modal": "true", "aria-labelledby": title ? "drawer-title" : undefined, children: [showOverlay && (jsxRuntimeExports.jsx("div", { className: classNames(styles.overlay, isAnimating ? styles.overlayVisible : styles.overlayHidden), "data-testid": "drawer-overlay", onClick: handleOverlayClick, "aria-hidden": "true" })), jsxRuntimeExports.jsxs("div", { ref: drawerRef, tabIndex: -1, className: getPositionClasses(), "data-position": position, "data-size": size, children: [title && (jsxRuntimeExports.jsx("div", { className: classNames(styles.header, headerAlign === "center" && styles.headerCenter), children: jsxRuntimeExports.jsxs("div", { className: styles.headerContent, children: [jsxRuntimeExports.jsx("h2", { id: "drawer-title", className: styles.title, children: title }), jsxRuntimeExports.jsx("button", { onClick: onClose, className: styles.closeButton, "aria-label": "Close drawer", children: jsxRuntimeExports.jsx(CloseIcon, { size: "md" }) })] }) })), jsxRuntimeExports.jsx("div", { className: styles.body, children: contentContained ? (jsxRuntimeExports.jsx("div", { className: styles.contained, children: children })) : (children) }), footer && (jsxRuntimeExports.jsx("div", { className: classNames(styles.footer, footerAlignClass), children: contentContained ? (jsxRuntimeExports.jsx("div", { className: styles.contained, children: footer })) : (footer) }))] })] }));
|
|
538
567
|
};
|
|
539
568
|
|
|
540
569
|
export { Drawer as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubenpazch/drawer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Flexible drawer/sidebar component with multiple positions and animations",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
|
-
"sideEffects":
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"**/*.css"
|
|
21
|
+
],
|
|
20
22
|
"exports": {
|
|
21
23
|
".": {
|
|
22
24
|
"import": "./dist/index.esm.js",
|
|
@@ -25,7 +27,7 @@
|
|
|
25
27
|
}
|
|
26
28
|
},
|
|
27
29
|
"dependencies": {
|
|
28
|
-
"@rubenpazch/icons": "
|
|
30
|
+
"@rubenpazch/icons": "4.0.0"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
31
33
|
"@types/react": "^19.0.2",
|