@trackunit/react-drawer 2.6.22-alpha-3e7014314a8.0 → 2.6.25
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/index.cjs.js +11 -3
- package/index.esm.js +11 -3
- package/package.json +4 -4
- package/src/components/Drawer/Drawer.d.ts +42 -6
- package/src/components/Drawer/Drawer.variants.d.ts +9 -1
- package/src/components/Drawer/useDrawer.d.ts +18 -0
- package/translation.cjs.js +4 -1
- package/translation.esm.js +4 -1
- package/translation10.cjs.js +4 -1
- package/translation10.esm.js +4 -1
- package/translation11.cjs.js +4 -1
- package/translation11.esm.js +4 -1
- package/translation12.cjs.js +4 -1
- package/translation12.esm.js +4 -1
- package/translation13.cjs.js +4 -1
- package/translation13.esm.js +4 -1
- package/translation14.cjs.js +4 -1
- package/translation14.esm.js +4 -1
- package/translation15.cjs.js +4 -1
- package/translation15.esm.js +4 -1
- package/translation16.cjs.js +4 -1
- package/translation16.esm.js +4 -1
- package/translation17.cjs.js +4 -1
- package/translation17.esm.js +4 -1
- package/translation2.cjs.js +4 -1
- package/translation2.esm.js +4 -1
- package/translation3.cjs.js +4 -1
- package/translation3.esm.js +4 -1
- package/translation4.cjs.js +4 -1
- package/translation4.esm.js +4 -1
- package/translation5.cjs.js +4 -1
- package/translation5.esm.js +4 -1
- package/translation6.cjs.js +4 -1
- package/translation6.esm.js +4 -1
- package/translation7.cjs.js +4 -1
- package/translation7.esm.js +4 -1
- package/translation8.cjs.js +4 -1
- package/translation8.esm.js +4 -1
- package/translation9.cjs.js +4 -1
- package/translation9.esm.js +4 -1
package/index.cjs.js
CHANGED
|
@@ -102,10 +102,18 @@ const cvaOverlayContainer = cssClassVarianceUtilities.cvaMerge([
|
|
|
102
102
|
*
|
|
103
103
|
* - `portaled` → `fixed` (viewport-relative; escapes parent layout)
|
|
104
104
|
* - in-tree → `absolute` (parent must establish a containing block, e.g. `relative`)
|
|
105
|
+
*
|
|
106
|
+
* The viewport container sits at `z-drawer` (35) — below `z-main-menu` (50) and
|
|
107
|
+
* `z-main-menu-drawer` (40), so the navigation rail and its flyout drawer always
|
|
108
|
+
* stack above regular drawers. Consumers that need drawer content to cover the
|
|
109
|
+
* navigation (e.g. the flyout drawer itself) override via `containerClassName`.
|
|
110
|
+
* Everything painted inside this container — the panel and modal backdrop — stacks
|
|
111
|
+
* within this local context, so their in-panel `z-overlay` still keeps the panel
|
|
112
|
+
* above the backdrop.
|
|
105
113
|
*/
|
|
106
114
|
const cvaDrawerViewport = cssClassVarianceUtilities.cvaMerge([
|
|
107
115
|
"inset-0",
|
|
108
|
-
"z-
|
|
116
|
+
"z-drawer",
|
|
109
117
|
"overflow-hidden",
|
|
110
118
|
"overscroll-none",
|
|
111
119
|
// Let non-modal drawers keep the page interactive; panel/overlay opt back in.
|
|
@@ -296,7 +304,7 @@ const PANEL_FOCUSABLE_SELECTOR = [
|
|
|
296
304
|
* ```
|
|
297
305
|
* @param {DrawerProps} props - The props for the Drawer component
|
|
298
306
|
*/
|
|
299
|
-
const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi,
|
|
307
|
+
const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, children, "data-testid": dataTestId, className, renderInPortal = false, containerClassName, ariaLabel, ariaLabelledBy, }) => {
|
|
300
308
|
const { isSm } = reactComponents.useViewportBreakpoints();
|
|
301
309
|
const shouldUsePortal = !isSm || renderInPortal;
|
|
302
310
|
const panelRef = react.useRef(null);
|
|
@@ -410,7 +418,7 @@ const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, open: _open,
|
|
|
410
418
|
mode: drawerState.mode,
|
|
411
419
|
position: position,
|
|
412
420
|
className,
|
|
413
|
-
}), "data-testid": dataTestId, onTransitionEnd: handleAnimationEnd, ref: mergedPanelRef, role: isModal ? "dialog" : "complementary", ...floatingProps,
|
|
421
|
+
}), "data-testid": dataTestId, onTransitionEnd: handleAnimationEnd, ref: mergedPanelRef, role: isModal ? "dialog" : "complementary", ...floatingProps, style: {
|
|
414
422
|
...getDrawerMotionStyle({ mode: drawerState.mode, position }),
|
|
415
423
|
}, children: jsxRuntime.jsx("div", { className: cvaDrawerContent({ position }), children: children }) }));
|
|
416
424
|
const content = (jsxRuntime.jsxs("div", { className: cvaDrawerViewport({ portaled: shouldUsePortal, className: containerClassName }), "data-testid": "drawer-viewport", children: [isModal ? jsxRuntime.jsx(Overlay, { open: isOpen ? drawerState.mode === "open" : false }) : null, showFocusManager ? (jsxRuntime.jsx(react$1.FloatingFocusManager, { context: floatingUi.context, initialFocus: -1, returnFocus: true, children: panel })) : (panel)] }));
|
package/index.esm.js
CHANGED
|
@@ -100,10 +100,18 @@ const cvaOverlayContainer = cvaMerge([
|
|
|
100
100
|
*
|
|
101
101
|
* - `portaled` → `fixed` (viewport-relative; escapes parent layout)
|
|
102
102
|
* - in-tree → `absolute` (parent must establish a containing block, e.g. `relative`)
|
|
103
|
+
*
|
|
104
|
+
* The viewport container sits at `z-drawer` (35) — below `z-main-menu` (50) and
|
|
105
|
+
* `z-main-menu-drawer` (40), so the navigation rail and its flyout drawer always
|
|
106
|
+
* stack above regular drawers. Consumers that need drawer content to cover the
|
|
107
|
+
* navigation (e.g. the flyout drawer itself) override via `containerClassName`.
|
|
108
|
+
* Everything painted inside this container — the panel and modal backdrop — stacks
|
|
109
|
+
* within this local context, so their in-panel `z-overlay` still keeps the panel
|
|
110
|
+
* above the backdrop.
|
|
103
111
|
*/
|
|
104
112
|
const cvaDrawerViewport = cvaMerge([
|
|
105
113
|
"inset-0",
|
|
106
|
-
"z-
|
|
114
|
+
"z-drawer",
|
|
107
115
|
"overflow-hidden",
|
|
108
116
|
"overscroll-none",
|
|
109
117
|
// Let non-modal drawers keep the page interactive; panel/overlay opt back in.
|
|
@@ -294,7 +302,7 @@ const PANEL_FOCUSABLE_SELECTOR = [
|
|
|
294
302
|
* ```
|
|
295
303
|
* @param {DrawerProps} props - The props for the Drawer component
|
|
296
304
|
*/
|
|
297
|
-
const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi,
|
|
305
|
+
const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, children, "data-testid": dataTestId, className, renderInPortal = false, containerClassName, ariaLabel, ariaLabelledBy, }) => {
|
|
298
306
|
const { isSm } = useViewportBreakpoints();
|
|
299
307
|
const shouldUsePortal = !isSm || renderInPortal;
|
|
300
308
|
const panelRef = useRef(null);
|
|
@@ -408,7 +416,7 @@ const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, open: _open,
|
|
|
408
416
|
mode: drawerState.mode,
|
|
409
417
|
position: position,
|
|
410
418
|
className,
|
|
411
|
-
}), "data-testid": dataTestId, onTransitionEnd: handleAnimationEnd, ref: mergedPanelRef, role: isModal ? "dialog" : "complementary", ...floatingProps,
|
|
419
|
+
}), "data-testid": dataTestId, onTransitionEnd: handleAnimationEnd, ref: mergedPanelRef, role: isModal ? "dialog" : "complementary", ...floatingProps, style: {
|
|
412
420
|
...getDrawerMotionStyle({ mode: drawerState.mode, position }),
|
|
413
421
|
}, children: jsx("div", { className: cvaDrawerContent({ position }), children: children }) }));
|
|
414
422
|
const content = (jsxs("div", { className: cvaDrawerViewport({ portaled: shouldUsePortal, className: containerClassName }), "data-testid": "drawer-viewport", children: [isModal ? jsx(Overlay, { open: isOpen ? drawerState.mode === "open" : false }) : null, showFocusManager ? (jsx(FloatingFocusManager, { context: floatingUi.context, initialFocus: -1, returnFocus: true, children: panel })) : (panel)] }));
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-drawer",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.25",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/react-components": "2.10.
|
|
11
|
-
"@trackunit/css-class-variance-utilities": "1.14.
|
|
12
|
-
"@trackunit/i18n-library-translation": "2.4.
|
|
10
|
+
"@trackunit/react-components": "2.10.19",
|
|
11
|
+
"@trackunit/css-class-variance-utilities": "1.14.19",
|
|
12
|
+
"@trackunit/i18n-library-translation": "2.4.25",
|
|
13
13
|
"@floating-ui/react": "^0.26.25",
|
|
14
14
|
"tailwind-merge": "^2.0.0"
|
|
15
15
|
},
|
|
@@ -1,12 +1,48 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
-
import type {
|
|
3
|
+
import type { DrawerPosition } from "../../types";
|
|
4
|
+
import type { DrawerFloatingUiProps, DrawerVariant } from "./useDrawer";
|
|
4
5
|
/**
|
|
5
|
-
* Presentational props for `Drawer`. State,
|
|
6
|
-
* opt-in,
|
|
7
|
-
* `
|
|
6
|
+
* Presentational props for `Drawer`. State (`isOpen`), resolved `variant`,
|
|
7
|
+
* focus-trap opt-in (`trapFocus`), `position`, and Floating UI wiring
|
|
8
|
+
* (`floatingUi`) all flow in from `useDrawer()`.
|
|
9
|
+
*
|
|
10
|
+
* Decoupled from the full `UseDrawerReturnValue` — `Drawer` only declares the
|
|
11
|
+
* props it actually reads. Consumers spread the hook return
|
|
12
|
+
* (`<Drawer {...drawer} />`) and TypeScript allows extra properties on spread
|
|
13
|
+
* expressions, so the imperative actions (`open` / `close` / `toggle` /
|
|
14
|
+
* `requestClose`) travel through the JSX without being typed here. This keeps
|
|
15
|
+
* the Storybook autodocs table (and the component's declared surface) focused
|
|
16
|
+
* on what `Drawer` genuinely consumes. Mirrors `Sheet`'s pattern in
|
|
17
|
+
* `@trackunit/react-components`.
|
|
8
18
|
*/
|
|
9
|
-
export interface DrawerProps extends CommonProps
|
|
19
|
+
export interface DrawerProps extends CommonProps {
|
|
20
|
+
/**
|
|
21
|
+
* Current open state — spread from `useDrawer()`. Drives the enter / exit
|
|
22
|
+
* animation and whether the overlay renders (when `variant="modal"`).
|
|
23
|
+
*/
|
|
24
|
+
readonly isOpen: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Semantic variant controlling backdrop, focus trap, and dismiss behavior.
|
|
27
|
+
* Spread from `useDrawer()`. See {@link DrawerVariant}.
|
|
28
|
+
*/
|
|
29
|
+
readonly variant: DrawerVariant;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to trap focus inside the panel when `variant="modal"`. Ignored for
|
|
32
|
+
* `variant="default"` (which never traps focus). Spread from `useDrawer()`.
|
|
33
|
+
*/
|
|
34
|
+
readonly trapFocus: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Which edge of the viewport the panel is anchored to and slides in from.
|
|
37
|
+
* Spread from `useDrawer()`.
|
|
38
|
+
*/
|
|
39
|
+
readonly position: DrawerPosition;
|
|
40
|
+
/**
|
|
41
|
+
* Floating UI wiring for the panel's focus manager and dismiss bindings.
|
|
42
|
+
* `Drawer` merges `refs.setFloating` onto the panel and uses `context` for
|
|
43
|
+
* its `FloatingFocusManager`. Spread from `useDrawer()`.
|
|
44
|
+
*/
|
|
45
|
+
readonly floatingUi: DrawerFloatingUiProps;
|
|
10
46
|
/**
|
|
11
47
|
* Content rendered inside the drawer panel. Compose layout parts explicitly — typically
|
|
12
48
|
* `<DrawerHeader />` (or a custom header such as `CardHeader`) followed by the body.
|
|
@@ -99,6 +135,6 @@ export interface DrawerProps extends CommonProps, UseDrawerReturnValue {
|
|
|
99
135
|
* @param {DrawerProps} props - The props for the Drawer component
|
|
100
136
|
*/
|
|
101
137
|
export declare const Drawer: {
|
|
102
|
-
({ isOpen, variant, trapFocus, position, floatingUi,
|
|
138
|
+
({ isOpen, variant, trapFocus, position, floatingUi, children, "data-testid": dataTestId, className, renderInPortal, containerClassName, ariaLabel, ariaLabelledBy, }: DrawerProps): ReactElement | null;
|
|
103
139
|
displayName: string;
|
|
104
140
|
};
|
|
@@ -4,13 +4,21 @@
|
|
|
4
4
|
*
|
|
5
5
|
* - `portaled` → `fixed` (viewport-relative; escapes parent layout)
|
|
6
6
|
* - in-tree → `absolute` (parent must establish a containing block, e.g. `relative`)
|
|
7
|
+
*
|
|
8
|
+
* The viewport container sits at `z-drawer` (35) — below `z-main-menu` (50) and
|
|
9
|
+
* `z-main-menu-drawer` (40), so the navigation rail and its flyout drawer always
|
|
10
|
+
* stack above regular drawers. Consumers that need drawer content to cover the
|
|
11
|
+
* navigation (e.g. the flyout drawer itself) override via `containerClassName`.
|
|
12
|
+
* Everything painted inside this container — the panel and modal backdrop — stacks
|
|
13
|
+
* within this local context, so their in-panel `z-overlay` still keeps the panel
|
|
14
|
+
* above the backdrop.
|
|
7
15
|
*/
|
|
8
16
|
export declare const cvaDrawerViewport: (props?: ({
|
|
9
17
|
portaled?: boolean | null | undefined;
|
|
10
18
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
19
|
export declare const cvaDrawer: (props?: ({
|
|
12
20
|
position?: "left" | "right" | null | undefined;
|
|
13
|
-
mode?: "
|
|
21
|
+
mode?: "closed" | "open" | null | undefined;
|
|
14
22
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
15
23
|
export declare const cvaDrawerContent: (props?: ({
|
|
16
24
|
position?: "left" | "right" | null | undefined;
|
|
@@ -58,9 +58,27 @@ export type UseDrawerProps = UseOverlayDismissibleProps & {
|
|
|
58
58
|
};
|
|
59
59
|
/** Return value of the {@link useDrawer} hook. */
|
|
60
60
|
export type UseDrawerReturnValue = {
|
|
61
|
+
/**
|
|
62
|
+
* Current open state. Spread onto `Drawer` — the component reads this to drive
|
|
63
|
+
* its enter / exit animation and to decide whether to render the overlay.
|
|
64
|
+
*/
|
|
61
65
|
readonly isOpen: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Open the drawer imperatively. Wire to a trigger, e.g. `onClick={drawer.open}`.
|
|
68
|
+
* Fires `onOpen` and `onOpenChange(true)` and flips `isOpen` to `true`. Bypasses
|
|
69
|
+
* the `onBeforeClose` guard (which only runs on close attempts).
|
|
70
|
+
*/
|
|
62
71
|
readonly open: () => void;
|
|
72
|
+
/**
|
|
73
|
+
* Close the drawer imperatively. Equivalent to `requestClose(undefined, "programmatic")`
|
|
74
|
+
* — runs the `onBeforeClose` guard (when provided) and only fires `onClose` /
|
|
75
|
+
* flips state if the guard resolves to `true`.
|
|
76
|
+
*/
|
|
63
77
|
readonly close: () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Toggle open state. Convenience wrapper — calls `open()` when closed and
|
|
80
|
+
* `close()` when open.
|
|
81
|
+
*/
|
|
64
82
|
readonly toggle: () => void;
|
|
65
83
|
/**
|
|
66
84
|
* Close the drawer with a specific reason. Runs `onBeforeClose` first
|
package/translation.cjs.js
CHANGED
package/translation.esm.js
CHANGED
package/translation10.cjs.js
CHANGED
package/translation10.esm.js
CHANGED
package/translation11.cjs.js
CHANGED
package/translation11.esm.js
CHANGED
package/translation12.cjs.js
CHANGED
package/translation12.esm.js
CHANGED
package/translation13.cjs.js
CHANGED
package/translation13.esm.js
CHANGED
package/translation14.cjs.js
CHANGED
package/translation14.esm.js
CHANGED
package/translation15.cjs.js
CHANGED
package/translation15.esm.js
CHANGED
package/translation16.cjs.js
CHANGED
package/translation16.esm.js
CHANGED
package/translation17.cjs.js
CHANGED
package/translation17.esm.js
CHANGED
package/translation2.cjs.js
CHANGED
package/translation2.esm.js
CHANGED
package/translation3.cjs.js
CHANGED
package/translation3.esm.js
CHANGED
package/translation4.cjs.js
CHANGED
package/translation4.esm.js
CHANGED
package/translation5.cjs.js
CHANGED
package/translation5.esm.js
CHANGED
package/translation6.cjs.js
CHANGED
package/translation6.esm.js
CHANGED
package/translation7.cjs.js
CHANGED
package/translation7.esm.js
CHANGED
package/translation8.cjs.js
CHANGED
package/translation8.esm.js
CHANGED
package/translation9.cjs.js
CHANGED