@trackunit/react-drawer 0.1.23 → 0.1.24

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 CHANGED
@@ -163,13 +163,13 @@ const cvaDrawer = cssClassVarianceUtilities.cvaMerge(["z-toast", "pointer-events
163
163
  mode: "closed",
164
164
  },
165
165
  });
166
- const cvaDrawerContent = cssClassVarianceUtilities.cvaMerge(["flex", "h-full", "shadow-lg", "bg-white"], {
166
+ const cvaDrawerContent = cssClassVarianceUtilities.cvaMerge(["flex", "flex-col", "h-full", "shadow-lg", "bg-white"], {
167
167
  variants: {
168
168
  position: {
169
169
  left: "rounded-r-lg",
170
170
  right: "rounded-l-lg",
171
- top: ["flex-col", "rounded-b-lg"],
172
- bottom: ["max-h-[calc(100dvh-10px)]", "flex-col", "rounded-t-lg", "sm:max-h-none"],
171
+ top: "rounded-b-lg",
172
+ bottom: ["max-h-[calc(100dvh-10px)]", "rounded-t-lg", "sm:max-h-none"],
173
173
  },
174
174
  },
175
175
  });
@@ -407,8 +407,9 @@ const CLOSING_THRESHOLD = 0.15;
407
407
  * The component manages its docked state based on the open prop and keepMountedWhenClosed prop.
408
408
  * It also applies styles dynamically based on whether the drawer is being dragged.
409
409
  */
410
- const SwipeableDrawer = ({ open, onClose, onOpenGesture, children, keepMountedWhenClosed, className, position = "bottom", ...others }) => {
410
+ const SwipeableDrawer = react.forwardRef(({ open, onClose, onOpenGesture, children, keepMountedWhenClosed, className, position = "bottom", ...others }, ref) => {
411
411
  const drawerRefs = react.useRef(null);
412
+ react.useImperativeHandle(ref, () => drawerRefs.current);
412
413
  const [isDocked, setIsDocked] = react.useState(keepMountedWhenClosed && !open);
413
414
  const { handlers, isDragging, dragDistance } = useSwipeHandlers({
414
415
  ref: drawerRefs,
@@ -442,7 +443,8 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, children, keepMountedWh
442
443
  }
443
444
  }, [drawerStyle, drawerRefs]);
444
445
  return (jsxRuntime.jsxs(Drawer, { className: cvaSwipeableDrawer({ docked: isDocked, className }), "data-docked": isDocked, keepMountedWhenClosed: keepMountedWhenClosed, onClose: onClose, open: open, position: position, ref: drawerRefs, ...others, children: [jsxRuntime.jsx(DrawerPuller, { ...handlers }), children] }));
445
- };
446
+ });
447
+ SwipeableDrawer.displayName = "SwipeableDrawer";
446
448
  const cvaSwipeableDrawer = cssClassVarianceUtilities.cvaMerge([], {
447
449
  variants: {
448
450
  docked: {
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { registerTranslations } from '@trackunit/i18n-library-translation';
3
- import { useEffect, forwardRef, useState, useCallback, useRef, useMemo } from 'react';
3
+ import { useEffect, forwardRef, useState, useCallback, useRef, useImperativeHandle, useMemo } from 'react';
4
4
  import usePortal from 'react-useportal';
5
5
  import { useViewportSize, Icon, useGeometry } from '@trackunit/react-components';
6
6
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
@@ -161,13 +161,13 @@ const cvaDrawer = cvaMerge(["z-toast", "pointer-events-auto", "absolute", "flex-
161
161
  mode: "closed",
162
162
  },
163
163
  });
164
- const cvaDrawerContent = cvaMerge(["flex", "h-full", "shadow-lg", "bg-white"], {
164
+ const cvaDrawerContent = cvaMerge(["flex", "flex-col", "h-full", "shadow-lg", "bg-white"], {
165
165
  variants: {
166
166
  position: {
167
167
  left: "rounded-r-lg",
168
168
  right: "rounded-l-lg",
169
- top: ["flex-col", "rounded-b-lg"],
170
- bottom: ["max-h-[calc(100dvh-10px)]", "flex-col", "rounded-t-lg", "sm:max-h-none"],
169
+ top: "rounded-b-lg",
170
+ bottom: ["max-h-[calc(100dvh-10px)]", "rounded-t-lg", "sm:max-h-none"],
171
171
  },
172
172
  },
173
173
  });
@@ -405,8 +405,9 @@ const CLOSING_THRESHOLD = 0.15;
405
405
  * The component manages its docked state based on the open prop and keepMountedWhenClosed prop.
406
406
  * It also applies styles dynamically based on whether the drawer is being dragged.
407
407
  */
408
- const SwipeableDrawer = ({ open, onClose, onOpenGesture, children, keepMountedWhenClosed, className, position = "bottom", ...others }) => {
408
+ const SwipeableDrawer = forwardRef(({ open, onClose, onOpenGesture, children, keepMountedWhenClosed, className, position = "bottom", ...others }, ref) => {
409
409
  const drawerRefs = useRef(null);
410
+ useImperativeHandle(ref, () => drawerRefs.current);
410
411
  const [isDocked, setIsDocked] = useState(keepMountedWhenClosed && !open);
411
412
  const { handlers, isDragging, dragDistance } = useSwipeHandlers({
412
413
  ref: drawerRefs,
@@ -440,7 +441,8 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, children, keepMountedWh
440
441
  }
441
442
  }, [drawerStyle, drawerRefs]);
442
443
  return (jsxs(Drawer, { className: cvaSwipeableDrawer({ docked: isDocked, className }), "data-docked": isDocked, keepMountedWhenClosed: keepMountedWhenClosed, onClose: onClose, open: open, position: position, ref: drawerRefs, ...others, children: [jsx(DrawerPuller, { ...handlers }), children] }));
443
- };
444
+ });
445
+ SwipeableDrawer.displayName = "SwipeableDrawer";
444
446
  const cvaSwipeableDrawer = cvaMerge([], {
445
447
  variants: {
446
448
  docked: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-drawer",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -9,7 +9,7 @@ export interface SwipeableDrawerProps extends DrawerProps {
9
9
  * The component manages its docked state based on the open prop and keepMountedWhenClosed prop.
10
10
  * It also applies styles dynamically based on whether the drawer is being dragged.
11
11
  */
12
- export declare const SwipeableDrawer: ({ open, onClose, onOpenGesture, children, keepMountedWhenClosed, className, position, ...others }: SwipeableDrawerProps) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const SwipeableDrawer: import("react").ForwardRefExoticComponent<SwipeableDrawerProps & import("react").RefAttributes<HTMLDivElement>>;
13
13
  export declare const cvaSwipeableDrawer: (props?: ({
14
14
  docked?: boolean | null | undefined;
15
15
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;