@seed-design/react-drawer 1.0.3 → 1.0.5
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/lib/{Drawer-12s-Cg9AJtdN.js → Drawer-12s-9vODHlci.js} +7 -13
- package/lib/{Drawer-12s-D1dD-wen.cjs → Drawer-12s-CTzxFYGf.cjs} +7 -13
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -3
- package/lib/index.js +2 -2
- package/package.json +1 -1
- package/src/Drawer.tsx +5 -5
- package/src/useDrawer.ts +2 -8
|
@@ -492,7 +492,6 @@ function useDrawer(props) {
|
|
|
492
492
|
const isAllowedToDrag = useRef(false);
|
|
493
493
|
const pointerStart = useRef(0);
|
|
494
494
|
const keyboardIsOpen = useRef(false);
|
|
495
|
-
const shouldAnimate = useRef(!defaultOpen);
|
|
496
495
|
const previousDiffFromInitial = useRef(0);
|
|
497
496
|
const drawerRef = useRef(null);
|
|
498
497
|
const drawerHeightRef = useRef(drawerRef.current?.getBoundingClientRect().height || 0);
|
|
@@ -746,11 +745,6 @@ function useDrawer(props) {
|
|
|
746
745
|
}, [
|
|
747
746
|
isOpen
|
|
748
747
|
]);
|
|
749
|
-
useEffect(()=>{
|
|
750
|
-
window.requestAnimationFrame(()=>{
|
|
751
|
-
shouldAnimate.current = true;
|
|
752
|
-
});
|
|
753
|
-
}, []);
|
|
754
748
|
useEffect(()=>{
|
|
755
749
|
function onVisualViewportChange() {
|
|
756
750
|
if (!drawerRef.current || !repositionInputs) return;
|
|
@@ -845,7 +839,6 @@ function useDrawer(props) {
|
|
|
845
839
|
onRelease,
|
|
846
840
|
onDrag,
|
|
847
841
|
dismissible,
|
|
848
|
-
shouldAnimate,
|
|
849
842
|
handleOnly,
|
|
850
843
|
isOpen,
|
|
851
844
|
isDragging,
|
|
@@ -937,7 +930,7 @@ const DrawerPositioner = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
937
930
|
});
|
|
938
931
|
DrawerPositioner.displayName = "DrawerPositioner";
|
|
939
932
|
const DrawerBackdrop = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
940
|
-
const { overlayRef, onRelease, modal, snapPoints, isOpen, shouldFade,
|
|
933
|
+
const { overlayRef, onRelease, modal, snapPoints, isOpen, shouldFade, shouldOverlayAnimate } = useDrawerContext();
|
|
941
934
|
const composedRef = useComposedRefs(ref, overlayRef);
|
|
942
935
|
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
943
936
|
const onMouseUp = useCallbackRef((event)=>onRelease(event));
|
|
@@ -950,7 +943,6 @@ const DrawerBackdrop = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
950
943
|
onMouseUp: onMouseUp,
|
|
951
944
|
"data-snap-points": isOpen && hasSnapPoints ? "true" : "false",
|
|
952
945
|
"data-snap-points-overlay": isOpen && shouldFade ? "true" : "false",
|
|
953
|
-
"data-animate": shouldAnimate?.current ? "true" : "false",
|
|
954
946
|
"data-should-overlay-animate": shouldOverlayAnimate ? "true" : "false",
|
|
955
947
|
"data-open": dataAttr(isOpen),
|
|
956
948
|
...props
|
|
@@ -959,7 +951,7 @@ const DrawerBackdrop = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
959
951
|
DrawerBackdrop.displayName = "DrawerBackdrop";
|
|
960
952
|
const DrawerContent = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
961
953
|
const { onPointerDownOutside, style, onOpenAutoFocus, ...restProps } = props;
|
|
962
|
-
const { drawerRef, onPress, onRelease, onDrag, keyboardIsOpen, snapPointsOffset, activeSnapPointIndex, modal, isOpen, direction, snapPoints, container, handleOnly,
|
|
954
|
+
const { drawerRef, onPress, onRelease, onDrag, keyboardIsOpen, snapPointsOffset, activeSnapPointIndex, modal, isOpen, direction, snapPoints, container, handleOnly, autoFocus, closeDrawer, closeOnInteractOutside, closeOnEscape, dismissible } = useDrawerContext();
|
|
963
955
|
// Needed to use transition instead of animations
|
|
964
956
|
const [delayedSnapPoints, setDelayedSnapPoints] = useState(false);
|
|
965
957
|
const composedRef = useComposedRefs(ref, drawerRef);
|
|
@@ -1009,7 +1001,6 @@ const DrawerContent = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
1009
1001
|
"data-drawer": "",
|
|
1010
1002
|
"data-snap-points": isOpen && hasSnapPoints ? "true" : "false",
|
|
1011
1003
|
"data-custom-container": container ? "true" : "false",
|
|
1012
|
-
"data-animate": shouldAnimate?.current ? "true" : "false",
|
|
1013
1004
|
...restProps,
|
|
1014
1005
|
ref: composedRef,
|
|
1015
1006
|
style: snapPointsOffset && snapPointsOffset.length > 0 ? {
|
|
@@ -1114,7 +1105,7 @@ const LONG_HANDLE_PRESS_TIMEOUT = 250;
|
|
|
1114
1105
|
const DOUBLE_TAP_TIMEOUT = 120;
|
|
1115
1106
|
const DrawerHandle = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
1116
1107
|
const { preventCycle = false, children, ...rest } = props;
|
|
1117
|
-
const { closeDrawer, isDragging, snapPoints, activeSnapPoint, setActiveSnapPoint, dismissible, handleOnly, isOpen, onPress, onDrag } = useDrawerContext();
|
|
1108
|
+
const { closeDrawer, isDragging, snapPoints, activeSnapPoint, setActiveSnapPoint, dismissible, handleOnly, isOpen, onPress, onDrag, onRelease } = useDrawerContext();
|
|
1118
1109
|
const closeTimeoutIdRef = useRef(null);
|
|
1119
1110
|
const shouldCancelInteractionRef = useRef(false);
|
|
1120
1111
|
function handleStartCycle() {
|
|
@@ -1174,7 +1165,10 @@ const DrawerHandle = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
1174
1165
|
onPointerMove: (e)=>{
|
|
1175
1166
|
if (handleOnly) onDrag(e);
|
|
1176
1167
|
},
|
|
1177
|
-
|
|
1168
|
+
onPointerUp: (e)=>{
|
|
1169
|
+
if (handleOnly) onRelease(e);
|
|
1170
|
+
handleCancelInteraction();
|
|
1171
|
+
},
|
|
1178
1172
|
"data-drawer-visible": isOpen ? "true" : "false",
|
|
1179
1173
|
"data-handle": "",
|
|
1180
1174
|
"aria-hidden": "true",
|
|
@@ -515,7 +515,6 @@ function useDrawer(props) {
|
|
|
515
515
|
const isAllowedToDrag = React.useRef(false);
|
|
516
516
|
const pointerStart = React.useRef(0);
|
|
517
517
|
const keyboardIsOpen = React.useRef(false);
|
|
518
|
-
const shouldAnimate = React.useRef(!defaultOpen);
|
|
519
518
|
const previousDiffFromInitial = React.useRef(0);
|
|
520
519
|
const drawerRef = React.useRef(null);
|
|
521
520
|
const drawerHeightRef = React.useRef(drawerRef.current?.getBoundingClientRect().height || 0);
|
|
@@ -769,11 +768,6 @@ function useDrawer(props) {
|
|
|
769
768
|
}, [
|
|
770
769
|
isOpen
|
|
771
770
|
]);
|
|
772
|
-
React.useEffect(()=>{
|
|
773
|
-
window.requestAnimationFrame(()=>{
|
|
774
|
-
shouldAnimate.current = true;
|
|
775
|
-
});
|
|
776
|
-
}, []);
|
|
777
771
|
React.useEffect(()=>{
|
|
778
772
|
function onVisualViewportChange() {
|
|
779
773
|
if (!drawerRef.current || !repositionInputs) return;
|
|
@@ -868,7 +862,6 @@ function useDrawer(props) {
|
|
|
868
862
|
onRelease,
|
|
869
863
|
onDrag,
|
|
870
864
|
dismissible,
|
|
871
|
-
shouldAnimate,
|
|
872
865
|
handleOnly,
|
|
873
866
|
isOpen,
|
|
874
867
|
isDragging,
|
|
@@ -960,7 +953,7 @@ const DrawerPositioner = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
|
960
953
|
});
|
|
961
954
|
DrawerPositioner.displayName = "DrawerPositioner";
|
|
962
955
|
const DrawerBackdrop = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
963
|
-
const { overlayRef, onRelease, modal, snapPoints, isOpen, shouldFade,
|
|
956
|
+
const { overlayRef, onRelease, modal, snapPoints, isOpen, shouldFade, shouldOverlayAnimate } = useDrawerContext();
|
|
964
957
|
const composedRef = reactComposeRefs.useComposedRefs(ref, overlayRef);
|
|
965
958
|
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
966
959
|
const onMouseUp = reactUseCallbackRef.useCallbackRef((event)=>onRelease(event));
|
|
@@ -973,7 +966,6 @@ const DrawerBackdrop = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
|
973
966
|
onMouseUp: onMouseUp,
|
|
974
967
|
"data-snap-points": isOpen && hasSnapPoints ? "true" : "false",
|
|
975
968
|
"data-snap-points-overlay": isOpen && shouldFade ? "true" : "false",
|
|
976
|
-
"data-animate": shouldAnimate?.current ? "true" : "false",
|
|
977
969
|
"data-should-overlay-animate": shouldOverlayAnimate ? "true" : "false",
|
|
978
970
|
"data-open": domUtils.dataAttr(isOpen),
|
|
979
971
|
...props
|
|
@@ -982,7 +974,7 @@ const DrawerBackdrop = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
|
982
974
|
DrawerBackdrop.displayName = "DrawerBackdrop";
|
|
983
975
|
const DrawerContent = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
984
976
|
const { onPointerDownOutside, style, onOpenAutoFocus, ...restProps } = props;
|
|
985
|
-
const { drawerRef, onPress, onRelease, onDrag, keyboardIsOpen, snapPointsOffset, activeSnapPointIndex, modal, isOpen, direction, snapPoints, container, handleOnly,
|
|
977
|
+
const { drawerRef, onPress, onRelease, onDrag, keyboardIsOpen, snapPointsOffset, activeSnapPointIndex, modal, isOpen, direction, snapPoints, container, handleOnly, autoFocus, closeDrawer, closeOnInteractOutside, closeOnEscape, dismissible } = useDrawerContext();
|
|
986
978
|
// Needed to use transition instead of animations
|
|
987
979
|
const [delayedSnapPoints, setDelayedSnapPoints] = React.useState(false);
|
|
988
980
|
const composedRef = reactComposeRefs.useComposedRefs(ref, drawerRef);
|
|
@@ -1032,7 +1024,6 @@ const DrawerContent = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
|
1032
1024
|
"data-drawer": "",
|
|
1033
1025
|
"data-snap-points": isOpen && hasSnapPoints ? "true" : "false",
|
|
1034
1026
|
"data-custom-container": container ? "true" : "false",
|
|
1035
|
-
"data-animate": shouldAnimate?.current ? "true" : "false",
|
|
1036
1027
|
...restProps,
|
|
1037
1028
|
ref: composedRef,
|
|
1038
1029
|
style: snapPointsOffset && snapPointsOffset.length > 0 ? {
|
|
@@ -1137,7 +1128,7 @@ const LONG_HANDLE_PRESS_TIMEOUT = 250;
|
|
|
1137
1128
|
const DOUBLE_TAP_TIMEOUT = 120;
|
|
1138
1129
|
const DrawerHandle = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
1139
1130
|
const { preventCycle = false, children, ...rest } = props;
|
|
1140
|
-
const { closeDrawer, isDragging, snapPoints, activeSnapPoint, setActiveSnapPoint, dismissible, handleOnly, isOpen, onPress, onDrag } = useDrawerContext();
|
|
1131
|
+
const { closeDrawer, isDragging, snapPoints, activeSnapPoint, setActiveSnapPoint, dismissible, handleOnly, isOpen, onPress, onDrag, onRelease } = useDrawerContext();
|
|
1141
1132
|
const closeTimeoutIdRef = React.useRef(null);
|
|
1142
1133
|
const shouldCancelInteractionRef = React.useRef(false);
|
|
1143
1134
|
function handleStartCycle() {
|
|
@@ -1197,7 +1188,10 @@ const DrawerHandle = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
|
1197
1188
|
onPointerMove: (e)=>{
|
|
1198
1189
|
if (handleOnly) onDrag(e);
|
|
1199
1190
|
},
|
|
1200
|
-
|
|
1191
|
+
onPointerUp: (e)=>{
|
|
1192
|
+
if (handleOnly) onRelease(e);
|
|
1193
|
+
handleCancelInteraction();
|
|
1194
|
+
},
|
|
1201
1195
|
"data-drawer-visible": isOpen ? "true" : "false",
|
|
1202
1196
|
"data-handle": "",
|
|
1203
1197
|
"aria-hidden": "true",
|
package/lib/index.cjs
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ interface UseDrawerProps {
|
|
|
55
55
|
*/
|
|
56
56
|
direction?: "top" | "bottom" | "left" | "right";
|
|
57
57
|
/**
|
|
58
|
-
* Opened by default
|
|
58
|
+
* Opened by default. Still reacts to `open` state changes
|
|
59
59
|
* @default false
|
|
60
60
|
*/
|
|
61
61
|
defaultOpen?: boolean;
|
|
@@ -115,7 +115,6 @@ declare function useDrawer(props: UseDrawerProps): {
|
|
|
115
115
|
onRelease: (event: React.PointerEvent<HTMLDivElement> | null) => void;
|
|
116
116
|
onDrag: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
117
117
|
dismissible: boolean;
|
|
118
|
-
shouldAnimate: react.RefObject<boolean>;
|
|
119
118
|
handleOnly: boolean;
|
|
120
119
|
isOpen: boolean;
|
|
121
120
|
isDragging: boolean;
|
|
@@ -178,7 +177,6 @@ declare function useDrawerContext(): {
|
|
|
178
177
|
onRelease: (event: React.PointerEvent<HTMLDivElement> | null) => void;
|
|
179
178
|
onDrag: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
180
179
|
dismissible: boolean;
|
|
181
|
-
shouldAnimate: react.RefObject<boolean>;
|
|
182
180
|
handleOnly: boolean;
|
|
183
181
|
isOpen: boolean;
|
|
184
182
|
isDragging: boolean;
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DrawerBackdrop, a as DrawerCloseButton, b as DrawerContent, c as DrawerDescription, d as DrawerHandle, e as DrawerPositioner, f as DrawerRoot, g as DrawerTitle, h as DrawerTrigger } from './Drawer-12s-
|
|
2
|
-
export { u as useDrawer, i as useDrawerContext } from './Drawer-12s-
|
|
1
|
+
import { D as DrawerBackdrop, a as DrawerCloseButton, b as DrawerContent, c as DrawerDescription, d as DrawerHandle, e as DrawerPositioner, f as DrawerRoot, g as DrawerTitle, h as DrawerTrigger } from './Drawer-12s-9vODHlci.js';
|
|
2
|
+
export { u as useDrawer, i as useDrawerContext } from './Drawer-12s-9vODHlci.js';
|
|
3
3
|
|
|
4
4
|
var Drawer_namespace = {
|
|
5
5
|
__proto__: null,
|
package/package.json
CHANGED
package/src/Drawer.tsx
CHANGED
|
@@ -71,7 +71,6 @@ export const DrawerBackdrop = forwardRef<HTMLDivElement, DrawerBackdropProps>((p
|
|
|
71
71
|
snapPoints,
|
|
72
72
|
isOpen,
|
|
73
73
|
shouldFade,
|
|
74
|
-
shouldAnimate,
|
|
75
74
|
shouldOverlayAnimate,
|
|
76
75
|
} = useDrawerContext();
|
|
77
76
|
const composedRef = useComposedRefs(ref, overlayRef);
|
|
@@ -89,7 +88,6 @@ export const DrawerBackdrop = forwardRef<HTMLDivElement, DrawerBackdropProps>((p
|
|
|
89
88
|
onMouseUp={onMouseUp}
|
|
90
89
|
data-snap-points={isOpen && hasSnapPoints ? "true" : "false"}
|
|
91
90
|
data-snap-points-overlay={isOpen && shouldFade ? "true" : "false"}
|
|
92
|
-
data-animate={shouldAnimate?.current ? "true" : "false"}
|
|
93
91
|
data-should-overlay-animate={shouldOverlayAnimate ? "true" : "false"}
|
|
94
92
|
data-open={dataAttr(isOpen)}
|
|
95
93
|
{...props}
|
|
@@ -118,7 +116,6 @@ export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>((pro
|
|
|
118
116
|
snapPoints,
|
|
119
117
|
container,
|
|
120
118
|
handleOnly,
|
|
121
|
-
shouldAnimate,
|
|
122
119
|
autoFocus,
|
|
123
120
|
closeDrawer,
|
|
124
121
|
closeOnInteractOutside,
|
|
@@ -183,7 +180,6 @@ export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>((pro
|
|
|
183
180
|
data-drawer=""
|
|
184
181
|
data-snap-points={isOpen && hasSnapPoints ? "true" : "false"}
|
|
185
182
|
data-custom-container={container ? "true" : "false"}
|
|
186
|
-
data-animate={shouldAnimate?.current ? "true" : "false"}
|
|
187
183
|
{...restProps}
|
|
188
184
|
ref={composedRef}
|
|
189
185
|
style={
|
|
@@ -325,6 +321,7 @@ export const DrawerHandle = forwardRef<HTMLDivElement, DrawerHandleProps>((props
|
|
|
325
321
|
isOpen,
|
|
326
322
|
onPress,
|
|
327
323
|
onDrag,
|
|
324
|
+
onRelease,
|
|
328
325
|
} = useDrawerContext();
|
|
329
326
|
|
|
330
327
|
const closeTimeoutIdRef = useRef<number | null>(null);
|
|
@@ -396,7 +393,10 @@ export const DrawerHandle = forwardRef<HTMLDivElement, DrawerHandleProps>((props
|
|
|
396
393
|
onPointerMove={(e) => {
|
|
397
394
|
if (handleOnly) onDrag(e);
|
|
398
395
|
}}
|
|
399
|
-
|
|
396
|
+
onPointerUp={(e) => {
|
|
397
|
+
if (handleOnly) onRelease(e);
|
|
398
|
+
handleCancelInteraction();
|
|
399
|
+
}}
|
|
400
400
|
data-drawer-visible={isOpen ? "true" : "false"}
|
|
401
401
|
data-handle=""
|
|
402
402
|
aria-hidden="true"
|
package/src/useDrawer.ts
CHANGED
|
@@ -65,7 +65,7 @@ export interface UseDrawerProps {
|
|
|
65
65
|
*/
|
|
66
66
|
direction?: "top" | "bottom" | "left" | "right";
|
|
67
67
|
/**
|
|
68
|
-
* Opened by default
|
|
68
|
+
* Opened by default. Still reacts to `open` state changes
|
|
69
69
|
* @default false
|
|
70
70
|
*/
|
|
71
71
|
defaultOpen?: boolean;
|
|
@@ -116,6 +116,7 @@ export interface UseDrawerProps {
|
|
|
116
116
|
* @default true
|
|
117
117
|
*/
|
|
118
118
|
closeOnEscape?: boolean;
|
|
119
|
+
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
export function useDrawer(props: UseDrawerProps) {
|
|
@@ -189,7 +190,6 @@ export function useDrawer(props: UseDrawerProps) {
|
|
|
189
190
|
const isAllowedToDrag = useRef<boolean>(false);
|
|
190
191
|
const pointerStart = useRef(0);
|
|
191
192
|
const keyboardIsOpen = useRef(false);
|
|
192
|
-
const shouldAnimate = useRef(!defaultOpen);
|
|
193
193
|
const previousDiffFromInitial = useRef(0);
|
|
194
194
|
const drawerRef = useRef<HTMLDivElement>(null);
|
|
195
195
|
const drawerHeightRef = useRef(drawerRef.current?.getBoundingClientRect().height || 0);
|
|
@@ -543,11 +543,6 @@ export function useDrawer(props: UseDrawerProps) {
|
|
|
543
543
|
};
|
|
544
544
|
}, [isOpen]);
|
|
545
545
|
|
|
546
|
-
useEffect(() => {
|
|
547
|
-
window.requestAnimationFrame(() => {
|
|
548
|
-
shouldAnimate.current = true;
|
|
549
|
-
});
|
|
550
|
-
}, []);
|
|
551
546
|
|
|
552
547
|
useEffect(() => {
|
|
553
548
|
function onVisualViewportChange() {
|
|
@@ -647,7 +642,6 @@ export function useDrawer(props: UseDrawerProps) {
|
|
|
647
642
|
onRelease,
|
|
648
643
|
onDrag,
|
|
649
644
|
dismissible,
|
|
650
|
-
shouldAnimate,
|
|
651
645
|
handleOnly,
|
|
652
646
|
isOpen,
|
|
653
647
|
isDragging,
|