@rango-dev/ui 0.36.1-next.11 → 0.36.1-next.12

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;AAkB3D,wBAAgB,KAAK,CAAC,KAAK,EAAE,iBAAiB,CAAC,cAAc,CAAC,qBA4G7D"}
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,qBAyG7D"}
@@ -1,5 +1,4 @@
1
1
  export declare const BackDrop: import("@stitches/react/types/styled-component").StyledComponent<"div", {
2
- anchor?: "center" | "bottom" | "right" | undefined;
3
2
  active?: boolean | "true" | undefined;
4
3
  }, {
5
4
  xs: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.styles.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Modal/Modal.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAUjB,CAAC"}
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
- import type { BackDrop } from './Modal.styles';
2
+ import type { ModalContainer } from './Modal.styles';
3
3
  import type { config } from '../../theme';
4
4
  import type * as Stitches from '@stitches/react';
5
- type BaseProps = Stitches.VariantProps<typeof BackDrop>;
5
+ type BaseProps = Stitches.VariantProps<typeof ModalContainer>;
6
6
  type BaseAnchor = Exclude<BaseProps['anchor'], object>;
7
7
  export interface ModalPropTypes {
8
8
  title?: string;
@@ -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;AAEjD,KAAK,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC;AACxD,KAAK,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;AAEvD,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC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,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC;QACnC,SAAS,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC;QACxC,OAAO,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC;QACtC,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC;KACtC,CAAC;IACF,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/ui",
3
- "version": "0.36.1-next.11",
3
+ "version": "0.36.1-next.12",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -5,34 +5,17 @@ export const BackDrop = styled('div', {
5
5
  position: 'absolute',
6
6
  top: '0',
7
7
  left: '0',
8
+ right: '0',
9
+ bottom: '0',
8
10
  width: '100%',
9
11
  height: '100%',
10
12
  backgroundColor: 'transparent',
11
13
  zIndex: 10,
12
14
  borderRadius: '$primary',
13
- display: 'flex',
14
15
  overflow: 'hidden',
15
16
  transition: 'background .35s',
16
17
 
17
18
  variants: {
18
- anchor: {
19
- bottom: {
20
- justifyContent: 'end',
21
- alignItems: 'end',
22
- bottom: '0',
23
- },
24
- center: {
25
- justifyContent: 'center',
26
- alignItems: 'center',
27
- },
28
- right: {
29
- right: '0',
30
- left: 'unset',
31
- borderTopRightRadius: '0',
32
- borderBottomRightRadius: '0',
33
- justifyContent: 'end',
34
- },
35
- },
36
19
  active: {
37
20
  true: {
38
21
  backgroundColor: 'color-mix(in srgb, $neutral500 70%, transparent)',
@@ -48,26 +31,26 @@ export const ModalContainer = styled('div', {
48
31
  display: 'flex',
49
32
  flexDirection: 'column',
50
33
  zIndex: 9999999,
51
- transform: 'translateY(100vh)',
52
- transition: 'transform .45s ease-in-out',
34
+ position: 'absolute',
35
+ transition:
36
+ 'transform .45s ease-in-out, top .45s ease-in-out, left .45s ease-in-out',
53
37
 
54
38
  variants: {
55
39
  anchor: {
56
- bottom: {
57
- width: '100%',
58
- maxHeight: '95%',
59
- },
60
- center: { height: '100%' },
61
40
  right: {
62
- borderTopRightRadius: '0',
63
- borderBottomRightRadius: '0',
64
- transform: 'translateX(100vw)',
41
+ left: '100%',
42
+ },
43
+ center: {
44
+ top: '100%',
45
+ left: '50%',
46
+ transform: 'translateX(-50%)',
47
+ },
48
+ bottom: {
49
+ top: '100%',
65
50
  },
66
51
  },
67
52
  active: {
68
- true: {
69
- transform: 'translateY(0)',
70
- },
53
+ true: {},
71
54
  },
72
55
  },
73
56
  compoundVariants: [
@@ -75,7 +58,23 @@ export const ModalContainer = styled('div', {
75
58
  active: true,
76
59
  anchor: 'right',
77
60
  css: {
78
- transform: 'translateX(0)',
61
+ transform: 'translateX(-100%)',
62
+ },
63
+ },
64
+ {
65
+ active: true,
66
+ anchor: 'center',
67
+ css: {
68
+ top: '50%',
69
+ left: '50%',
70
+ transform: 'translate(-50%, -50%)',
71
+ },
72
+ },
73
+ {
74
+ active: true,
75
+ anchor: 'bottom',
76
+ css: {
77
+ transform: 'translateY(-100%)',
79
78
  },
80
79
  },
81
80
  ],
@@ -19,6 +19,9 @@ import {
19
19
  ModalHeader,
20
20
  } from './Modal.styles';
21
21
 
22
+ const CLOSED_DELAY = 600;
23
+ const OPEN_DELAY = 100;
24
+
22
25
  export function Modal(props: PropsWithChildren<ModalPropTypes>) {
23
26
  const {
24
27
  title,
@@ -39,8 +42,7 @@ export function Modal(props: PropsWithChildren<ModalPropTypes>) {
39
42
 
40
43
  const [active, setActive] = useState(false);
41
44
  const [isMount, setIsMount] = useState(false);
42
-
43
- const ref = useRef<HTMLDivElement | null>(null);
45
+ const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
44
46
 
45
47
  const handleBackDropClick = (event: React.MouseEvent<HTMLDivElement>) => {
46
48
  event.stopPropagation();
@@ -49,29 +51,30 @@ export function Modal(props: PropsWithChildren<ModalPropTypes>) {
49
51
  onClose();
50
52
  }
51
53
  };
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
-
66
54
  useEffect(() => {
67
55
  if (container) {
56
+ if (timeoutRef.current) {
57
+ clearTimeout(timeoutRef.current);
58
+ }
68
59
  if (open) {
69
60
  setIsMount(true);
70
61
  container.style.overflow = 'hidden';
62
+ timeoutRef.current = setTimeout(() => {
63
+ setActive(true);
64
+ }, OPEN_DELAY);
71
65
  } else {
72
66
  setActive(false);
67
+ timeoutRef.current = setTimeout(() => {
68
+ setIsMount(false);
69
+ container.style.removeProperty('overflow');
70
+ }, CLOSED_DELAY);
73
71
  }
74
72
  }
73
+ return () => {
74
+ if (timeoutRef.current) {
75
+ clearTimeout(timeoutRef.current);
76
+ }
77
+ };
75
78
  }, [open, container]);
76
79
 
77
80
  return (
@@ -82,14 +85,11 @@ export function Modal(props: PropsWithChildren<ModalPropTypes>) {
82
85
  <BackDrop
83
86
  active={active}
84
87
  onClick={handleBackDropClick}
85
- anchor={anchor}
86
88
  css={styles?.root}>
87
89
  <ModalContainer
88
90
  active={active}
89
91
  css={styles?.container}
90
- anchor={anchor}
91
- onTransitionEnd={handleTransitionEnd}
92
- ref={ref}>
92
+ anchor={anchor}>
93
93
  {header ?? (
94
94
  <ModalHeader noTitle={!title && dismissible && !prefix}>
95
95
  {prefix}
@@ -1,8 +1,8 @@
1
- import type { BackDrop } from './Modal.styles';
1
+ import type { ModalContainer } from './Modal.styles';
2
2
  import type { config } from '../../theme';
3
3
  import type * as Stitches from '@stitches/react';
4
4
 
5
- type BaseProps = Stitches.VariantProps<typeof BackDrop>;
5
+ type BaseProps = Stitches.VariantProps<typeof ModalContainer>;
6
6
  type BaseAnchor = Exclude<BaseProps['anchor'], object>;
7
7
 
8
8
  export interface ModalPropTypes {