@rubenpazch/drawer 4.2.6 → 4.3.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 +18 -17
- package/dist/Drawer.d.ts +7 -1
- package/dist/Drawer.d.ts.map +1 -1
- package/dist/index.cjs.js +4 -2
- package/dist/index.d.ts +7 -1
- package/dist/index.esm.js +4 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -17,23 +17,24 @@ npm install @rubenpazch/drawer
|
|
|
17
17
|
|
|
18
18
|
## Drawer
|
|
19
19
|
|
|
20
|
-
| Prop | Tipo | Req. | Por defecto | Descripción
|
|
21
|
-
| --------------------- | -------------------------------------------------- | ---- | --------------- |
|
|
22
|
-
| `children` | `ReactNode` | sí | | Content to render in the drawer
|
|
23
|
-
| `isOpen` | `boolean` | sí | | Whether the drawer is open
|
|
24
|
-
| `onClose` | `() => void` | sí | | Function to close the drawer
|
|
25
|
-
| `className` | `string` | | `` | Custom className for the drawer content
|
|
26
|
-
| `closeLabel` | `string` | |
|
|
27
|
-
| `closeOnEscape` | `boolean` | | `true` | Whether pressing Escape closes the drawer
|
|
28
|
-
| `closeOnOverlayClick` | `boolean` | | `true` | Whether clicking overlay closes the drawer
|
|
29
|
-
| `contentContained` | `boolean` | | `false` | Whether the content (header, body, footer) should be contained in a max-width container
|
|
30
|
-
| `footer` | `ReactNode` | | | Footer content (typically action buttons)
|
|
31
|
-
| `footerAlign` | `"left" \| "right" \| "center" \| "space-between"` | | `right` | Footer alignment
|
|
32
|
-
| `headerAlign` | `"left" \| "right" \| "center" \| "space-between"` | | `space-between` | Header alignment (how to position title and close button)
|
|
33
|
-
| `
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
20
|
+
| Prop | Tipo | Req. | Por defecto | Descripción |
|
|
21
|
+
| --------------------- | -------------------------------------------------- | ---- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
22
|
+
| `children` | `ReactNode` | sí | | Content to render in the drawer |
|
|
23
|
+
| `isOpen` | `boolean` | sí | | Whether the drawer is open |
|
|
24
|
+
| `onClose` | `() => void` | sí | | Function to close the drawer |
|
|
25
|
+
| `className` | `string` | | `` | Custom className for the drawer content |
|
|
26
|
+
| `closeLabel` | `string` | | | Texto accesible del botón de cerrar. @deprecated Usa `labels.close`. |
|
|
27
|
+
| `closeOnEscape` | `boolean` | | `true` | Whether pressing Escape closes the drawer |
|
|
28
|
+
| `closeOnOverlayClick` | `boolean` | | `true` | Whether clicking overlay closes the drawer |
|
|
29
|
+
| `contentContained` | `boolean` | | `false` | Whether the content (header, body, footer) should be contained in a max-width container |
|
|
30
|
+
| `footer` | `ReactNode` | | | Footer content (typically action buttons) |
|
|
31
|
+
| `footerAlign` | `"left" \| "right" \| "center" \| "space-between"` | | `right` | Footer alignment |
|
|
32
|
+
| `headerAlign` | `"left" \| "right" \| "center" \| "space-between"` | | `space-between` | Header alignment (how to position title and close button) |
|
|
33
|
+
| `labels` | `Partial<{ close: string; }>` | | | Textos de la interfaz. Por defecto, los del idioma activo (`UiLocaleProvider`); también se cambian para toda la app con su prop `messages`. |
|
|
34
|
+
| `position` | `"left" \| "right" \| "top" \| "bottom"` | | `right` | Position from which the drawer slides in |
|
|
35
|
+
| `showOverlay` | `boolean` | | `true` | Whether to show overlay backdrop |
|
|
36
|
+
| `size` | `"sm" \| "md" \| "lg" \| "xl" \| "full"` | | `md` | Size of the drawer |
|
|
37
|
+
| `title` | `string` | | | Title displayed in the drawer header |
|
|
37
38
|
|
|
38
39
|
Tipos: `DrawerPosition`, `DrawerSize`, `DrawerAlign`, `DrawerProps`.
|
|
39
40
|
|
package/dist/Drawer.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { type UiMessages } from "@rubenpazch/shared";
|
|
2
3
|
export type DrawerPosition = "left" | "right" | "top" | "bottom";
|
|
3
4
|
export type DrawerSize = "sm" | "md" | "lg" | "xl" | "full";
|
|
4
5
|
export type DrawerAlign = "left" | "center" | "right" | "space-between";
|
|
@@ -21,7 +22,7 @@ export interface DrawerProps {
|
|
|
21
22
|
closeOnOverlayClick?: boolean;
|
|
22
23
|
/** Whether pressing Escape closes the drawer */
|
|
23
24
|
closeOnEscape?: boolean;
|
|
24
|
-
/** Texto accesible del botón de cerrar. */
|
|
25
|
+
/** Texto accesible del botón de cerrar. @deprecated Usa `labels.close`. */
|
|
25
26
|
closeLabel?: string;
|
|
26
27
|
/** Custom className for the drawer content */
|
|
27
28
|
className?: string;
|
|
@@ -33,6 +34,11 @@ export interface DrawerProps {
|
|
|
33
34
|
footerAlign?: DrawerAlign;
|
|
34
35
|
/** Whether the content (header, body, footer) should be contained in a max-width container */
|
|
35
36
|
contentContained?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Textos de la interfaz. Por defecto, los del idioma activo (`UiLocaleProvider`);
|
|
39
|
+
* también se cambian para toda la app con su prop `messages`.
|
|
40
|
+
*/
|
|
41
|
+
labels?: Partial<UiMessages["drawer"]>;
|
|
36
42
|
}
|
|
37
43
|
declare const Drawer: React.FC<DrawerProps>;
|
|
38
44
|
export default Drawer;
|
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;AAC3D,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOpE,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAA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enpazch/shared');
|
|
4
5
|
var icons = require('@rubenpazch/icons');
|
|
5
6
|
|
|
6
7
|
var jsxRuntime = {exports: {}};
|
|
@@ -457,7 +458,8 @@ var styles = {"root":"Drawer-module_root__9H22a","overlay":"Drawer-module_overla
|
|
|
457
458
|
styleInject(css_248z);
|
|
458
459
|
|
|
459
460
|
const classNames = (...classes) => classes.filter(Boolean).join(" ");
|
|
460
|
-
const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, children, showOverlay = true, closeOnOverlayClick = true, closeOnEscape = true, closeLabel
|
|
461
|
+
const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, children, showOverlay = true, closeOnOverlayClick = true, closeOnEscape = true, closeLabel, className = "", footer, headerAlign = "space-between", footerAlign = "right", contentContained = false, labels, }) => {
|
|
462
|
+
const t = shared.useUiMessages("drawer", labels, { close: closeLabel });
|
|
461
463
|
const drawerRef = require$$0.useRef(null);
|
|
462
464
|
const [isAnimating, setIsAnimating] = require$$0.useState(false);
|
|
463
465
|
const [shouldRender, setShouldRender] = require$$0.useState(isOpen);
|
|
@@ -565,7 +567,7 @@ const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, child
|
|
|
565
567
|
right: styles.footerEnd,
|
|
566
568
|
"space-between": styles.footerSpaceBetween,
|
|
567
569
|
}[footerAlign];
|
|
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":
|
|
570
|
+
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": t.close, 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) }))] })] }));
|
|
569
571
|
};
|
|
570
572
|
|
|
571
573
|
module.exports = Drawer;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { UiMessages } from '@rubenpazch/shared';
|
|
2
3
|
|
|
3
4
|
type DrawerPosition = "left" | "right" | "top" | "bottom";
|
|
4
5
|
type DrawerSize = "sm" | "md" | "lg" | "xl" | "full";
|
|
@@ -22,7 +23,7 @@ interface DrawerProps {
|
|
|
22
23
|
closeOnOverlayClick?: boolean;
|
|
23
24
|
/** Whether pressing Escape closes the drawer */
|
|
24
25
|
closeOnEscape?: boolean;
|
|
25
|
-
/** Texto accesible del botón de cerrar. */
|
|
26
|
+
/** Texto accesible del botón de cerrar. @deprecated Usa `labels.close`. */
|
|
26
27
|
closeLabel?: string;
|
|
27
28
|
/** Custom className for the drawer content */
|
|
28
29
|
className?: string;
|
|
@@ -34,6 +35,11 @@ interface DrawerProps {
|
|
|
34
35
|
footerAlign?: DrawerAlign;
|
|
35
36
|
/** Whether the content (header, body, footer) should be contained in a max-width container */
|
|
36
37
|
contentContained?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Textos de la interfaz. Por defecto, los del idioma activo (`UiLocaleProvider`);
|
|
40
|
+
* también se cambian para toda la app con su prop `messages`.
|
|
41
|
+
*/
|
|
42
|
+
labels?: Partial<UiMessages["drawer"]>;
|
|
37
43
|
}
|
|
38
44
|
declare const Drawer: React.FC<DrawerProps>;
|
|
39
45
|
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import require$$0, { useRef, useState, useEffect } from 'react';
|
|
2
|
+
import { useUiMessages } from '@rubenpazch/shared';
|
|
2
3
|
import { CloseIcon } from '@rubenpazch/icons';
|
|
3
4
|
|
|
4
5
|
var jsxRuntime = {exports: {}};
|
|
@@ -455,7 +456,8 @@ var styles = {"root":"Drawer-module_root__9H22a","overlay":"Drawer-module_overla
|
|
|
455
456
|
styleInject(css_248z);
|
|
456
457
|
|
|
457
458
|
const classNames = (...classes) => classes.filter(Boolean).join(" ");
|
|
458
|
-
const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, children, showOverlay = true, closeOnOverlayClick = true, closeOnEscape = true, closeLabel
|
|
459
|
+
const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, children, showOverlay = true, closeOnOverlayClick = true, closeOnEscape = true, closeLabel, className = "", footer, headerAlign = "space-between", footerAlign = "right", contentContained = false, labels, }) => {
|
|
460
|
+
const t = useUiMessages("drawer", labels, { close: closeLabel });
|
|
459
461
|
const drawerRef = useRef(null);
|
|
460
462
|
const [isAnimating, setIsAnimating] = useState(false);
|
|
461
463
|
const [shouldRender, setShouldRender] = useState(isOpen);
|
|
@@ -563,7 +565,7 @@ const Drawer = ({ isOpen, onClose, position = "right", size = "md", title, child
|
|
|
563
565
|
right: styles.footerEnd,
|
|
564
566
|
"space-between": styles.footerSpaceBetween,
|
|
565
567
|
}[footerAlign];
|
|
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":
|
|
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": t.close, 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) }))] })] }));
|
|
567
569
|
};
|
|
568
570
|
|
|
569
571
|
export { Drawer as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rubenpazch/drawer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.0",
|
|
4
4
|
"description": "Flexible drawer/sidebar component with multiple positions and animations",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"@rubenpazch/tokens": "0.5.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@rubenpazch/icons": "6.
|
|
33
|
+
"@rubenpazch/icons": "6.6.1",
|
|
34
|
+
"@rubenpazch/shared": "5.4.0"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@types/react": "^19.2.18",
|