@rango-dev/ui 0.36.1-next.7 → 0.36.1-next.8

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAsC,MAAM,OAAO,CAAC;AAqB3D,wBAAgB,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC,cAAc,CAAC,qBAqH7D"}
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAsC,MAAM,OAAO,CAAC;AAkB3D,wBAAgB,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC,cAAc,CAAC,qBA4G7D"}
@@ -23,10 +23,6 @@ export interface ModalPropTypes {
23
23
  footer?: React.ReactNode;
24
24
  hasWatermark?: boolean;
25
25
  hasCloseIcon?: boolean;
26
- transitionDuration?: {
27
- enter?: number;
28
- exit?: number;
29
- };
30
26
  }
31
27
  export {};
32
28
  //# sourceMappingURL=Modal.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.types.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Modal/Modal.types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AA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
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -48,7 +48,7 @@ export const ModalContainer = styled('div', {
48
48
  display: 'flex',
49
49
  flexDirection: 'column',
50
50
  zIndex: 9999999,
51
- transform: 'translateY(100%)',
51
+ transform: 'translateY(100vh)',
52
52
  transition: 'transform .45s ease-in-out',
53
53
 
54
54
  variants: {
@@ -61,7 +61,7 @@ export const ModalContainer = styled('div', {
61
61
  right: {
62
62
  borderTopRightRadius: '0',
63
63
  borderBottomRightRadius: '0',
64
- transform: 'translateX(100%)',
64
+ transform: 'translateX(100vw)',
65
65
  },
66
66
  },
67
67
  active: {
@@ -19,9 +19,6 @@ import {
19
19
  ModalHeader,
20
20
  } from './Modal.styles';
21
21
 
22
- const CLOSED_DELAY = 600;
23
- const OPEN_DELAY = 100;
24
-
25
22
  export function Modal(props: PropsWithChildren<ModalPropTypes>) {
26
23
  const {
27
24
  title,
@@ -38,12 +35,12 @@ export function Modal(props: PropsWithChildren<ModalPropTypes>) {
38
35
  footer,
39
36
  hasWatermark = true,
40
37
  hasCloseIcon = true,
41
- transitionDuration,
42
38
  } = props;
43
39
 
44
40
  const [active, setActive] = useState(false);
45
41
  const [isMount, setIsMount] = useState(false);
46
- const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
42
+
43
+ const ref = useRef<HTMLDivElement | null>(null);
47
44
 
48
45
  const handleBackDropClick = (event: React.MouseEvent<HTMLDivElement>) => {
49
46
  event.stopPropagation();
@@ -52,40 +49,29 @@ export function Modal(props: PropsWithChildren<ModalPropTypes>) {
52
49
  onClose();
53
50
  }
54
51
  };
52
+
53
+ const handleTransitionEnd = (e: React.TransitionEvent<HTMLDivElement>) => {
54
+ if (!open && ref.current === e.target) {
55
+ setIsMount(false);
56
+ container.style.removeProperty('overflow');
57
+ }
58
+ };
59
+
60
+ useEffect(() => {
61
+ if (isMount) {
62
+ setActive(true);
63
+ }
64
+ }, [isMount]);
65
+
55
66
  useEffect(() => {
56
67
  if (container) {
57
- if (timeoutRef.current) {
58
- clearTimeout(timeoutRef.current);
59
- }
60
68
  if (open) {
61
69
  setIsMount(true);
62
70
  container.style.overflow = 'hidden';
63
- timeoutRef.current = setTimeout(
64
- () => {
65
- setActive(true);
66
- },
67
- typeof transitionDuration?.enter !== 'undefined'
68
- ? transitionDuration?.enter
69
- : OPEN_DELAY
70
- );
71
71
  } else {
72
72
  setActive(false);
73
- timeoutRef.current = setTimeout(
74
- () => {
75
- setIsMount(false);
76
- container.style.removeProperty('overflow');
77
- },
78
- typeof transitionDuration?.exit !== 'undefined'
79
- ? transitionDuration?.exit
80
- : CLOSED_DELAY
81
- );
82
73
  }
83
74
  }
84
- return () => {
85
- if (timeoutRef.current) {
86
- clearTimeout(timeoutRef.current);
87
- }
88
- };
89
75
  }, [open, container]);
90
76
 
91
77
  return (
@@ -101,7 +87,9 @@ export function Modal(props: PropsWithChildren<ModalPropTypes>) {
101
87
  <ModalContainer
102
88
  active={active}
103
89
  css={styles?.container}
104
- anchor={anchor}>
90
+ anchor={anchor}
91
+ onTransitionEnd={handleTransitionEnd}
92
+ ref={ref}>
105
93
  {header ?? (
106
94
  <ModalHeader noTitle={!title && dismissible && !prefix}>
107
95
  {prefix}
@@ -24,8 +24,4 @@ export interface ModalPropTypes {
24
24
  footer?: React.ReactNode;
25
25
  hasWatermark?: boolean;
26
26
  hasCloseIcon?: boolean;
27
- transitionDuration?: {
28
- enter?: number;
29
- exit?: number;
30
- };
31
27
  }