@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/browser/index.cjs
CHANGED
|
@@ -1105,7 +1105,7 @@ var require_react_development = __commonJS({
|
|
|
1105
1105
|
var dispatcher = resolveDispatcher();
|
|
1106
1106
|
return dispatcher.useReducer(reducer, initialArg, init);
|
|
1107
1107
|
}
|
|
1108
|
-
function
|
|
1108
|
+
function useRef11(initialValue) {
|
|
1109
1109
|
var dispatcher = resolveDispatcher();
|
|
1110
1110
|
return dispatcher.useRef(initialValue);
|
|
1111
1111
|
}
|
|
@@ -1899,7 +1899,7 @@ var require_react_development = __commonJS({
|
|
|
1899
1899
|
exports.useLayoutEffect = useLayoutEffect5;
|
|
1900
1900
|
exports.useMemo = useMemo6;
|
|
1901
1901
|
exports.useReducer = useReducer3;
|
|
1902
|
-
exports.useRef =
|
|
1902
|
+
exports.useRef = useRef11;
|
|
1903
1903
|
exports.useState = useState10;
|
|
1904
1904
|
exports.useSyncExternalStore = useSyncExternalStore;
|
|
1905
1905
|
exports.useTransition = useTransition;
|
|
@@ -26988,25 +26988,34 @@ var nonTextInputTypes = /* @__PURE__ */ new Set([
|
|
|
26988
26988
|
"submit",
|
|
26989
26989
|
"reset"
|
|
26990
26990
|
]);
|
|
26991
|
-
var
|
|
26992
|
-
var
|
|
26991
|
+
var activePreventScrollLocks = /* @__PURE__ */ new Set();
|
|
26992
|
+
var activePreventScrollRestore = null;
|
|
26993
|
+
function acquirePreventScrollLock(lockId) {
|
|
26994
|
+
activePreventScrollLocks.add(lockId);
|
|
26995
|
+
if (activePreventScrollLocks.size === 1 && isIOS()) {
|
|
26996
|
+
activePreventScrollRestore = preventScrollMobileSafari();
|
|
26997
|
+
}
|
|
26998
|
+
}
|
|
26999
|
+
function releasePreventScrollLock(lockId) {
|
|
27000
|
+
activePreventScrollLocks.delete(lockId);
|
|
27001
|
+
if (activePreventScrollLocks.size === 0) {
|
|
27002
|
+
activePreventScrollRestore?.();
|
|
27003
|
+
activePreventScrollRestore = null;
|
|
27004
|
+
}
|
|
27005
|
+
}
|
|
26993
27006
|
function usePreventScroll(options = {}) {
|
|
26994
27007
|
let { isDisabled } = options;
|
|
27008
|
+
const lockIdRef = (0, import_react3.useRef)();
|
|
27009
|
+
if (!lockIdRef.current) {
|
|
27010
|
+
lockIdRef.current = /* @__PURE__ */ Symbol("drawer-prevent-scroll-lock");
|
|
27011
|
+
}
|
|
26995
27012
|
useIsomorphicLayoutEffect2(() => {
|
|
26996
27013
|
if (isDisabled) {
|
|
26997
27014
|
return;
|
|
26998
27015
|
}
|
|
26999
|
-
|
|
27000
|
-
if (preventScrollCount === 1) {
|
|
27001
|
-
if (isIOS()) {
|
|
27002
|
-
restore = preventScrollMobileSafari();
|
|
27003
|
-
}
|
|
27004
|
-
}
|
|
27016
|
+
acquirePreventScrollLock(lockIdRef.current);
|
|
27005
27017
|
return () => {
|
|
27006
|
-
|
|
27007
|
-
if (preventScrollCount === 0) {
|
|
27008
|
-
restore?.();
|
|
27009
|
-
}
|
|
27018
|
+
releasePreventScrollLock(lockIdRef.current);
|
|
27010
27019
|
};
|
|
27011
27020
|
}, [isDisabled]);
|
|
27012
27021
|
}
|
|
@@ -27580,12 +27589,23 @@ function useScaleBackground() {
|
|
|
27580
27589
|
const { direction, isOpen, shouldScaleBackground, setBackgroundColorOnScale, noBodyStyles } = useDrawerContext();
|
|
27581
27590
|
const timeoutIdRef = import_react6.default.useRef(null);
|
|
27582
27591
|
const initialBackgroundColor = (0, import_react6.useMemo)(() => document.body.style.backgroundColor, []);
|
|
27592
|
+
import_react6.default.useEffect(() => {
|
|
27593
|
+
return () => {
|
|
27594
|
+
if (timeoutIdRef.current !== null) {
|
|
27595
|
+
window.clearTimeout(timeoutIdRef.current);
|
|
27596
|
+
timeoutIdRef.current = null;
|
|
27597
|
+
}
|
|
27598
|
+
};
|
|
27599
|
+
}, []);
|
|
27583
27600
|
function getScale() {
|
|
27584
27601
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
27585
27602
|
}
|
|
27586
27603
|
import_react6.default.useEffect(() => {
|
|
27587
27604
|
if (isOpen && shouldScaleBackground) {
|
|
27588
|
-
if (timeoutIdRef.current)
|
|
27605
|
+
if (timeoutIdRef.current !== null) {
|
|
27606
|
+
clearTimeout(timeoutIdRef.current);
|
|
27607
|
+
timeoutIdRef.current = null;
|
|
27608
|
+
}
|
|
27589
27609
|
const wrapper = document.querySelector("[data-drawer-wrapper]");
|
|
27590
27610
|
if (!wrapper) return;
|
|
27591
27611
|
chain(
|
|
@@ -27614,6 +27634,7 @@ function useScaleBackground() {
|
|
|
27614
27634
|
} else {
|
|
27615
27635
|
document.body.style.removeProperty("background");
|
|
27616
27636
|
}
|
|
27637
|
+
timeoutIdRef.current = null;
|
|
27617
27638
|
}, TRANSITIONS.DURATION * 1e3);
|
|
27618
27639
|
};
|
|
27619
27640
|
}
|
|
@@ -27623,6 +27644,14 @@ function useScaleBackground() {
|
|
|
27623
27644
|
// src/use-position-fixed.ts
|
|
27624
27645
|
var import_react7 = __toESM(require_react());
|
|
27625
27646
|
var previousBodyPosition = null;
|
|
27647
|
+
var activeBodyPositionLocks = /* @__PURE__ */ new Set();
|
|
27648
|
+
var bodyPositionTimeoutId = null;
|
|
27649
|
+
function clearBodyPositionTimeout() {
|
|
27650
|
+
if (bodyPositionTimeoutId !== null) {
|
|
27651
|
+
window.clearTimeout(bodyPositionTimeoutId);
|
|
27652
|
+
bodyPositionTimeoutId = null;
|
|
27653
|
+
}
|
|
27654
|
+
}
|
|
27626
27655
|
function usePositionFixed({
|
|
27627
27656
|
isOpen,
|
|
27628
27657
|
modal,
|
|
@@ -27633,8 +27662,17 @@ function usePositionFixed({
|
|
|
27633
27662
|
}) {
|
|
27634
27663
|
const [activeUrl, setActiveUrl] = import_react7.default.useState(() => typeof window !== "undefined" ? window.location.href : "");
|
|
27635
27664
|
const scrollPos = import_react7.default.useRef(0);
|
|
27665
|
+
const lockIdRef = import_react7.default.useRef();
|
|
27666
|
+
if (!lockIdRef.current) {
|
|
27667
|
+
lockIdRef.current = /* @__PURE__ */ Symbol("drawer-body-position-lock");
|
|
27668
|
+
}
|
|
27636
27669
|
const setPositionFixed = import_react7.default.useCallback(() => {
|
|
27637
27670
|
if (!isSafari()) return;
|
|
27671
|
+
const lockId = lockIdRef.current;
|
|
27672
|
+
if (activeBodyPositionLocks.has(lockId)) {
|
|
27673
|
+
return;
|
|
27674
|
+
}
|
|
27675
|
+
activeBodyPositionLocks.add(lockId);
|
|
27638
27676
|
if (previousBodyPosition === null && isOpen && !noBodyStyles) {
|
|
27639
27677
|
previousBodyPosition = {
|
|
27640
27678
|
position: document.body.style.position,
|
|
@@ -27651,7 +27689,8 @@ function usePositionFixed({
|
|
|
27651
27689
|
right: "0px",
|
|
27652
27690
|
height: "auto"
|
|
27653
27691
|
});
|
|
27654
|
-
|
|
27692
|
+
clearBodyPositionTimeout();
|
|
27693
|
+
bodyPositionTimeoutId = window.setTimeout(
|
|
27655
27694
|
() => window.requestAnimationFrame(() => {
|
|
27656
27695
|
const bottomBarHeight = innerHeight - window.innerHeight;
|
|
27657
27696
|
if (bottomBarHeight && scrollPos.current >= innerHeight) {
|
|
@@ -27661,10 +27700,16 @@ function usePositionFixed({
|
|
|
27661
27700
|
300
|
|
27662
27701
|
);
|
|
27663
27702
|
}
|
|
27664
|
-
}, [isOpen]);
|
|
27703
|
+
}, [isOpen, noBodyStyles]);
|
|
27665
27704
|
const restorePositionSetting = import_react7.default.useCallback(() => {
|
|
27666
27705
|
if (!isSafari()) return;
|
|
27706
|
+
const lockId = lockIdRef.current;
|
|
27707
|
+
activeBodyPositionLocks.delete(lockId);
|
|
27708
|
+
if (activeBodyPositionLocks.size > 0) {
|
|
27709
|
+
return;
|
|
27710
|
+
}
|
|
27667
27711
|
if (previousBodyPosition !== null && !noBodyStyles) {
|
|
27712
|
+
clearBodyPositionTimeout();
|
|
27668
27713
|
const y = -parseInt(document.body.style.top, 10);
|
|
27669
27714
|
const x = -parseInt(document.body.style.left, 10);
|
|
27670
27715
|
Object.assign(document.body.style, previousBodyPosition);
|
|
@@ -27677,7 +27722,7 @@ function usePositionFixed({
|
|
|
27677
27722
|
});
|
|
27678
27723
|
previousBodyPosition = null;
|
|
27679
27724
|
}
|
|
27680
|
-
}, [activeUrl]);
|
|
27725
|
+
}, [activeUrl, noBodyStyles, setActiveUrl]);
|
|
27681
27726
|
import_react7.default.useEffect(() => {
|
|
27682
27727
|
function onScroll() {
|
|
27683
27728
|
scrollPos.current = window.scrollY;
|
|
@@ -27944,6 +27989,7 @@ function getDragPermission({
|
|
|
27944
27989
|
}
|
|
27945
27990
|
|
|
27946
27991
|
// src/react/components.tsx
|
|
27992
|
+
var useSafeLayoutEffect = typeof window === "undefined" ? import_react9.default.useEffect : import_react9.default.useLayoutEffect;
|
|
27947
27993
|
function Root2({
|
|
27948
27994
|
open: openProp,
|
|
27949
27995
|
onOpenChange,
|
|
@@ -27975,6 +28021,12 @@ function Root2({
|
|
|
27975
28021
|
container,
|
|
27976
28022
|
autoFocus = false
|
|
27977
28023
|
}) {
|
|
28024
|
+
const animationEndTimeoutRef = import_react9.default.useRef(null);
|
|
28025
|
+
const nonModalPointerEventsRafRef = import_react9.default.useRef(null);
|
|
28026
|
+
const shouldAnimateRafRef = import_react9.default.useRef(null);
|
|
28027
|
+
const snapPointsResetTimeoutRef = import_react9.default.useRef(null);
|
|
28028
|
+
const justReleasedTimeoutRef = import_react9.default.useRef(null);
|
|
28029
|
+
const touchEndHandlerRef = import_react9.default.useRef(null);
|
|
27978
28030
|
const [isOpen = false, setIsOpen] = useControllableState2({
|
|
27979
28031
|
defaultProp: defaultOpen,
|
|
27980
28032
|
prop: openProp,
|
|
@@ -27983,13 +28035,20 @@ function Root2({
|
|
|
27983
28035
|
if (!o && !nested) {
|
|
27984
28036
|
restorePositionSetting();
|
|
27985
28037
|
}
|
|
27986
|
-
|
|
28038
|
+
if (animationEndTimeoutRef.current !== null) {
|
|
28039
|
+
window.clearTimeout(animationEndTimeoutRef.current);
|
|
28040
|
+
}
|
|
28041
|
+
animationEndTimeoutRef.current = window.setTimeout(() => {
|
|
27987
28042
|
onAnimationEnd?.(o);
|
|
27988
28043
|
}, TRANSITIONS.DURATION * 1e3);
|
|
27989
28044
|
if (o && !modal) {
|
|
27990
28045
|
if (typeof window !== "undefined") {
|
|
27991
|
-
|
|
28046
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28047
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28048
|
+
}
|
|
28049
|
+
nonModalPointerEventsRafRef.current = window.requestAnimationFrame(() => {
|
|
27992
28050
|
document.body.style.pointerEvents = "auto";
|
|
28051
|
+
nonModalPointerEventsRafRef.current = null;
|
|
27993
28052
|
});
|
|
27994
28053
|
}
|
|
27995
28054
|
}
|
|
@@ -28074,18 +28133,22 @@ function Root2({
|
|
|
28074
28133
|
noBodyStyles,
|
|
28075
28134
|
autoFocus
|
|
28076
28135
|
});
|
|
28077
|
-
|
|
28136
|
+
useSafeLayoutEffect(() => {
|
|
28078
28137
|
if (!isOpen || !modal || autoFocus || typeof document === "undefined") {
|
|
28079
28138
|
return;
|
|
28080
28139
|
}
|
|
28081
28140
|
const activeElement = document.activeElement;
|
|
28082
|
-
if (!
|
|
28141
|
+
if (!activeElement || activeElement === document.body) {
|
|
28083
28142
|
return;
|
|
28084
28143
|
}
|
|
28085
|
-
|
|
28144
|
+
const activeElementNode = activeElement;
|
|
28145
|
+
if (drawerRef.current?.contains(activeElementNode) || activeElementNode.closest?.("[data-drawer]")) {
|
|
28086
28146
|
return;
|
|
28087
28147
|
}
|
|
28088
|
-
|
|
28148
|
+
if (typeof activeElementNode.blur !== "function") {
|
|
28149
|
+
return;
|
|
28150
|
+
}
|
|
28151
|
+
activeElementNode.blur();
|
|
28089
28152
|
}, [autoFocus, isOpen, modal]);
|
|
28090
28153
|
function getScale() {
|
|
28091
28154
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
@@ -28098,7 +28161,15 @@ function Root2({
|
|
|
28098
28161
|
setIsDragging(true);
|
|
28099
28162
|
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
28100
28163
|
if (isIOS()) {
|
|
28101
|
-
|
|
28164
|
+
if (touchEndHandlerRef.current) {
|
|
28165
|
+
window.removeEventListener("touchend", touchEndHandlerRef.current);
|
|
28166
|
+
}
|
|
28167
|
+
const handleTouchEnd = () => {
|
|
28168
|
+
isAllowedToDrag.current = false;
|
|
28169
|
+
touchEndHandlerRef.current = null;
|
|
28170
|
+
};
|
|
28171
|
+
touchEndHandlerRef.current = handleTouchEnd;
|
|
28172
|
+
window.addEventListener("touchend", handleTouchEnd, { once: true });
|
|
28102
28173
|
}
|
|
28103
28174
|
event.target.setPointerCapture(event.pointerId);
|
|
28104
28175
|
pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
|
|
@@ -28205,9 +28276,15 @@ function Root2({
|
|
|
28205
28276
|
}
|
|
28206
28277
|
}
|
|
28207
28278
|
import_react9.default.useEffect(() => {
|
|
28208
|
-
window.requestAnimationFrame(() => {
|
|
28279
|
+
shouldAnimateRafRef.current = window.requestAnimationFrame(() => {
|
|
28209
28280
|
shouldAnimate.current = true;
|
|
28210
28281
|
});
|
|
28282
|
+
return () => {
|
|
28283
|
+
if (shouldAnimateRafRef.current !== null) {
|
|
28284
|
+
window.cancelAnimationFrame(shouldAnimateRafRef.current);
|
|
28285
|
+
shouldAnimateRafRef.current = null;
|
|
28286
|
+
}
|
|
28287
|
+
};
|
|
28211
28288
|
}, []);
|
|
28212
28289
|
import_react9.default.useEffect(() => {
|
|
28213
28290
|
function onVisualViewportChange() {
|
|
@@ -28248,10 +28325,14 @@ function Root2({
|
|
|
28248
28325
|
if (!fromWithin) {
|
|
28249
28326
|
setIsOpen(false);
|
|
28250
28327
|
}
|
|
28251
|
-
|
|
28328
|
+
if (snapPointsResetTimeoutRef.current !== null) {
|
|
28329
|
+
window.clearTimeout(snapPointsResetTimeoutRef.current);
|
|
28330
|
+
}
|
|
28331
|
+
snapPointsResetTimeoutRef.current = window.setTimeout(() => {
|
|
28252
28332
|
if (snapPoints) {
|
|
28253
28333
|
setActiveSnapPoint(snapPoints[0]);
|
|
28254
28334
|
}
|
|
28335
|
+
snapPointsResetTimeoutRef.current = null;
|
|
28255
28336
|
}, TRANSITIONS.DURATION * 1e3);
|
|
28256
28337
|
}
|
|
28257
28338
|
function resetDrawer() {
|
|
@@ -28326,8 +28407,12 @@ function Root2({
|
|
|
28326
28407
|
});
|
|
28327
28408
|
if (releaseResult.shouldPreventFocus) {
|
|
28328
28409
|
setJustReleased(true);
|
|
28329
|
-
|
|
28410
|
+
if (justReleasedTimeoutRef.current !== null) {
|
|
28411
|
+
window.clearTimeout(justReleasedTimeoutRef.current);
|
|
28412
|
+
}
|
|
28413
|
+
justReleasedTimeoutRef.current = window.setTimeout(() => {
|
|
28330
28414
|
setJustReleased(false);
|
|
28415
|
+
justReleasedTimeoutRef.current = null;
|
|
28331
28416
|
}, 200);
|
|
28332
28417
|
}
|
|
28333
28418
|
if (releaseResult.action === "close") {
|
|
@@ -28401,11 +28486,44 @@ function Root2({
|
|
|
28401
28486
|
});
|
|
28402
28487
|
}
|
|
28403
28488
|
}
|
|
28489
|
+
import_react9.default.useEffect(() => {
|
|
28490
|
+
return () => {
|
|
28491
|
+
if (animationEndTimeoutRef.current !== null) {
|
|
28492
|
+
window.clearTimeout(animationEndTimeoutRef.current);
|
|
28493
|
+
}
|
|
28494
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28495
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28496
|
+
}
|
|
28497
|
+
if (snapPointsResetTimeoutRef.current !== null) {
|
|
28498
|
+
window.clearTimeout(snapPointsResetTimeoutRef.current);
|
|
28499
|
+
}
|
|
28500
|
+
if (justReleasedTimeoutRef.current !== null) {
|
|
28501
|
+
window.clearTimeout(justReleasedTimeoutRef.current);
|
|
28502
|
+
}
|
|
28503
|
+
if (nestedOpenChangeTimer.current) {
|
|
28504
|
+
window.clearTimeout(nestedOpenChangeTimer.current);
|
|
28505
|
+
}
|
|
28506
|
+
if (touchEndHandlerRef.current) {
|
|
28507
|
+
window.removeEventListener("touchend", touchEndHandlerRef.current);
|
|
28508
|
+
touchEndHandlerRef.current = null;
|
|
28509
|
+
}
|
|
28510
|
+
};
|
|
28511
|
+
}, []);
|
|
28404
28512
|
import_react9.default.useEffect(() => {
|
|
28405
28513
|
if (!modal) {
|
|
28406
|
-
|
|
28514
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28515
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28516
|
+
}
|
|
28517
|
+
nonModalPointerEventsRafRef.current = window.requestAnimationFrame(() => {
|
|
28407
28518
|
document.body.style.pointerEvents = "auto";
|
|
28519
|
+
nonModalPointerEventsRafRef.current = null;
|
|
28408
28520
|
});
|
|
28521
|
+
return () => {
|
|
28522
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28523
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28524
|
+
nonModalPointerEventsRafRef.current = null;
|
|
28525
|
+
}
|
|
28526
|
+
};
|
|
28409
28527
|
}
|
|
28410
28528
|
}, [modal]);
|
|
28411
28529
|
return /* @__PURE__ */ import_react9.default.createElement(
|
|
@@ -28512,15 +28630,23 @@ var Content2 = import_react9.default.forwardRef(function({ onPointerDownOutside,
|
|
|
28512
28630
|
const pointerStartRef = import_react9.default.useRef(null);
|
|
28513
28631
|
const lastKnownPointerEventRef = import_react9.default.useRef(null);
|
|
28514
28632
|
const wasBeyondThePointRef = import_react9.default.useRef(false);
|
|
28633
|
+
const delayedSnapPointsRafRef = import_react9.default.useRef(null);
|
|
28515
28634
|
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
28516
28635
|
useScaleBackground();
|
|
28517
28636
|
import_react9.default.useEffect(() => {
|
|
28518
28637
|
if (hasSnapPoints) {
|
|
28519
|
-
window.requestAnimationFrame(() => {
|
|
28638
|
+
delayedSnapPointsRafRef.current = window.requestAnimationFrame(() => {
|
|
28520
28639
|
setDelayedSnapPoints(true);
|
|
28640
|
+
delayedSnapPointsRafRef.current = null;
|
|
28521
28641
|
});
|
|
28522
28642
|
}
|
|
28523
|
-
|
|
28643
|
+
return () => {
|
|
28644
|
+
if (delayedSnapPointsRafRef.current !== null) {
|
|
28645
|
+
window.cancelAnimationFrame(delayedSnapPointsRafRef.current);
|
|
28646
|
+
delayedSnapPointsRafRef.current = null;
|
|
28647
|
+
}
|
|
28648
|
+
};
|
|
28649
|
+
}, [hasSnapPoints]);
|
|
28524
28650
|
function handleOnPointerUp(event) {
|
|
28525
28651
|
pointerStartRef.current = null;
|
|
28526
28652
|
wasBeyondThePointRef.current = false;
|
|
@@ -28629,13 +28755,14 @@ var Handle = import_react9.default.forwardRef(function({ preventCycle = false, c
|
|
|
28629
28755
|
onDrag
|
|
28630
28756
|
} = useDrawerContext();
|
|
28631
28757
|
const closeTimeoutIdRef = import_react9.default.useRef(null);
|
|
28758
|
+
const cycleTimeoutIdRef = import_react9.default.useRef(null);
|
|
28632
28759
|
const shouldCancelInteractionRef = import_react9.default.useRef(false);
|
|
28633
28760
|
function handleStartCycle() {
|
|
28634
28761
|
if (shouldCancelInteractionRef.current) {
|
|
28635
28762
|
handleCancelInteraction();
|
|
28636
28763
|
return;
|
|
28637
28764
|
}
|
|
28638
|
-
window.setTimeout(() => {
|
|
28765
|
+
cycleTimeoutIdRef.current = window.setTimeout(() => {
|
|
28639
28766
|
handleCycleSnapPoints();
|
|
28640
28767
|
}, DOUBLE_TAP_TIMEOUT);
|
|
28641
28768
|
}
|
|
@@ -28666,9 +28793,19 @@ var Handle = import_react9.default.forwardRef(function({ preventCycle = false, c
|
|
|
28666
28793
|
function handleCancelInteraction() {
|
|
28667
28794
|
if (closeTimeoutIdRef.current) {
|
|
28668
28795
|
window.clearTimeout(closeTimeoutIdRef.current);
|
|
28796
|
+
closeTimeoutIdRef.current = null;
|
|
28797
|
+
}
|
|
28798
|
+
if (cycleTimeoutIdRef.current) {
|
|
28799
|
+
window.clearTimeout(cycleTimeoutIdRef.current);
|
|
28800
|
+
cycleTimeoutIdRef.current = null;
|
|
28669
28801
|
}
|
|
28670
28802
|
shouldCancelInteractionRef.current = false;
|
|
28671
28803
|
}
|
|
28804
|
+
import_react9.default.useEffect(() => {
|
|
28805
|
+
return () => {
|
|
28806
|
+
handleCancelInteraction();
|
|
28807
|
+
};
|
|
28808
|
+
}, []);
|
|
28672
28809
|
return /* @__PURE__ */ import_react9.default.createElement(
|
|
28673
28810
|
"div",
|
|
28674
28811
|
{
|
|
@@ -28749,7 +28886,7 @@ var VISUALLY_HIDDEN_STYLE = {
|
|
|
28749
28886
|
whiteSpace: "nowrap",
|
|
28750
28887
|
border: 0
|
|
28751
28888
|
};
|
|
28752
|
-
var
|
|
28889
|
+
var useSafeLayoutEffect2 = typeof window === "undefined" ? import_react10.default.useEffect : import_react10.default.useLayoutEffect;
|
|
28753
28890
|
function toReactDrawerProps(options, open, onOpenChange, internalOnDragChange, internalOnReleaseChange) {
|
|
28754
28891
|
const { id: _id, parentId: _parentId, onDragChange, onReleaseChange, ...drawerOptions } = options;
|
|
28755
28892
|
const baseProps = {
|
|
@@ -28783,7 +28920,7 @@ function VanillaNode({
|
|
|
28783
28920
|
dataAttribute
|
|
28784
28921
|
}) {
|
|
28785
28922
|
const ref = import_react10.default.useRef(null);
|
|
28786
|
-
|
|
28923
|
+
useSafeLayoutEffect2(() => {
|
|
28787
28924
|
const element = ref.current;
|
|
28788
28925
|
if (!element) {
|
|
28789
28926
|
return;
|
|
@@ -28989,6 +29126,7 @@ function openAncestorChain(parentId) {
|
|
|
28989
29126
|
openAncestorChain(nextParentId);
|
|
28990
29127
|
}
|
|
28991
29128
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
29129
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
28992
29130
|
parentRuntime.controller.setOpen(true);
|
|
28993
29131
|
notifyOpenStateChange(parentRuntime, true);
|
|
28994
29132
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -29008,6 +29146,7 @@ function bindTriggerElement(runtime) {
|
|
|
29008
29146
|
}
|
|
29009
29147
|
const triggerElement = runtime.options.triggerElement;
|
|
29010
29148
|
const handleClick = () => {
|
|
29149
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29011
29150
|
runtime.controller.setOpen(true);
|
|
29012
29151
|
renderVanillaDrawer(runtime.id);
|
|
29013
29152
|
};
|
|
@@ -29043,6 +29182,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
29043
29182
|
function canUseDOM3() {
|
|
29044
29183
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
29045
29184
|
}
|
|
29185
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
29186
|
+
if (!canUseDOM3() || options.modal === false || options.autoFocus) {
|
|
29187
|
+
return;
|
|
29188
|
+
}
|
|
29189
|
+
const activeElement = document.activeElement;
|
|
29190
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== "function") {
|
|
29191
|
+
return;
|
|
29192
|
+
}
|
|
29193
|
+
activeElement.blur();
|
|
29194
|
+
}
|
|
29046
29195
|
function getRuntimeDrawerElement(runtime) {
|
|
29047
29196
|
if (!runtime.element) {
|
|
29048
29197
|
return null;
|
|
@@ -29096,6 +29245,9 @@ function renderVanillaDrawer(id) {
|
|
|
29096
29245
|
open: snapshot.state.isOpen,
|
|
29097
29246
|
onOpenChange: (open) => {
|
|
29098
29247
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29248
|
+
if (open) {
|
|
29249
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29250
|
+
}
|
|
29099
29251
|
runtime.controller.setOpen(open);
|
|
29100
29252
|
if (previousOpen !== open) {
|
|
29101
29253
|
notifyOpenStateChange(runtime, open);
|
|
@@ -29142,6 +29294,9 @@ function buildVanillaController(id) {
|
|
|
29142
29294
|
if (!runtime) {
|
|
29143
29295
|
return createDrawer({ id, open }).getSnapshot();
|
|
29144
29296
|
}
|
|
29297
|
+
if (open) {
|
|
29298
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29299
|
+
}
|
|
29145
29300
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29146
29301
|
const snapshot = runtime.controller.setOpen(open);
|
|
29147
29302
|
if (previousOpen !== open) {
|
|
@@ -29212,6 +29367,9 @@ function createDrawer(options = {}) {
|
|
|
29212
29367
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
29213
29368
|
}
|
|
29214
29369
|
}
|
|
29370
|
+
if (nextOptions.open && !previousOpen) {
|
|
29371
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
29372
|
+
}
|
|
29215
29373
|
renderVanillaDrawer(id);
|
|
29216
29374
|
if (nextOptions.parentId && nextOptions.open) {
|
|
29217
29375
|
openAncestorChain(nextOptions.parentId);
|