akanjs 2.3.10-rc.0 → 2.3.10-rc.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akanjs",
3
- "version": "2.3.10-rc.0",
3
+ "version": "2.3.10-rc.1",
4
4
  "sourceType": "module",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -5,7 +5,7 @@ import { animated } from "akanjs/ui";
5
5
  import { type ReactNode, useCallback, useContext, useEffect, useId, useRef, useState } from "react";
6
6
  import { createPortal } from "react-dom";
7
7
  import { BiX } from "react-icons/bi";
8
- import { config, useReducedMotion, useSpring } from "react-spring";
8
+ import { config, useSpring } from "react-spring";
9
9
 
10
10
  import { DialogContext } from "./context";
11
11
 
@@ -30,10 +30,7 @@ export const Modal = ({ className, bodyClassName, confirmClose, children, onCanc
30
30
  const { l } = usePage();
31
31
  const ref = useRef<HTMLDivElement>(null);
32
32
  const closeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
33
- const closeFallbackRef = useRef<ReturnType<typeof setTimeout> | null>(null);
34
33
  const closingRef = useRef(false);
35
-
36
- useReducedMotion();
37
34
  const focusedElementRef = useRef<HTMLElement | null>(null);
38
35
  const titleId = useId();
39
36
  const contentId = useId();
@@ -45,8 +42,6 @@ export const Modal = ({ className, bodyClassName, confirmClose, children, onCanc
45
42
  const openModal = useCallback(
46
43
  async ({ canceled }: { canceled?: boolean } = {}) => {
47
44
  closingRef.current = false;
48
- if (closeFallbackRef.current) clearTimeout(closeFallbackRef.current);
49
- closeFallbackRef.current = null;
50
45
  setIsMounted(true);
51
46
  if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
52
47
  closeTimerRef.current = setTimeout(() => {
@@ -57,19 +52,6 @@ export const Modal = ({ className, bodyClassName, confirmClose, children, onCanc
57
52
  [api],
58
53
  );
59
54
 
60
- const finalizeClose = useCallback(
61
- ({ notifyCancel }: { notifyCancel: boolean }) => {
62
- if (!closingRef.current) return;
63
- if (closeFallbackRef.current) clearTimeout(closeFallbackRef.current);
64
- closeFallbackRef.current = null;
65
- setIsMounted(false);
66
- setOpen(false);
67
- if (notifyCancel) onCancel?.();
68
- closingRef.current = false;
69
- },
70
- [onCancel, setOpen],
71
- );
72
-
73
55
  const closeModal = useCallback(
74
56
  async ({
75
57
  velocity = 0,
@@ -90,19 +72,13 @@ export const Modal = ({ className, bodyClassName, confirmClose, children, onCanc
90
72
  closeTimerRef.current = setTimeout(() => {
91
73
  setShowBackground(false);
92
74
  }, 100);
93
-
94
- if (closeFallbackRef.current) clearTimeout(closeFallbackRef.current);
95
- closeFallbackRef.current = setTimeout(() => {
96
- finalizeClose({ notifyCancel });
97
- }, 400);
98
-
99
- try {
100
- await Promise.all(api.start({ translate: 1, immediate: false, config: { ...config.stiff, velocity } }));
101
- } finally {
102
- finalizeClose({ notifyCancel });
103
- }
75
+ await Promise.all(api.start({ translate: 1, immediate: false, config: { ...config.stiff, velocity } }));
76
+ setIsMounted(false);
77
+ setOpen(false);
78
+ if (notifyCancel) onCancel?.();
79
+ closingRef.current = false;
104
80
  },
105
- [api, l, finalizeClose],
81
+ [api, l, onCancel, setOpen],
106
82
  );
107
83
 
108
84
  const requestClose = useCallback(
@@ -201,7 +177,6 @@ export const Modal = ({ className, bodyClassName, confirmClose, children, onCanc
201
177
  useEffect(() => {
202
178
  return () => {
203
179
  if (closeTimerRef.current) clearTimeout(closeTimerRef.current);
204
- if (closeFallbackRef.current) clearTimeout(closeFallbackRef.current);
205
180
  };
206
181
  }, []);
207
182