@vygruppen/spor-react 12.8.10 → 12.9.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/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-postinstall.log +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs +22 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +23 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/dialog/Drawer.tsx +32 -22
package/package.json
CHANGED
package/src/dialog/Drawer.tsx
CHANGED
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
Grid,
|
8
8
|
GridItem,
|
9
9
|
Portal,
|
10
|
+
useDialogContext,
|
10
11
|
} from "@chakra-ui/react";
|
11
12
|
import {
|
12
13
|
ArrowLeftFill24Icon,
|
@@ -21,6 +22,7 @@ import {
|
|
21
22
|
DrawerFullScreenHeaderProps,
|
22
23
|
DrawerProps,
|
23
24
|
} from "./types";
|
25
|
+
import { useSwipeable } from "react-swipeable";
|
24
26
|
|
25
27
|
/**
|
26
28
|
* A drawer is a panel that slides in from the side of the screen. It is used to display additional content without taking up too much space.
|
@@ -56,15 +58,31 @@ export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
|
|
56
58
|
(props, ref) => {
|
57
59
|
const { children, portalled = true, portalRef, ...rest } = props;
|
58
60
|
const { size, placement } = useRootDrawerProps();
|
61
|
+
const { setOpen } = useDialogContext();
|
62
|
+
const handlers = useSwipeable({
|
63
|
+
onSwiped: (e) => {
|
64
|
+
const shouldClose =
|
65
|
+
(placement === "bottom" && e.dir === "Down") ||
|
66
|
+
(placement === "top" && e.dir === "Up") ||
|
67
|
+
(placement === "end" && e.dir === "Right") ||
|
68
|
+
(placement === "start" && e.dir === "Left");
|
69
|
+
if (shouldClose) {
|
70
|
+
setOpen(false);
|
71
|
+
}
|
72
|
+
},
|
73
|
+
swipeDuration: 250,
|
74
|
+
});
|
59
75
|
const sizeNotFull = size !== "full";
|
60
76
|
return (
|
61
77
|
<Portal disabled={!portalled} container={portalRef}>
|
62
78
|
<ChakraDrawer.Positioner>
|
63
|
-
<
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
79
|
+
<Box {...handlers} width="100%">
|
80
|
+
<ChakraDrawer.Content ref={ref} {...rest}>
|
81
|
+
{sizeNotFull && placement === "bottom" && <CloseDrawerLine />}
|
82
|
+
{children}
|
83
|
+
{sizeNotFull && placement === "top" && <CloseDrawerLine />}
|
84
|
+
</ChakraDrawer.Content>
|
85
|
+
</Box>
|
68
86
|
</ChakraDrawer.Positioner>
|
69
87
|
</Portal>
|
70
88
|
);
|
@@ -73,26 +91,18 @@ export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
|
|
73
91
|
DrawerContent.displayName = "DrawerContent";
|
74
92
|
|
75
93
|
export const CloseDrawerLine = forwardRef<HTMLButtonElement>((props, ref) => {
|
76
|
-
const { t } = useTranslation();
|
77
94
|
return (
|
78
|
-
<
|
95
|
+
<Box
|
96
|
+
width={7}
|
97
|
+
minHeight={1}
|
98
|
+
top={0}
|
99
|
+
marginY={2}
|
100
|
+
marginX="auto"
|
101
|
+
backgroundColor="silver"
|
102
|
+
borderRadius="xs"
|
79
103
|
{...props}
|
80
104
|
ref={ref}
|
81
|
-
|
82
|
-
insetEnd="unset"
|
83
|
-
aria-label={t(texts.close)}
|
84
|
-
cursor="pointer"
|
85
|
-
top={0}
|
86
|
-
paddingY={2}
|
87
|
-
>
|
88
|
-
<Box
|
89
|
-
width={7}
|
90
|
-
height={1}
|
91
|
-
backgroundColor="silver"
|
92
|
-
borderRadius="xs"
|
93
|
-
marginX="auto"
|
94
|
-
/>
|
95
|
-
</ChakraDrawer.CloseTrigger>
|
105
|
+
/>
|
96
106
|
);
|
97
107
|
});
|
98
108
|
CloseDrawerLine.displayName = "CloseDrawerLine";
|