@trackunit/react-drawer 1.7.94 → 1.7.101
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 +35 -53
- package/index.esm.js +37 -55
- package/package.json +6 -6
- package/src/components/Drawer/Drawer.d.ts +5 -1
- package/src/components/Drawer/Drawer.stories.d.ts +1 -1
- package/src/components/SwipeableDrawer/SwipeableDrawer.d.ts +2 -2
- package/src/hooks/index.d.ts +0 -1
- package/src/hooks/useScrollBlock.d.ts +0 -6
package/index.cjs.js
CHANGED
|
@@ -193,15 +193,22 @@ const NOOP$1 = () => void 0;
|
|
|
193
193
|
* @param {DrawerProps} props - The props for the Drawer component
|
|
194
194
|
*/
|
|
195
195
|
const Drawer = ({ open = false, // Default to closed
|
|
196
|
-
onClose = NOOP$1, hasOverlay = true, position = DEFAULT_POSITION, children, dataTestId, className, renderInPortal = false, keepMountedWhenClosed = false, containerClassName, ref, ...others }) => {
|
|
196
|
+
onClose = NOOP$1, onOpen = NOOP$1, hasOverlay = true, position = DEFAULT_POSITION, children, dataTestId, className, renderInPortal = false, keepMountedWhenClosed = false, containerClassName, ref, ...others }) => {
|
|
197
197
|
const { isSm } = reactComponents.useViewportBreakpoints();
|
|
198
198
|
const shouldUsePortal = !isSm || renderInPortal;
|
|
199
199
|
const [shouldRender, setShouldRender] = react.useState(open);
|
|
200
200
|
const [mode, setMode] = react.useState(open ? "open" : "closed");
|
|
201
|
+
const onOpenRef = react.useRef(onOpen);
|
|
202
|
+
react.useEffect(() => {
|
|
203
|
+
onOpenRef.current = onOpen;
|
|
204
|
+
}, [onOpen]);
|
|
201
205
|
react.useEffect(() => {
|
|
202
206
|
if (open) {
|
|
203
207
|
setShouldRender(true);
|
|
204
|
-
setTimeout(() =>
|
|
208
|
+
setTimeout(() => {
|
|
209
|
+
setMode("open");
|
|
210
|
+
onOpenRef.current();
|
|
211
|
+
}, TRANSITION_DURATION);
|
|
205
212
|
}
|
|
206
213
|
else {
|
|
207
214
|
setMode("closed");
|
|
@@ -291,47 +298,6 @@ const cvaToggleContainer = cssClassVarianceUtilities.cvaMerge(["z-8", "absolute"
|
|
|
291
298
|
},
|
|
292
299
|
});
|
|
293
300
|
|
|
294
|
-
const blockDocumentScroll = () => {
|
|
295
|
-
const { body } = document;
|
|
296
|
-
const html = document.documentElement;
|
|
297
|
-
const scrollBarWidth = window.innerWidth - (html.clientWidth || 0);
|
|
298
|
-
const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
|
|
299
|
-
html.style.position = "relative";
|
|
300
|
-
html.style.overflow = "hidden";
|
|
301
|
-
body.style.position = "relative";
|
|
302
|
-
body.style.overflow = "hidden";
|
|
303
|
-
body.style.paddingRight = `${bodyPaddingRight + scrollBarWidth}px`;
|
|
304
|
-
};
|
|
305
|
-
const restoreDocumentScroll = () => {
|
|
306
|
-
const { body } = document;
|
|
307
|
-
const html = document.documentElement;
|
|
308
|
-
html.style.position = "";
|
|
309
|
-
html.style.overflow = "";
|
|
310
|
-
body.style.position = "";
|
|
311
|
-
body.style.overflow = "";
|
|
312
|
-
body.style.paddingRight = "";
|
|
313
|
-
};
|
|
314
|
-
/**
|
|
315
|
-
* Hook for blocking scroll to prevent strange behaviors when full-screen swipeable components are open.
|
|
316
|
-
*/
|
|
317
|
-
const useScrollBlock = ({ isDisabled }) => {
|
|
318
|
-
const scrollBlocked = react.useRef(false);
|
|
319
|
-
const blockScroll = react.useCallback(() => {
|
|
320
|
-
blockDocumentScroll();
|
|
321
|
-
scrollBlocked.current = true;
|
|
322
|
-
return () => {
|
|
323
|
-
restoreDocumentScroll();
|
|
324
|
-
scrollBlocked.current = false;
|
|
325
|
-
};
|
|
326
|
-
}, []);
|
|
327
|
-
react.useEffect(() => {
|
|
328
|
-
if (isDisabled) {
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
return blockScroll();
|
|
332
|
-
}, [isDisabled, blockScroll]);
|
|
333
|
-
};
|
|
334
|
-
|
|
335
301
|
/**
|
|
336
302
|
* Retrieves the Y-axis translation value of a given HTML element.
|
|
337
303
|
*
|
|
@@ -432,7 +398,7 @@ const SNAP_POINT_TRANSITION = "transform 500ms cubic-bezier(0.32,0.72,0,1)";
|
|
|
432
398
|
* The component manages its docked state based on the open prop and keepMountedWhenClosed prop.
|
|
433
399
|
* It also applies styles dynamically based on whether the drawer is being dragged.
|
|
434
400
|
*/
|
|
435
|
-
const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, children, keepMountedWhenClosed, className, position = "bottom", snapPoints, activeSnapPoint: activeSnapPointProp = null, container, ref, ...others }) => {
|
|
401
|
+
const SwipeableDrawer = ({ open = false, onClose, onOpen, onOpenGesture, onSnapPointChange, children, keepMountedWhenClosed, className, position = "bottom", snapPoints, activeSnapPoint: activeSnapPointProp = null, container, ref, ...others }) => {
|
|
436
402
|
const drawerRef = react.useRef(null);
|
|
437
403
|
const { geometry: containerGeometry, ref: containerMeasureRef } = reactComponents.useMeasure();
|
|
438
404
|
react.useImperativeHandle(ref, () => drawerRef.current);
|
|
@@ -453,7 +419,7 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
453
419
|
// If the velocity is greater than the threshold and the dragged distance is less than 40% of the container height, snap to the next snap point
|
|
454
420
|
if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedBy) < (containerGeometry?.height ?? 0) * 0.4) {
|
|
455
421
|
const newSnapPoint = snapPoints[activeSnapPointIndex + direction] ?? null;
|
|
456
|
-
if (newSnapPoint) {
|
|
422
|
+
if (newSnapPoint !== null) {
|
|
457
423
|
setActiveSnapPoint(newSnapPoint);
|
|
458
424
|
onSnapPointChange?.(newSnapPoint);
|
|
459
425
|
}
|
|
@@ -471,7 +437,7 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
471
437
|
});
|
|
472
438
|
const snapPointIndex = snapPointOffsets.findIndex(offset => offset === closestSnapPoint);
|
|
473
439
|
const nextSnapPoint = snapPoints[snapPointIndex] ?? null;
|
|
474
|
-
if (
|
|
440
|
+
if (nextSnapPoint === null) {
|
|
475
441
|
return;
|
|
476
442
|
}
|
|
477
443
|
setActiveSnapPoint(nextSnapPoint);
|
|
@@ -482,12 +448,12 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
482
448
|
closingThreshold: CLOSING_THRESHOLD,
|
|
483
449
|
onCloseGesture: () => {
|
|
484
450
|
if (!snapPoints) {
|
|
485
|
-
onClose
|
|
451
|
+
onClose?.();
|
|
486
452
|
}
|
|
487
453
|
},
|
|
488
454
|
onOpenGesture: () => {
|
|
489
455
|
if (!snapPoints) {
|
|
490
|
-
onOpenGesture
|
|
456
|
+
onOpenGesture?.();
|
|
491
457
|
}
|
|
492
458
|
},
|
|
493
459
|
onDragEnd: onHandleDragEnd,
|
|
@@ -501,7 +467,8 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
501
467
|
return false;
|
|
502
468
|
},
|
|
503
469
|
});
|
|
504
|
-
|
|
470
|
+
const { blockScroll, restoreScroll } = reactComponents.useScrollBlock();
|
|
471
|
+
const { blockScroll: blockScrollContent, restoreScroll: restoreScrollContent } = reactComponents.useScrollBlock(document.getElementById("host-layout-content"));
|
|
505
472
|
react.useEffect(() => {
|
|
506
473
|
if (!snapPoints || !drawerRef.current) {
|
|
507
474
|
return;
|
|
@@ -532,7 +499,7 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
532
499
|
}
|
|
533
500
|
const snapPointIndex = snapPoints.findIndex(offset => offset === activeSnapPointProp);
|
|
534
501
|
const nextSnapPoint = snapPoints[snapPointIndex > -1 ? snapPointIndex : 0] ?? null;
|
|
535
|
-
if (
|
|
502
|
+
if (nextSnapPoint === null) {
|
|
536
503
|
return;
|
|
537
504
|
}
|
|
538
505
|
setActiveSnapPoint(nextSnapPoint);
|
|
@@ -553,7 +520,7 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
553
520
|
}
|
|
554
521
|
return {};
|
|
555
522
|
}, [isDragging, dragDistance, snapPointOffsets, activeSnapPointIndex, snapPoints]);
|
|
556
|
-
react.
|
|
523
|
+
const applyDrawerStyles = react.useCallback(() => {
|
|
557
524
|
if (!drawerRef.current) {
|
|
558
525
|
return;
|
|
559
526
|
}
|
|
@@ -565,8 +532,23 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
565
532
|
drawerRef.current.style.transform = "";
|
|
566
533
|
drawerRef.current.style.transition = "";
|
|
567
534
|
}
|
|
568
|
-
}, [
|
|
569
|
-
|
|
535
|
+
}, [open, drawerStyle]);
|
|
536
|
+
react.useEffect(() => {
|
|
537
|
+
applyDrawerStyles();
|
|
538
|
+
}, [applyDrawerStyles]);
|
|
539
|
+
const onOpenHandler = react.useCallback(() => {
|
|
540
|
+
onOpen?.();
|
|
541
|
+
blockScroll();
|
|
542
|
+
blockScrollContent();
|
|
543
|
+
applyDrawerStyles();
|
|
544
|
+
}, [onOpen, blockScroll, blockScrollContent, applyDrawerStyles]);
|
|
545
|
+
const onCloseHandler = react.useCallback(() => {
|
|
546
|
+
onClose?.();
|
|
547
|
+
restoreScroll();
|
|
548
|
+
restoreScrollContent();
|
|
549
|
+
applyDrawerStyles();
|
|
550
|
+
}, [onClose, restoreScroll, restoreScrollContent, applyDrawerStyles]);
|
|
551
|
+
return (jsxRuntime.jsxs(Drawer, { className: cvaSwipeableDrawer({ className }), keepMountedWhenClosed: keepMountedWhenClosed, onClose: onCloseHandler, onOpen: onOpenHandler, open: open, position: position, ref: drawerRef, ...others, children: [jsxRuntime.jsx(DrawerPuller, { ...handlers }), children] }));
|
|
570
552
|
};
|
|
571
553
|
SwipeableDrawer.displayName = "SwipeableDrawer";
|
|
572
554
|
const cvaSwipeableDrawer = cssClassVarianceUtilities.cvaMerge([]);
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { registerTranslations } from '@trackunit/i18n-library-translation';
|
|
3
|
-
import { useViewportBreakpoints, Portal, Icon, useMeasureElement, useMeasure } from '@trackunit/react-components';
|
|
4
|
-
import { useEffect, useState,
|
|
3
|
+
import { useViewportBreakpoints, Portal, Icon, useMeasureElement, useMeasure, useScrollBlock } from '@trackunit/react-components';
|
|
4
|
+
import { useEffect, useState, useRef, useCallback, useImperativeHandle, useMemo } from 'react';
|
|
5
5
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
6
6
|
import { useSwipeable } from 'react-swipeable';
|
|
7
7
|
|
|
@@ -191,15 +191,22 @@ const NOOP$1 = () => void 0;
|
|
|
191
191
|
* @param {DrawerProps} props - The props for the Drawer component
|
|
192
192
|
*/
|
|
193
193
|
const Drawer = ({ open = false, // Default to closed
|
|
194
|
-
onClose = NOOP$1, hasOverlay = true, position = DEFAULT_POSITION, children, dataTestId, className, renderInPortal = false, keepMountedWhenClosed = false, containerClassName, ref, ...others }) => {
|
|
194
|
+
onClose = NOOP$1, onOpen = NOOP$1, hasOverlay = true, position = DEFAULT_POSITION, children, dataTestId, className, renderInPortal = false, keepMountedWhenClosed = false, containerClassName, ref, ...others }) => {
|
|
195
195
|
const { isSm } = useViewportBreakpoints();
|
|
196
196
|
const shouldUsePortal = !isSm || renderInPortal;
|
|
197
197
|
const [shouldRender, setShouldRender] = useState(open);
|
|
198
198
|
const [mode, setMode] = useState(open ? "open" : "closed");
|
|
199
|
+
const onOpenRef = useRef(onOpen);
|
|
200
|
+
useEffect(() => {
|
|
201
|
+
onOpenRef.current = onOpen;
|
|
202
|
+
}, [onOpen]);
|
|
199
203
|
useEffect(() => {
|
|
200
204
|
if (open) {
|
|
201
205
|
setShouldRender(true);
|
|
202
|
-
setTimeout(() =>
|
|
206
|
+
setTimeout(() => {
|
|
207
|
+
setMode("open");
|
|
208
|
+
onOpenRef.current();
|
|
209
|
+
}, TRANSITION_DURATION);
|
|
203
210
|
}
|
|
204
211
|
else {
|
|
205
212
|
setMode("closed");
|
|
@@ -289,47 +296,6 @@ const cvaToggleContainer = cvaMerge(["z-8", "absolute"], {
|
|
|
289
296
|
},
|
|
290
297
|
});
|
|
291
298
|
|
|
292
|
-
const blockDocumentScroll = () => {
|
|
293
|
-
const { body } = document;
|
|
294
|
-
const html = document.documentElement;
|
|
295
|
-
const scrollBarWidth = window.innerWidth - (html.clientWidth || 0);
|
|
296
|
-
const bodyPaddingRight = parseInt(window.getComputedStyle(body).getPropertyValue("padding-right")) || 0;
|
|
297
|
-
html.style.position = "relative";
|
|
298
|
-
html.style.overflow = "hidden";
|
|
299
|
-
body.style.position = "relative";
|
|
300
|
-
body.style.overflow = "hidden";
|
|
301
|
-
body.style.paddingRight = `${bodyPaddingRight + scrollBarWidth}px`;
|
|
302
|
-
};
|
|
303
|
-
const restoreDocumentScroll = () => {
|
|
304
|
-
const { body } = document;
|
|
305
|
-
const html = document.documentElement;
|
|
306
|
-
html.style.position = "";
|
|
307
|
-
html.style.overflow = "";
|
|
308
|
-
body.style.position = "";
|
|
309
|
-
body.style.overflow = "";
|
|
310
|
-
body.style.paddingRight = "";
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* Hook for blocking scroll to prevent strange behaviors when full-screen swipeable components are open.
|
|
314
|
-
*/
|
|
315
|
-
const useScrollBlock = ({ isDisabled }) => {
|
|
316
|
-
const scrollBlocked = useRef(false);
|
|
317
|
-
const blockScroll = useCallback(() => {
|
|
318
|
-
blockDocumentScroll();
|
|
319
|
-
scrollBlocked.current = true;
|
|
320
|
-
return () => {
|
|
321
|
-
restoreDocumentScroll();
|
|
322
|
-
scrollBlocked.current = false;
|
|
323
|
-
};
|
|
324
|
-
}, []);
|
|
325
|
-
useEffect(() => {
|
|
326
|
-
if (isDisabled) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
return blockScroll();
|
|
330
|
-
}, [isDisabled, blockScroll]);
|
|
331
|
-
};
|
|
332
|
-
|
|
333
299
|
/**
|
|
334
300
|
* Retrieves the Y-axis translation value of a given HTML element.
|
|
335
301
|
*
|
|
@@ -430,7 +396,7 @@ const SNAP_POINT_TRANSITION = "transform 500ms cubic-bezier(0.32,0.72,0,1)";
|
|
|
430
396
|
* The component manages its docked state based on the open prop and keepMountedWhenClosed prop.
|
|
431
397
|
* It also applies styles dynamically based on whether the drawer is being dragged.
|
|
432
398
|
*/
|
|
433
|
-
const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, children, keepMountedWhenClosed, className, position = "bottom", snapPoints, activeSnapPoint: activeSnapPointProp = null, container, ref, ...others }) => {
|
|
399
|
+
const SwipeableDrawer = ({ open = false, onClose, onOpen, onOpenGesture, onSnapPointChange, children, keepMountedWhenClosed, className, position = "bottom", snapPoints, activeSnapPoint: activeSnapPointProp = null, container, ref, ...others }) => {
|
|
434
400
|
const drawerRef = useRef(null);
|
|
435
401
|
const { geometry: containerGeometry, ref: containerMeasureRef } = useMeasure();
|
|
436
402
|
useImperativeHandle(ref, () => drawerRef.current);
|
|
@@ -451,7 +417,7 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
451
417
|
// If the velocity is greater than the threshold and the dragged distance is less than 40% of the container height, snap to the next snap point
|
|
452
418
|
if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedBy) < (containerGeometry?.height ?? 0) * 0.4) {
|
|
453
419
|
const newSnapPoint = snapPoints[activeSnapPointIndex + direction] ?? null;
|
|
454
|
-
if (newSnapPoint) {
|
|
420
|
+
if (newSnapPoint !== null) {
|
|
455
421
|
setActiveSnapPoint(newSnapPoint);
|
|
456
422
|
onSnapPointChange?.(newSnapPoint);
|
|
457
423
|
}
|
|
@@ -469,7 +435,7 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
469
435
|
});
|
|
470
436
|
const snapPointIndex = snapPointOffsets.findIndex(offset => offset === closestSnapPoint);
|
|
471
437
|
const nextSnapPoint = snapPoints[snapPointIndex] ?? null;
|
|
472
|
-
if (
|
|
438
|
+
if (nextSnapPoint === null) {
|
|
473
439
|
return;
|
|
474
440
|
}
|
|
475
441
|
setActiveSnapPoint(nextSnapPoint);
|
|
@@ -480,12 +446,12 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
480
446
|
closingThreshold: CLOSING_THRESHOLD,
|
|
481
447
|
onCloseGesture: () => {
|
|
482
448
|
if (!snapPoints) {
|
|
483
|
-
onClose
|
|
449
|
+
onClose?.();
|
|
484
450
|
}
|
|
485
451
|
},
|
|
486
452
|
onOpenGesture: () => {
|
|
487
453
|
if (!snapPoints) {
|
|
488
|
-
onOpenGesture
|
|
454
|
+
onOpenGesture?.();
|
|
489
455
|
}
|
|
490
456
|
},
|
|
491
457
|
onDragEnd: onHandleDragEnd,
|
|
@@ -499,7 +465,8 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
499
465
|
return false;
|
|
500
466
|
},
|
|
501
467
|
});
|
|
502
|
-
|
|
468
|
+
const { blockScroll, restoreScroll } = useScrollBlock();
|
|
469
|
+
const { blockScroll: blockScrollContent, restoreScroll: restoreScrollContent } = useScrollBlock(document.getElementById("host-layout-content"));
|
|
503
470
|
useEffect(() => {
|
|
504
471
|
if (!snapPoints || !drawerRef.current) {
|
|
505
472
|
return;
|
|
@@ -530,7 +497,7 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
530
497
|
}
|
|
531
498
|
const snapPointIndex = snapPoints.findIndex(offset => offset === activeSnapPointProp);
|
|
532
499
|
const nextSnapPoint = snapPoints[snapPointIndex > -1 ? snapPointIndex : 0] ?? null;
|
|
533
|
-
if (
|
|
500
|
+
if (nextSnapPoint === null) {
|
|
534
501
|
return;
|
|
535
502
|
}
|
|
536
503
|
setActiveSnapPoint(nextSnapPoint);
|
|
@@ -551,7 +518,7 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
551
518
|
}
|
|
552
519
|
return {};
|
|
553
520
|
}, [isDragging, dragDistance, snapPointOffsets, activeSnapPointIndex, snapPoints]);
|
|
554
|
-
|
|
521
|
+
const applyDrawerStyles = useCallback(() => {
|
|
555
522
|
if (!drawerRef.current) {
|
|
556
523
|
return;
|
|
557
524
|
}
|
|
@@ -563,8 +530,23 @@ const SwipeableDrawer = ({ open, onClose, onOpenGesture, onSnapPointChange, chil
|
|
|
563
530
|
drawerRef.current.style.transform = "";
|
|
564
531
|
drawerRef.current.style.transition = "";
|
|
565
532
|
}
|
|
566
|
-
}, [
|
|
567
|
-
|
|
533
|
+
}, [open, drawerStyle]);
|
|
534
|
+
useEffect(() => {
|
|
535
|
+
applyDrawerStyles();
|
|
536
|
+
}, [applyDrawerStyles]);
|
|
537
|
+
const onOpenHandler = useCallback(() => {
|
|
538
|
+
onOpen?.();
|
|
539
|
+
blockScroll();
|
|
540
|
+
blockScrollContent();
|
|
541
|
+
applyDrawerStyles();
|
|
542
|
+
}, [onOpen, blockScroll, blockScrollContent, applyDrawerStyles]);
|
|
543
|
+
const onCloseHandler = useCallback(() => {
|
|
544
|
+
onClose?.();
|
|
545
|
+
restoreScroll();
|
|
546
|
+
restoreScrollContent();
|
|
547
|
+
applyDrawerStyles();
|
|
548
|
+
}, [onClose, restoreScroll, restoreScrollContent, applyDrawerStyles]);
|
|
549
|
+
return (jsxs(Drawer, { className: cvaSwipeableDrawer({ className }), keepMountedWhenClosed: keepMountedWhenClosed, onClose: onCloseHandler, onOpen: onOpenHandler, open: open, position: position, ref: drawerRef, ...others, children: [jsx(DrawerPuller, { ...handlers }), children] }));
|
|
568
550
|
};
|
|
569
551
|
SwipeableDrawer.displayName = "SwipeableDrawer";
|
|
570
552
|
const cvaSwipeableDrawer = cvaMerge([]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-drawer",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.101",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react": "19.0.0",
|
|
11
11
|
"react-swipeable": "^7.0.1",
|
|
12
|
-
"@trackunit/react-components": "1.10.
|
|
13
|
-
"@trackunit/css-class-variance-utilities": "1.7.
|
|
14
|
-
"@trackunit/ui-icons": "1.7.
|
|
15
|
-
"@trackunit/i18n-library-translation": "1.7.
|
|
16
|
-
"@trackunit/react-test-setup": "1.4.
|
|
12
|
+
"@trackunit/react-components": "1.10.40",
|
|
13
|
+
"@trackunit/css-class-variance-utilities": "1.7.70",
|
|
14
|
+
"@trackunit/ui-icons": "1.7.71",
|
|
15
|
+
"@trackunit/i18n-library-translation": "1.7.84",
|
|
16
|
+
"@trackunit/react-test-setup": "1.4.70"
|
|
17
17
|
},
|
|
18
18
|
"module": "./index.esm.js",
|
|
19
19
|
"main": "./index.cjs.js",
|
|
@@ -15,6 +15,10 @@ export interface DrawerProps extends CommonProps {
|
|
|
15
15
|
* The handler for closing the drawer. If not provided, the drawer will dock when closed.=
|
|
16
16
|
*/
|
|
17
17
|
onClose?: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* The handler for opening the drawer. Called when the drawer transitions to open state.
|
|
20
|
+
*/
|
|
21
|
+
onOpen?: () => void;
|
|
18
22
|
/**
|
|
19
23
|
* Whether the drawer needs an overlay or not. Without the overlay, user will have to handle mechanism for closing the drawer.
|
|
20
24
|
* Default is true.
|
|
@@ -59,6 +63,6 @@ export interface DrawerProps extends CommonProps {
|
|
|
59
63
|
* @param {DrawerProps} props - The props for the Drawer component
|
|
60
64
|
*/
|
|
61
65
|
export declare const Drawer: {
|
|
62
|
-
({ open, onClose, hasOverlay, position, children, dataTestId, className, renderInPortal, keepMountedWhenClosed, containerClassName, ref, ...others }: DrawerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
66
|
+
({ open, onClose, onOpen, hasOverlay, position, children, dataTestId, className, renderInPortal, keepMountedWhenClosed, containerClassName, ref, ...others }: DrawerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
63
67
|
displayName: string;
|
|
64
68
|
};
|
|
@@ -6,7 +6,7 @@ type Story = StoryObj<typeof Drawer | typeof SwipeableDrawer>;
|
|
|
6
6
|
declare const meta: {
|
|
7
7
|
title: string;
|
|
8
8
|
component: {
|
|
9
|
-
({ open, onClose, hasOverlay, position, children, dataTestId, className, renderInPortal, keepMountedWhenClosed, containerClassName, ref, ...others }: DrawerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
({ open, onClose, onOpen, hasOverlay, position, children, dataTestId, className, renderInPortal, keepMountedWhenClosed, containerClassName, ref, ...others }: DrawerProps): import("react/jsx-runtime").JSX.Element | null;
|
|
10
10
|
displayName: string;
|
|
11
11
|
};
|
|
12
12
|
tags: string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ref } from "react";
|
|
1
|
+
import { ReactElement, Ref } from "react";
|
|
2
2
|
import { type DrawerProps } from "../Drawer/Drawer";
|
|
3
3
|
export interface SwipeableDrawerProps extends DrawerProps {
|
|
4
4
|
onOpenGesture?: () => void;
|
|
@@ -19,7 +19,7 @@ export interface SwipeableDrawerProps extends DrawerProps {
|
|
|
19
19
|
* It also applies styles dynamically based on whether the drawer is being dragged.
|
|
20
20
|
*/
|
|
21
21
|
export declare const SwipeableDrawer: {
|
|
22
|
-
({ open, onClose, onOpenGesture, onSnapPointChange, children, keepMountedWhenClosed, className, position, snapPoints, activeSnapPoint: activeSnapPointProp, container, ref, ...others }: SwipeableDrawerProps):
|
|
22
|
+
({ open, onClose, onOpen, onOpenGesture, onSnapPointChange, children, keepMountedWhenClosed, className, position, snapPoints, activeSnapPoint: activeSnapPointProp, container, ref, ...others }: SwipeableDrawerProps): ReactElement;
|
|
23
23
|
displayName: string;
|
|
24
24
|
};
|
|
25
25
|
export declare const cvaSwipeableDrawer: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
|
package/src/hooks/index.d.ts
CHANGED