@samline/drawer 2.0.4 → 2.0.6
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/README.md +1 -0
- package/dist/{svelte/components-client-DXeaMmfk.js → browser/components-client-CJuQ5vtW.js} +172 -31
- package/dist/browser/{components-client-CZSt5H60.mjs → components-client-tfLTRxPH.mjs} +173 -32
- package/dist/browser/index.cjs +192 -34
- package/dist/browser/index.js +192 -34
- package/dist/browser/index.mjs +192 -34
- package/dist/{browser/components-client-DXeaMmfk.js → components-client-CJuQ5vtW.js} +172 -31
- package/dist/{svelte/components-client-CZSt5H60.mjs → components-client-tfLTRxPH.mjs} +173 -32
- package/dist/index.js +192 -34
- package/dist/index.mjs +192 -34
- package/dist/react/index.js +193 -31
- package/dist/react/index.mjs +194 -32
- package/dist/{vue/components-client-DXeaMmfk.js → svelte/components-client-CJuQ5vtW.js} +172 -31
- package/dist/{components-client-CZSt5H60.mjs → svelte/components-client-tfLTRxPH.mjs} +173 -32
- package/dist/svelte/index.js +192 -34
- package/dist/svelte/index.mjs +192 -34
- package/dist/{components-client-DXeaMmfk.js → vue/components-client-CJuQ5vtW.js} +172 -31
- package/dist/vue/{components-client-DZfql3-W.mjs → components-client-DSM2G8ef.mjs} +173 -32
- package/dist/vue/index.js +192 -34
- package/dist/vue/index.mjs +192 -34
- package/package.json +1 -1
package/dist/vue/index.mjs
CHANGED
|
@@ -1099,7 +1099,7 @@ var require_react_development = __commonJS({
|
|
|
1099
1099
|
var dispatcher = resolveDispatcher();
|
|
1100
1100
|
return dispatcher.useReducer(reducer, initialArg, init);
|
|
1101
1101
|
}
|
|
1102
|
-
function
|
|
1102
|
+
function useRef11(initialValue) {
|
|
1103
1103
|
var dispatcher = resolveDispatcher();
|
|
1104
1104
|
return dispatcher.useRef(initialValue);
|
|
1105
1105
|
}
|
|
@@ -1893,7 +1893,7 @@ var require_react_development = __commonJS({
|
|
|
1893
1893
|
exports.useLayoutEffect = useLayoutEffect5;
|
|
1894
1894
|
exports.useMemo = useMemo6;
|
|
1895
1895
|
exports.useReducer = useReducer3;
|
|
1896
|
-
exports.useRef =
|
|
1896
|
+
exports.useRef = useRef11;
|
|
1897
1897
|
exports.useState = useState10;
|
|
1898
1898
|
exports.useSyncExternalStore = useSyncExternalStore;
|
|
1899
1899
|
exports.useTransition = useTransition;
|
|
@@ -26965,25 +26965,34 @@ var nonTextInputTypes = /* @__PURE__ */ new Set([
|
|
|
26965
26965
|
"submit",
|
|
26966
26966
|
"reset"
|
|
26967
26967
|
]);
|
|
26968
|
-
var
|
|
26969
|
-
var
|
|
26968
|
+
var activePreventScrollLocks = /* @__PURE__ */ new Set();
|
|
26969
|
+
var activePreventScrollRestore = null;
|
|
26970
|
+
function acquirePreventScrollLock(lockId) {
|
|
26971
|
+
activePreventScrollLocks.add(lockId);
|
|
26972
|
+
if (activePreventScrollLocks.size === 1 && isIOS()) {
|
|
26973
|
+
activePreventScrollRestore = preventScrollMobileSafari();
|
|
26974
|
+
}
|
|
26975
|
+
}
|
|
26976
|
+
function releasePreventScrollLock(lockId) {
|
|
26977
|
+
activePreventScrollLocks.delete(lockId);
|
|
26978
|
+
if (activePreventScrollLocks.size === 0) {
|
|
26979
|
+
activePreventScrollRestore?.();
|
|
26980
|
+
activePreventScrollRestore = null;
|
|
26981
|
+
}
|
|
26982
|
+
}
|
|
26970
26983
|
function usePreventScroll(options = {}) {
|
|
26971
26984
|
let { isDisabled } = options;
|
|
26985
|
+
const lockIdRef = (0, import_react3.useRef)();
|
|
26986
|
+
if (!lockIdRef.current) {
|
|
26987
|
+
lockIdRef.current = /* @__PURE__ */ Symbol("drawer-prevent-scroll-lock");
|
|
26988
|
+
}
|
|
26972
26989
|
useIsomorphicLayoutEffect2(() => {
|
|
26973
26990
|
if (isDisabled) {
|
|
26974
26991
|
return;
|
|
26975
26992
|
}
|
|
26976
|
-
|
|
26977
|
-
if (preventScrollCount === 1) {
|
|
26978
|
-
if (isIOS()) {
|
|
26979
|
-
restore = preventScrollMobileSafari();
|
|
26980
|
-
}
|
|
26981
|
-
}
|
|
26993
|
+
acquirePreventScrollLock(lockIdRef.current);
|
|
26982
26994
|
return () => {
|
|
26983
|
-
|
|
26984
|
-
if (preventScrollCount === 0) {
|
|
26985
|
-
restore?.();
|
|
26986
|
-
}
|
|
26995
|
+
releasePreventScrollLock(lockIdRef.current);
|
|
26987
26996
|
};
|
|
26988
26997
|
}, [isDisabled]);
|
|
26989
26998
|
}
|
|
@@ -27557,12 +27566,23 @@ function useScaleBackground() {
|
|
|
27557
27566
|
const { direction, isOpen, shouldScaleBackground, setBackgroundColorOnScale, noBodyStyles } = useDrawerContext();
|
|
27558
27567
|
const timeoutIdRef = import_react6.default.useRef(null);
|
|
27559
27568
|
const initialBackgroundColor = (0, import_react6.useMemo)(() => document.body.style.backgroundColor, []);
|
|
27569
|
+
import_react6.default.useEffect(() => {
|
|
27570
|
+
return () => {
|
|
27571
|
+
if (timeoutIdRef.current !== null) {
|
|
27572
|
+
window.clearTimeout(timeoutIdRef.current);
|
|
27573
|
+
timeoutIdRef.current = null;
|
|
27574
|
+
}
|
|
27575
|
+
};
|
|
27576
|
+
}, []);
|
|
27560
27577
|
function getScale() {
|
|
27561
27578
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
27562
27579
|
}
|
|
27563
27580
|
import_react6.default.useEffect(() => {
|
|
27564
27581
|
if (isOpen && shouldScaleBackground) {
|
|
27565
|
-
if (timeoutIdRef.current)
|
|
27582
|
+
if (timeoutIdRef.current !== null) {
|
|
27583
|
+
clearTimeout(timeoutIdRef.current);
|
|
27584
|
+
timeoutIdRef.current = null;
|
|
27585
|
+
}
|
|
27566
27586
|
const wrapper = document.querySelector("[data-drawer-wrapper]");
|
|
27567
27587
|
if (!wrapper) return;
|
|
27568
27588
|
chain(
|
|
@@ -27591,6 +27611,7 @@ function useScaleBackground() {
|
|
|
27591
27611
|
} else {
|
|
27592
27612
|
document.body.style.removeProperty("background");
|
|
27593
27613
|
}
|
|
27614
|
+
timeoutIdRef.current = null;
|
|
27594
27615
|
}, TRANSITIONS.DURATION * 1e3);
|
|
27595
27616
|
};
|
|
27596
27617
|
}
|
|
@@ -27600,6 +27621,14 @@ function useScaleBackground() {
|
|
|
27600
27621
|
// src/use-position-fixed.ts
|
|
27601
27622
|
var import_react7 = __toESM(require_react());
|
|
27602
27623
|
var previousBodyPosition = null;
|
|
27624
|
+
var activeBodyPositionLocks = /* @__PURE__ */ new Set();
|
|
27625
|
+
var bodyPositionTimeoutId = null;
|
|
27626
|
+
function clearBodyPositionTimeout() {
|
|
27627
|
+
if (bodyPositionTimeoutId !== null) {
|
|
27628
|
+
window.clearTimeout(bodyPositionTimeoutId);
|
|
27629
|
+
bodyPositionTimeoutId = null;
|
|
27630
|
+
}
|
|
27631
|
+
}
|
|
27603
27632
|
function usePositionFixed({
|
|
27604
27633
|
isOpen,
|
|
27605
27634
|
modal,
|
|
@@ -27610,8 +27639,17 @@ function usePositionFixed({
|
|
|
27610
27639
|
}) {
|
|
27611
27640
|
const [activeUrl, setActiveUrl] = import_react7.default.useState(() => typeof window !== "undefined" ? window.location.href : "");
|
|
27612
27641
|
const scrollPos = import_react7.default.useRef(0);
|
|
27642
|
+
const lockIdRef = import_react7.default.useRef();
|
|
27643
|
+
if (!lockIdRef.current) {
|
|
27644
|
+
lockIdRef.current = /* @__PURE__ */ Symbol("drawer-body-position-lock");
|
|
27645
|
+
}
|
|
27613
27646
|
const setPositionFixed = import_react7.default.useCallback(() => {
|
|
27614
27647
|
if (!isSafari()) return;
|
|
27648
|
+
const lockId = lockIdRef.current;
|
|
27649
|
+
if (activeBodyPositionLocks.has(lockId)) {
|
|
27650
|
+
return;
|
|
27651
|
+
}
|
|
27652
|
+
activeBodyPositionLocks.add(lockId);
|
|
27615
27653
|
if (previousBodyPosition === null && isOpen && !noBodyStyles) {
|
|
27616
27654
|
previousBodyPosition = {
|
|
27617
27655
|
position: document.body.style.position,
|
|
@@ -27628,7 +27666,8 @@ function usePositionFixed({
|
|
|
27628
27666
|
right: "0px",
|
|
27629
27667
|
height: "auto"
|
|
27630
27668
|
});
|
|
27631
|
-
|
|
27669
|
+
clearBodyPositionTimeout();
|
|
27670
|
+
bodyPositionTimeoutId = window.setTimeout(
|
|
27632
27671
|
() => window.requestAnimationFrame(() => {
|
|
27633
27672
|
const bottomBarHeight = innerHeight - window.innerHeight;
|
|
27634
27673
|
if (bottomBarHeight && scrollPos.current >= innerHeight) {
|
|
@@ -27638,10 +27677,16 @@ function usePositionFixed({
|
|
|
27638
27677
|
300
|
|
27639
27678
|
);
|
|
27640
27679
|
}
|
|
27641
|
-
}, [isOpen]);
|
|
27680
|
+
}, [isOpen, noBodyStyles]);
|
|
27642
27681
|
const restorePositionSetting = import_react7.default.useCallback(() => {
|
|
27643
27682
|
if (!isSafari()) return;
|
|
27683
|
+
const lockId = lockIdRef.current;
|
|
27684
|
+
activeBodyPositionLocks.delete(lockId);
|
|
27685
|
+
if (activeBodyPositionLocks.size > 0) {
|
|
27686
|
+
return;
|
|
27687
|
+
}
|
|
27644
27688
|
if (previousBodyPosition !== null && !noBodyStyles) {
|
|
27689
|
+
clearBodyPositionTimeout();
|
|
27645
27690
|
const y = -parseInt(document.body.style.top, 10);
|
|
27646
27691
|
const x = -parseInt(document.body.style.left, 10);
|
|
27647
27692
|
Object.assign(document.body.style, previousBodyPosition);
|
|
@@ -27654,7 +27699,7 @@ function usePositionFixed({
|
|
|
27654
27699
|
});
|
|
27655
27700
|
previousBodyPosition = null;
|
|
27656
27701
|
}
|
|
27657
|
-
}, [activeUrl]);
|
|
27702
|
+
}, [activeUrl, noBodyStyles, setActiveUrl]);
|
|
27658
27703
|
import_react7.default.useEffect(() => {
|
|
27659
27704
|
function onScroll() {
|
|
27660
27705
|
scrollPos.current = window.scrollY;
|
|
@@ -27921,6 +27966,7 @@ function getDragPermission({
|
|
|
27921
27966
|
}
|
|
27922
27967
|
|
|
27923
27968
|
// src/react/components.tsx
|
|
27969
|
+
var useSafeLayoutEffect = typeof window === "undefined" ? import_react9.default.useEffect : import_react9.default.useLayoutEffect;
|
|
27924
27970
|
function Root2({
|
|
27925
27971
|
open: openProp,
|
|
27926
27972
|
onOpenChange,
|
|
@@ -27952,6 +27998,12 @@ function Root2({
|
|
|
27952
27998
|
container,
|
|
27953
27999
|
autoFocus = false
|
|
27954
28000
|
}) {
|
|
28001
|
+
const animationEndTimeoutRef = import_react9.default.useRef(null);
|
|
28002
|
+
const nonModalPointerEventsRafRef = import_react9.default.useRef(null);
|
|
28003
|
+
const shouldAnimateRafRef = import_react9.default.useRef(null);
|
|
28004
|
+
const snapPointsResetTimeoutRef = import_react9.default.useRef(null);
|
|
28005
|
+
const justReleasedTimeoutRef = import_react9.default.useRef(null);
|
|
28006
|
+
const touchEndHandlerRef = import_react9.default.useRef(null);
|
|
27955
28007
|
const [isOpen = false, setIsOpen] = useControllableState2({
|
|
27956
28008
|
defaultProp: defaultOpen,
|
|
27957
28009
|
prop: openProp,
|
|
@@ -27960,13 +28012,20 @@ function Root2({
|
|
|
27960
28012
|
if (!o && !nested) {
|
|
27961
28013
|
restorePositionSetting();
|
|
27962
28014
|
}
|
|
27963
|
-
|
|
28015
|
+
if (animationEndTimeoutRef.current !== null) {
|
|
28016
|
+
window.clearTimeout(animationEndTimeoutRef.current);
|
|
28017
|
+
}
|
|
28018
|
+
animationEndTimeoutRef.current = window.setTimeout(() => {
|
|
27964
28019
|
onAnimationEnd?.(o);
|
|
27965
28020
|
}, TRANSITIONS.DURATION * 1e3);
|
|
27966
28021
|
if (o && !modal) {
|
|
27967
28022
|
if (typeof window !== "undefined") {
|
|
27968
|
-
|
|
28023
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28024
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28025
|
+
}
|
|
28026
|
+
nonModalPointerEventsRafRef.current = window.requestAnimationFrame(() => {
|
|
27969
28027
|
document.body.style.pointerEvents = "auto";
|
|
28028
|
+
nonModalPointerEventsRafRef.current = null;
|
|
27970
28029
|
});
|
|
27971
28030
|
}
|
|
27972
28031
|
}
|
|
@@ -28051,18 +28110,22 @@ function Root2({
|
|
|
28051
28110
|
noBodyStyles,
|
|
28052
28111
|
autoFocus
|
|
28053
28112
|
});
|
|
28054
|
-
|
|
28113
|
+
useSafeLayoutEffect(() => {
|
|
28055
28114
|
if (!isOpen || !modal || autoFocus || typeof document === "undefined") {
|
|
28056
28115
|
return;
|
|
28057
28116
|
}
|
|
28058
28117
|
const activeElement = document.activeElement;
|
|
28059
|
-
if (!
|
|
28118
|
+
if (!activeElement || activeElement === document.body) {
|
|
28060
28119
|
return;
|
|
28061
28120
|
}
|
|
28062
|
-
|
|
28121
|
+
const activeElementNode = activeElement;
|
|
28122
|
+
if (drawerRef.current?.contains(activeElementNode) || activeElementNode.closest?.("[data-drawer]")) {
|
|
28063
28123
|
return;
|
|
28064
28124
|
}
|
|
28065
|
-
|
|
28125
|
+
if (typeof activeElementNode.blur !== "function") {
|
|
28126
|
+
return;
|
|
28127
|
+
}
|
|
28128
|
+
activeElementNode.blur();
|
|
28066
28129
|
}, [autoFocus, isOpen, modal]);
|
|
28067
28130
|
function getScale() {
|
|
28068
28131
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
@@ -28075,7 +28138,15 @@ function Root2({
|
|
|
28075
28138
|
setIsDragging(true);
|
|
28076
28139
|
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
28077
28140
|
if (isIOS()) {
|
|
28078
|
-
|
|
28141
|
+
if (touchEndHandlerRef.current) {
|
|
28142
|
+
window.removeEventListener("touchend", touchEndHandlerRef.current);
|
|
28143
|
+
}
|
|
28144
|
+
const handleTouchEnd = () => {
|
|
28145
|
+
isAllowedToDrag.current = false;
|
|
28146
|
+
touchEndHandlerRef.current = null;
|
|
28147
|
+
};
|
|
28148
|
+
touchEndHandlerRef.current = handleTouchEnd;
|
|
28149
|
+
window.addEventListener("touchend", handleTouchEnd, { once: true });
|
|
28079
28150
|
}
|
|
28080
28151
|
event.target.setPointerCapture(event.pointerId);
|
|
28081
28152
|
pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
|
|
@@ -28182,9 +28253,15 @@ function Root2({
|
|
|
28182
28253
|
}
|
|
28183
28254
|
}
|
|
28184
28255
|
import_react9.default.useEffect(() => {
|
|
28185
|
-
window.requestAnimationFrame(() => {
|
|
28256
|
+
shouldAnimateRafRef.current = window.requestAnimationFrame(() => {
|
|
28186
28257
|
shouldAnimate.current = true;
|
|
28187
28258
|
});
|
|
28259
|
+
return () => {
|
|
28260
|
+
if (shouldAnimateRafRef.current !== null) {
|
|
28261
|
+
window.cancelAnimationFrame(shouldAnimateRafRef.current);
|
|
28262
|
+
shouldAnimateRafRef.current = null;
|
|
28263
|
+
}
|
|
28264
|
+
};
|
|
28188
28265
|
}, []);
|
|
28189
28266
|
import_react9.default.useEffect(() => {
|
|
28190
28267
|
function onVisualViewportChange() {
|
|
@@ -28225,10 +28302,14 @@ function Root2({
|
|
|
28225
28302
|
if (!fromWithin) {
|
|
28226
28303
|
setIsOpen(false);
|
|
28227
28304
|
}
|
|
28228
|
-
|
|
28305
|
+
if (snapPointsResetTimeoutRef.current !== null) {
|
|
28306
|
+
window.clearTimeout(snapPointsResetTimeoutRef.current);
|
|
28307
|
+
}
|
|
28308
|
+
snapPointsResetTimeoutRef.current = window.setTimeout(() => {
|
|
28229
28309
|
if (snapPoints) {
|
|
28230
28310
|
setActiveSnapPoint(snapPoints[0]);
|
|
28231
28311
|
}
|
|
28312
|
+
snapPointsResetTimeoutRef.current = null;
|
|
28232
28313
|
}, TRANSITIONS.DURATION * 1e3);
|
|
28233
28314
|
}
|
|
28234
28315
|
function resetDrawer() {
|
|
@@ -28303,8 +28384,12 @@ function Root2({
|
|
|
28303
28384
|
});
|
|
28304
28385
|
if (releaseResult.shouldPreventFocus) {
|
|
28305
28386
|
setJustReleased(true);
|
|
28306
|
-
|
|
28387
|
+
if (justReleasedTimeoutRef.current !== null) {
|
|
28388
|
+
window.clearTimeout(justReleasedTimeoutRef.current);
|
|
28389
|
+
}
|
|
28390
|
+
justReleasedTimeoutRef.current = window.setTimeout(() => {
|
|
28307
28391
|
setJustReleased(false);
|
|
28392
|
+
justReleasedTimeoutRef.current = null;
|
|
28308
28393
|
}, 200);
|
|
28309
28394
|
}
|
|
28310
28395
|
if (releaseResult.action === "close") {
|
|
@@ -28378,11 +28463,44 @@ function Root2({
|
|
|
28378
28463
|
});
|
|
28379
28464
|
}
|
|
28380
28465
|
}
|
|
28466
|
+
import_react9.default.useEffect(() => {
|
|
28467
|
+
return () => {
|
|
28468
|
+
if (animationEndTimeoutRef.current !== null) {
|
|
28469
|
+
window.clearTimeout(animationEndTimeoutRef.current);
|
|
28470
|
+
}
|
|
28471
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28472
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28473
|
+
}
|
|
28474
|
+
if (snapPointsResetTimeoutRef.current !== null) {
|
|
28475
|
+
window.clearTimeout(snapPointsResetTimeoutRef.current);
|
|
28476
|
+
}
|
|
28477
|
+
if (justReleasedTimeoutRef.current !== null) {
|
|
28478
|
+
window.clearTimeout(justReleasedTimeoutRef.current);
|
|
28479
|
+
}
|
|
28480
|
+
if (nestedOpenChangeTimer.current) {
|
|
28481
|
+
window.clearTimeout(nestedOpenChangeTimer.current);
|
|
28482
|
+
}
|
|
28483
|
+
if (touchEndHandlerRef.current) {
|
|
28484
|
+
window.removeEventListener("touchend", touchEndHandlerRef.current);
|
|
28485
|
+
touchEndHandlerRef.current = null;
|
|
28486
|
+
}
|
|
28487
|
+
};
|
|
28488
|
+
}, []);
|
|
28381
28489
|
import_react9.default.useEffect(() => {
|
|
28382
28490
|
if (!modal) {
|
|
28383
|
-
|
|
28491
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28492
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28493
|
+
}
|
|
28494
|
+
nonModalPointerEventsRafRef.current = window.requestAnimationFrame(() => {
|
|
28384
28495
|
document.body.style.pointerEvents = "auto";
|
|
28496
|
+
nonModalPointerEventsRafRef.current = null;
|
|
28385
28497
|
});
|
|
28498
|
+
return () => {
|
|
28499
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28500
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28501
|
+
nonModalPointerEventsRafRef.current = null;
|
|
28502
|
+
}
|
|
28503
|
+
};
|
|
28386
28504
|
}
|
|
28387
28505
|
}, [modal]);
|
|
28388
28506
|
return /* @__PURE__ */ import_react9.default.createElement(
|
|
@@ -28489,15 +28607,23 @@ var Content2 = import_react9.default.forwardRef(function({ onPointerDownOutside,
|
|
|
28489
28607
|
const pointerStartRef = import_react9.default.useRef(null);
|
|
28490
28608
|
const lastKnownPointerEventRef = import_react9.default.useRef(null);
|
|
28491
28609
|
const wasBeyondThePointRef = import_react9.default.useRef(false);
|
|
28610
|
+
const delayedSnapPointsRafRef = import_react9.default.useRef(null);
|
|
28492
28611
|
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
28493
28612
|
useScaleBackground();
|
|
28494
28613
|
import_react9.default.useEffect(() => {
|
|
28495
28614
|
if (hasSnapPoints) {
|
|
28496
|
-
window.requestAnimationFrame(() => {
|
|
28615
|
+
delayedSnapPointsRafRef.current = window.requestAnimationFrame(() => {
|
|
28497
28616
|
setDelayedSnapPoints(true);
|
|
28617
|
+
delayedSnapPointsRafRef.current = null;
|
|
28498
28618
|
});
|
|
28499
28619
|
}
|
|
28500
|
-
|
|
28620
|
+
return () => {
|
|
28621
|
+
if (delayedSnapPointsRafRef.current !== null) {
|
|
28622
|
+
window.cancelAnimationFrame(delayedSnapPointsRafRef.current);
|
|
28623
|
+
delayedSnapPointsRafRef.current = null;
|
|
28624
|
+
}
|
|
28625
|
+
};
|
|
28626
|
+
}, [hasSnapPoints]);
|
|
28501
28627
|
function handleOnPointerUp(event) {
|
|
28502
28628
|
pointerStartRef.current = null;
|
|
28503
28629
|
wasBeyondThePointRef.current = false;
|
|
@@ -28606,13 +28732,14 @@ var Handle = import_react9.default.forwardRef(function({ preventCycle = false, c
|
|
|
28606
28732
|
onDrag
|
|
28607
28733
|
} = useDrawerContext();
|
|
28608
28734
|
const closeTimeoutIdRef = import_react9.default.useRef(null);
|
|
28735
|
+
const cycleTimeoutIdRef = import_react9.default.useRef(null);
|
|
28609
28736
|
const shouldCancelInteractionRef = import_react9.default.useRef(false);
|
|
28610
28737
|
function handleStartCycle() {
|
|
28611
28738
|
if (shouldCancelInteractionRef.current) {
|
|
28612
28739
|
handleCancelInteraction();
|
|
28613
28740
|
return;
|
|
28614
28741
|
}
|
|
28615
|
-
window.setTimeout(() => {
|
|
28742
|
+
cycleTimeoutIdRef.current = window.setTimeout(() => {
|
|
28616
28743
|
handleCycleSnapPoints();
|
|
28617
28744
|
}, DOUBLE_TAP_TIMEOUT);
|
|
28618
28745
|
}
|
|
@@ -28643,9 +28770,19 @@ var Handle = import_react9.default.forwardRef(function({ preventCycle = false, c
|
|
|
28643
28770
|
function handleCancelInteraction() {
|
|
28644
28771
|
if (closeTimeoutIdRef.current) {
|
|
28645
28772
|
window.clearTimeout(closeTimeoutIdRef.current);
|
|
28773
|
+
closeTimeoutIdRef.current = null;
|
|
28774
|
+
}
|
|
28775
|
+
if (cycleTimeoutIdRef.current) {
|
|
28776
|
+
window.clearTimeout(cycleTimeoutIdRef.current);
|
|
28777
|
+
cycleTimeoutIdRef.current = null;
|
|
28646
28778
|
}
|
|
28647
28779
|
shouldCancelInteractionRef.current = false;
|
|
28648
28780
|
}
|
|
28781
|
+
import_react9.default.useEffect(() => {
|
|
28782
|
+
return () => {
|
|
28783
|
+
handleCancelInteraction();
|
|
28784
|
+
};
|
|
28785
|
+
}, []);
|
|
28649
28786
|
return /* @__PURE__ */ import_react9.default.createElement(
|
|
28650
28787
|
"div",
|
|
28651
28788
|
{
|
|
@@ -28726,7 +28863,7 @@ var VISUALLY_HIDDEN_STYLE = {
|
|
|
28726
28863
|
whiteSpace: "nowrap",
|
|
28727
28864
|
border: 0
|
|
28728
28865
|
};
|
|
28729
|
-
var
|
|
28866
|
+
var useSafeLayoutEffect2 = typeof window === "undefined" ? import_react10.default.useEffect : import_react10.default.useLayoutEffect;
|
|
28730
28867
|
function toReactDrawerProps(options, open, onOpenChange, internalOnDragChange, internalOnReleaseChange) {
|
|
28731
28868
|
const { id: _id, parentId: _parentId, onDragChange, onReleaseChange, ...drawerOptions } = options;
|
|
28732
28869
|
const baseProps = {
|
|
@@ -28760,7 +28897,7 @@ function VanillaNode({
|
|
|
28760
28897
|
dataAttribute
|
|
28761
28898
|
}) {
|
|
28762
28899
|
const ref = import_react10.default.useRef(null);
|
|
28763
|
-
|
|
28900
|
+
useSafeLayoutEffect2(() => {
|
|
28764
28901
|
const element = ref.current;
|
|
28765
28902
|
if (!element) {
|
|
28766
28903
|
return;
|
|
@@ -28966,6 +29103,7 @@ function openAncestorChain(parentId) {
|
|
|
28966
29103
|
openAncestorChain(nextParentId);
|
|
28967
29104
|
}
|
|
28968
29105
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
29106
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
28969
29107
|
parentRuntime.controller.setOpen(true);
|
|
28970
29108
|
notifyOpenStateChange(parentRuntime, true);
|
|
28971
29109
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -28985,6 +29123,7 @@ function bindTriggerElement(runtime) {
|
|
|
28985
29123
|
}
|
|
28986
29124
|
const triggerElement = runtime.options.triggerElement;
|
|
28987
29125
|
const handleClick = () => {
|
|
29126
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
28988
29127
|
runtime.controller.setOpen(true);
|
|
28989
29128
|
renderVanillaDrawer(runtime.id);
|
|
28990
29129
|
};
|
|
@@ -29020,6 +29159,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
29020
29159
|
function canUseDOM3() {
|
|
29021
29160
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
29022
29161
|
}
|
|
29162
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
29163
|
+
if (!canUseDOM3() || options.modal === false || options.autoFocus) {
|
|
29164
|
+
return;
|
|
29165
|
+
}
|
|
29166
|
+
const activeElement = document.activeElement;
|
|
29167
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== "function") {
|
|
29168
|
+
return;
|
|
29169
|
+
}
|
|
29170
|
+
activeElement.blur();
|
|
29171
|
+
}
|
|
29023
29172
|
function getRuntimeDrawerElement(runtime) {
|
|
29024
29173
|
if (!runtime.element) {
|
|
29025
29174
|
return null;
|
|
@@ -29073,6 +29222,9 @@ function renderVanillaDrawer(id) {
|
|
|
29073
29222
|
open: snapshot.state.isOpen,
|
|
29074
29223
|
onOpenChange: (open) => {
|
|
29075
29224
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29225
|
+
if (open) {
|
|
29226
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29227
|
+
}
|
|
29076
29228
|
runtime.controller.setOpen(open);
|
|
29077
29229
|
if (previousOpen !== open) {
|
|
29078
29230
|
notifyOpenStateChange(runtime, open);
|
|
@@ -29119,6 +29271,9 @@ function buildVanillaController(id) {
|
|
|
29119
29271
|
if (!runtime) {
|
|
29120
29272
|
return createDrawer({ id, open }).getSnapshot();
|
|
29121
29273
|
}
|
|
29274
|
+
if (open) {
|
|
29275
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29276
|
+
}
|
|
29122
29277
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29123
29278
|
const snapshot = runtime.controller.setOpen(open);
|
|
29124
29279
|
if (previousOpen !== open) {
|
|
@@ -29189,6 +29344,9 @@ function createDrawer(options = {}) {
|
|
|
29189
29344
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
29190
29345
|
}
|
|
29191
29346
|
}
|
|
29347
|
+
if (nextOptions.open && !previousOpen) {
|
|
29348
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
29349
|
+
}
|
|
29192
29350
|
renderVanillaDrawer(id);
|
|
29193
29351
|
if (nextOptions.parentId && nextOptions.open) {
|
|
29194
29352
|
openAncestorChain(nextOptions.parentId);
|