@trackunit/react-drawer 2.6.20 → 2.6.22-alpha-3e7014314a8.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/index.cjs.js +3 -11
- package/index.esm.js +3 -11
- package/package.json +4 -4
- package/src/components/Drawer/Drawer.d.ts +6 -42
- package/src/components/Drawer/Drawer.variants.d.ts +1 -9
- package/src/components/Drawer/useDrawer.d.ts +0 -18
- package/translation.cjs.js +1 -4
- package/translation.esm.js +1 -4
- package/translation10.cjs.js +1 -4
- package/translation10.esm.js +1 -4
- package/translation11.cjs.js +1 -4
- package/translation11.esm.js +1 -4
- package/translation12.cjs.js +1 -4
- package/translation12.esm.js +1 -4
- package/translation13.cjs.js +1 -4
- package/translation13.esm.js +1 -4
- package/translation14.cjs.js +1 -4
- package/translation14.esm.js +1 -4
- package/translation15.cjs.js +1 -4
- package/translation15.esm.js +1 -4
- package/translation16.cjs.js +1 -4
- package/translation16.esm.js +1 -4
- package/translation17.cjs.js +1 -4
- package/translation17.esm.js +1 -4
- package/translation2.cjs.js +1 -4
- package/translation2.esm.js +1 -4
- package/translation3.cjs.js +1 -4
- package/translation3.esm.js +1 -4
- package/translation4.cjs.js +1 -4
- package/translation4.esm.js +1 -4
- package/translation5.cjs.js +1 -4
- package/translation5.esm.js +1 -4
- package/translation6.cjs.js +1 -4
- package/translation6.esm.js +1 -4
- package/translation7.cjs.js +1 -4
- package/translation7.esm.js +1 -4
- package/translation8.cjs.js +1 -4
- package/translation8.esm.js +1 -4
- package/translation9.cjs.js +1 -4
- package/translation9.esm.js +1 -4
- package/migrations/entry.js.map +0 -1
package/index.cjs.js
CHANGED
|
@@ -102,18 +102,10 @@ 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.
|
|
113
105
|
*/
|
|
114
106
|
const cvaDrawerViewport = cssClassVarianceUtilities.cvaMerge([
|
|
115
107
|
"inset-0",
|
|
116
|
-
"z-
|
|
108
|
+
"z-overlay",
|
|
117
109
|
"overflow-hidden",
|
|
118
110
|
"overscroll-none",
|
|
119
111
|
// Let non-modal drawers keep the page interactive; panel/overlay opt back in.
|
|
@@ -304,7 +296,7 @@ const PANEL_FOCUSABLE_SELECTOR = [
|
|
|
304
296
|
* ```
|
|
305
297
|
* @param {DrawerProps} props - The props for the Drawer component
|
|
306
298
|
*/
|
|
307
|
-
const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, children, "data-testid": dataTestId, className, renderInPortal = false, containerClassName, ariaLabel, ariaLabelledBy, }) => {
|
|
299
|
+
const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, open: _open, close: _close, toggle: _toggle, requestClose: _requestClose, children, "data-testid": dataTestId, className, renderInPortal = false, containerClassName, ariaLabel, ariaLabelledBy, ...others }) => {
|
|
308
300
|
const { isSm } = reactComponents.useViewportBreakpoints();
|
|
309
301
|
const shouldUsePortal = !isSm || renderInPortal;
|
|
310
302
|
const panelRef = react.useRef(null);
|
|
@@ -418,7 +410,7 @@ const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, children, "d
|
|
|
418
410
|
mode: drawerState.mode,
|
|
419
411
|
position: position,
|
|
420
412
|
className,
|
|
421
|
-
}), "data-testid": dataTestId, onTransitionEnd: handleAnimationEnd, ref: mergedPanelRef, role: isModal ? "dialog" : "complementary", ...floatingProps, style: {
|
|
413
|
+
}), "data-testid": dataTestId, onTransitionEnd: handleAnimationEnd, ref: mergedPanelRef, role: isModal ? "dialog" : "complementary", ...floatingProps, ...others, style: {
|
|
422
414
|
...getDrawerMotionStyle({ mode: drawerState.mode, position }),
|
|
423
415
|
}, children: jsxRuntime.jsx("div", { className: cvaDrawerContent({ position }), children: children }) }));
|
|
424
416
|
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,18 +100,10 @@ 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.
|
|
111
103
|
*/
|
|
112
104
|
const cvaDrawerViewport = cvaMerge([
|
|
113
105
|
"inset-0",
|
|
114
|
-
"z-
|
|
106
|
+
"z-overlay",
|
|
115
107
|
"overflow-hidden",
|
|
116
108
|
"overscroll-none",
|
|
117
109
|
// Let non-modal drawers keep the page interactive; panel/overlay opt back in.
|
|
@@ -302,7 +294,7 @@ const PANEL_FOCUSABLE_SELECTOR = [
|
|
|
302
294
|
* ```
|
|
303
295
|
* @param {DrawerProps} props - The props for the Drawer component
|
|
304
296
|
*/
|
|
305
|
-
const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, children, "data-testid": dataTestId, className, renderInPortal = false, containerClassName, ariaLabel, ariaLabelledBy, }) => {
|
|
297
|
+
const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, open: _open, close: _close, toggle: _toggle, requestClose: _requestClose, children, "data-testid": dataTestId, className, renderInPortal = false, containerClassName, ariaLabel, ariaLabelledBy, ...others }) => {
|
|
306
298
|
const { isSm } = useViewportBreakpoints();
|
|
307
299
|
const shouldUsePortal = !isSm || renderInPortal;
|
|
308
300
|
const panelRef = useRef(null);
|
|
@@ -416,7 +408,7 @@ const Drawer = ({ isOpen, variant, trapFocus, position, floatingUi, children, "d
|
|
|
416
408
|
mode: drawerState.mode,
|
|
417
409
|
position: position,
|
|
418
410
|
className,
|
|
419
|
-
}), "data-testid": dataTestId, onTransitionEnd: handleAnimationEnd, ref: mergedPanelRef, role: isModal ? "dialog" : "complementary", ...floatingProps, style: {
|
|
411
|
+
}), "data-testid": dataTestId, onTransitionEnd: handleAnimationEnd, ref: mergedPanelRef, role: isModal ? "dialog" : "complementary", ...floatingProps, ...others, style: {
|
|
420
412
|
...getDrawerMotionStyle({ mode: drawerState.mode, position }),
|
|
421
413
|
}, children: jsx("div", { className: cvaDrawerContent({ position }), children: children }) }));
|
|
422
414
|
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.22-alpha-3e7014314a8.0",
|
|
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.16-alpha-3e7014314a8.0",
|
|
11
|
+
"@trackunit/css-class-variance-utilities": "1.14.20-alpha-3e7014314a8.0",
|
|
12
|
+
"@trackunit/i18n-library-translation": "2.4.22-alpha-3e7014314a8.0",
|
|
13
13
|
"@floating-ui/react": "^0.26.25",
|
|
14
14
|
"tailwind-merge": "^2.0.0"
|
|
15
15
|
},
|
|
@@ -1,48 +1,12 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
2
|
import { ReactElement, ReactNode } from "react";
|
|
3
|
-
import type {
|
|
4
|
-
import type { DrawerFloatingUiProps, DrawerVariant } from "./useDrawer";
|
|
3
|
+
import type { UseDrawerReturnValue } from "./useDrawer";
|
|
5
4
|
/**
|
|
6
|
-
* Presentational props for `Drawer`. State
|
|
7
|
-
*
|
|
8
|
-
* (`
|
|
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`.
|
|
5
|
+
* Presentational props for `Drawer`. State, dismiss wiring, variant, focus-trap
|
|
6
|
+
* opt-in, and position all flow in via {@link UseDrawerReturnValue} — call
|
|
7
|
+
* `useDrawer()` and spread its return onto `<Drawer>`.
|
|
18
8
|
*/
|
|
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;
|
|
9
|
+
export interface DrawerProps extends CommonProps, UseDrawerReturnValue {
|
|
46
10
|
/**
|
|
47
11
|
* Content rendered inside the drawer panel. Compose layout parts explicitly — typically
|
|
48
12
|
* `<DrawerHeader />` (or a custom header such as `CardHeader`) followed by the body.
|
|
@@ -135,6 +99,6 @@ export interface DrawerProps extends CommonProps {
|
|
|
135
99
|
* @param {DrawerProps} props - The props for the Drawer component
|
|
136
100
|
*/
|
|
137
101
|
export declare const Drawer: {
|
|
138
|
-
({ isOpen, variant, trapFocus, position, floatingUi, children, "data-testid": dataTestId, className, renderInPortal, containerClassName, ariaLabel, ariaLabelledBy, }: DrawerProps): ReactElement | null;
|
|
102
|
+
({ isOpen, variant, trapFocus, position, floatingUi, open: _open, close: _close, toggle: _toggle, requestClose: _requestClose, children, "data-testid": dataTestId, className, renderInPortal, containerClassName, ariaLabel, ariaLabelledBy, ...others }: DrawerProps): ReactElement | null;
|
|
139
103
|
displayName: string;
|
|
140
104
|
};
|
|
@@ -4,21 +4,13 @@
|
|
|
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.
|
|
15
7
|
*/
|
|
16
8
|
export declare const cvaDrawerViewport: (props?: ({
|
|
17
9
|
portaled?: boolean | null | undefined;
|
|
18
10
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
19
11
|
export declare const cvaDrawer: (props?: ({
|
|
20
12
|
position?: "left" | "right" | null | undefined;
|
|
21
|
-
mode?: "
|
|
13
|
+
mode?: "open" | "closed" | null | undefined;
|
|
22
14
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
23
15
|
export declare const cvaDrawerContent: (props?: ({
|
|
24
16
|
position?: "left" | "right" | null | undefined;
|
|
@@ -58,27 +58,9 @@ 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
|
-
*/
|
|
65
61
|
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
|
-
*/
|
|
71
62
|
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
|
-
*/
|
|
77
63
|
readonly close: () => void;
|
|
78
|
-
/**
|
|
79
|
-
* Toggle open state. Convenience wrapper — calls `open()` when closed and
|
|
80
|
-
* `close()` when open.
|
|
81
|
-
*/
|
|
82
64
|
readonly toggle: () => void;
|
|
83
65
|
/**
|
|
84
66
|
* 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
package/translation9.esm.js
CHANGED
package/migrations/entry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/drawer/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["export {};\n"]}
|