@trackunit/react-modal 2.1.43-alpha-7bce9c1cf2a.0 → 2.1.43
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/index.cjs.js +18 -0
- package/index.esm.js +19 -1
- package/package.json +6 -6
- package/src/modal/utils/useSheetToCardCleanup.d.ts +8 -0
package/index.cjs.js
CHANGED
|
@@ -217,6 +217,23 @@ const useModalFooterBorder = (rootRef, { footerClass = "border-t", enabled = tru
|
|
|
217
217
|
});
|
|
218
218
|
};
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Calls onCloseComplete when the modal transitions from sheet→card mode while
|
|
222
|
+
* already closed. This handles the race where the Sheet unmounts before its
|
|
223
|
+
* transitionend fires (viewport widens mid-close), which would otherwise leave
|
|
224
|
+
* pendingCloseModalRef armed and trigger the safety-timeout Sentry report.
|
|
225
|
+
*/
|
|
226
|
+
function useSheetToCardCleanup(mode, isOpen, onCloseComplete) {
|
|
227
|
+
const prevModeRef = react.useRef(mode);
|
|
228
|
+
react.useEffect(() => {
|
|
229
|
+
const prevMode = prevModeRef.current;
|
|
230
|
+
prevModeRef.current = mode;
|
|
231
|
+
if (prevMode === "sheet" && mode === "card" && !isOpen) {
|
|
232
|
+
onCloseComplete();
|
|
233
|
+
}
|
|
234
|
+
}, [mode, isOpen, onCloseComplete]);
|
|
235
|
+
}
|
|
236
|
+
|
|
220
237
|
/** Scale factor per modal depth level (5% smaller per level back) */
|
|
221
238
|
const SCALE_FACTOR_PER_LEVEL = 0.05;
|
|
222
239
|
/** Maximum number of stacked modals visible behind the frontmost one. */
|
|
@@ -317,6 +334,7 @@ const Modal = ({ children, container, dismiss, isOpen, mode, requestClose, role
|
|
|
317
334
|
}
|
|
318
335
|
},
|
|
319
336
|
});
|
|
337
|
+
useSheetToCardCleanup(mode, isOpen, onCloseComplete);
|
|
320
338
|
const stackScale = 1 - Math.min(depthFromFront, MAX_VISIBLE_STACK_BEHIND) * SCALE_FACTOR_PER_LEVEL;
|
|
321
339
|
const sheetContainerStyle = react.useMemo(() => {
|
|
322
340
|
const style = {
|
package/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useNamespaceTranslation, registerTranslations } from '@trackunit/i18n-library-translation';
|
|
3
3
|
import { useMergeRefs, FloatingFocusManager, FloatingOverlay, useFloating, shift, autoUpdate, useDismiss, useInteractions } from '@floating-ui/react';
|
|
4
4
|
import { useOverflowBorder, useSheetSnap, useWatch, Card, Portal, Sheet, Button, Heading, Text, IconButton, Icon, useContainerBreakpoints, useViewportBreakpoints, useTimeout, SHEET_TRANSITION_DURATION_MS } from '@trackunit/react-components';
|
|
5
|
-
import { useRef, useCallback, useState, useReducer, useMemo, forwardRef, useId, useSyncExternalStore, useLayoutEffect, useContext
|
|
5
|
+
import { useRef, useEffect, useCallback, useState, useReducer, useMemo, forwardRef, useId, useSyncExternalStore, useLayoutEffect, useContext } from 'react';
|
|
6
6
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
7
7
|
import { ModalDialogContext, ErrorHandlingContext } from '@trackunit/react-core-contexts-api';
|
|
8
8
|
|
|
@@ -215,6 +215,23 @@ const useModalFooterBorder = (rootRef, { footerClass = "border-t", enabled = tru
|
|
|
215
215
|
});
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Calls onCloseComplete when the modal transitions from sheet→card mode while
|
|
220
|
+
* already closed. This handles the race where the Sheet unmounts before its
|
|
221
|
+
* transitionend fires (viewport widens mid-close), which would otherwise leave
|
|
222
|
+
* pendingCloseModalRef armed and trigger the safety-timeout Sentry report.
|
|
223
|
+
*/
|
|
224
|
+
function useSheetToCardCleanup(mode, isOpen, onCloseComplete) {
|
|
225
|
+
const prevModeRef = useRef(mode);
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
const prevMode = prevModeRef.current;
|
|
228
|
+
prevModeRef.current = mode;
|
|
229
|
+
if (prevMode === "sheet" && mode === "card" && !isOpen) {
|
|
230
|
+
onCloseComplete();
|
|
231
|
+
}
|
|
232
|
+
}, [mode, isOpen, onCloseComplete]);
|
|
233
|
+
}
|
|
234
|
+
|
|
218
235
|
/** Scale factor per modal depth level (5% smaller per level back) */
|
|
219
236
|
const SCALE_FACTOR_PER_LEVEL = 0.05;
|
|
220
237
|
/** Maximum number of stacked modals visible behind the frontmost one. */
|
|
@@ -315,6 +332,7 @@ const Modal = ({ children, container, dismiss, isOpen, mode, requestClose, role
|
|
|
315
332
|
}
|
|
316
333
|
},
|
|
317
334
|
});
|
|
335
|
+
useSheetToCardCleanup(mode, isOpen, onCloseComplete);
|
|
318
336
|
const stackScale = 1 - Math.min(depthFromFront, MAX_VISIBLE_STACK_BEHIND) * SCALE_FACTOR_PER_LEVEL;
|
|
319
337
|
const sheetContainerStyle = useMemo(() => {
|
|
320
338
|
const style = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-modal",
|
|
3
|
-
"version": "2.1.43
|
|
3
|
+
"version": "2.1.43",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@floating-ui/react": "^0.26.25",
|
|
11
|
-
"@trackunit/react-components": "2.1.39
|
|
12
|
-
"@trackunit/css-class-variance-utilities": "1.13.43
|
|
13
|
-
"@trackunit/shared-utils": "1.15.43
|
|
11
|
+
"@trackunit/react-components": "2.1.39",
|
|
12
|
+
"@trackunit/css-class-variance-utilities": "1.13.43",
|
|
13
|
+
"@trackunit/shared-utils": "1.15.43",
|
|
14
14
|
"@floating-ui/react-dom": "2.1.2",
|
|
15
|
-
"@trackunit/react-core-contexts-api": "1.17.47
|
|
16
|
-
"@trackunit/i18n-library-translation": "2.0.40
|
|
15
|
+
"@trackunit/react-core-contexts-api": "1.17.47",
|
|
16
|
+
"@trackunit/i18n-library-translation": "2.0.40"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"@tanstack/react-router": "^1.114.29",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ModalMode } from "../useModal";
|
|
2
|
+
/**
|
|
3
|
+
* Calls onCloseComplete when the modal transitions from sheet→card mode while
|
|
4
|
+
* already closed. This handles the race where the Sheet unmounts before its
|
|
5
|
+
* transitionend fires (viewport widens mid-close), which would otherwise leave
|
|
6
|
+
* pendingCloseModalRef armed and trigger the safety-timeout Sentry report.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useSheetToCardCleanup(mode: ModalMode, isOpen: boolean, onCloseComplete: () => void): void;
|