@seed-design/react-drawer 1.0.4 → 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.
@@ -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, shouldAnimate, shouldOverlayAnimate } = useDrawerContext();
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, shouldAnimate, autoFocus, closeDrawer, closeOnInteractOutside, closeOnEscape, dismissible } = useDrawerContext();
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 ? {
@@ -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, shouldAnimate, shouldOverlayAnimate } = useDrawerContext();
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, shouldAnimate, autoFocus, closeDrawer, closeOnInteractOutside, closeOnEscape, dismissible } = useDrawerContext();
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 ? {
package/lib/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- var Drawer12s = require('./Drawer-12s-Yr_NcCoF.cjs');
1
+ var Drawer12s = require('./Drawer-12s-CTzxFYGf.cjs');
2
2
 
3
3
  var Drawer_namespace = {
4
4
  __proto__: null,
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, skips initial enter animation. Still reacts to `open` state changes
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-BOMSoUDc.js';
2
- export { u as useDrawer, i as useDrawerContext } from './Drawer-12s-BOMSoUDc.js';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/react-drawer",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
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={
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, skips initial enter animation. Still reacts to `open` state changes
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,