@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/svelte/index.js
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;
|
|
@@ -26990,25 +26990,34 @@ var nonTextInputTypes = /* @__PURE__ */ new Set([
|
|
|
26990
26990
|
"submit",
|
|
26991
26991
|
"reset"
|
|
26992
26992
|
]);
|
|
26993
|
-
var
|
|
26994
|
-
var
|
|
26993
|
+
var activePreventScrollLocks = /* @__PURE__ */ new Set();
|
|
26994
|
+
var activePreventScrollRestore = null;
|
|
26995
|
+
function acquirePreventScrollLock(lockId) {
|
|
26996
|
+
activePreventScrollLocks.add(lockId);
|
|
26997
|
+
if (activePreventScrollLocks.size === 1 && isIOS()) {
|
|
26998
|
+
activePreventScrollRestore = preventScrollMobileSafari();
|
|
26999
|
+
}
|
|
27000
|
+
}
|
|
27001
|
+
function releasePreventScrollLock(lockId) {
|
|
27002
|
+
activePreventScrollLocks.delete(lockId);
|
|
27003
|
+
if (activePreventScrollLocks.size === 0) {
|
|
27004
|
+
activePreventScrollRestore?.();
|
|
27005
|
+
activePreventScrollRestore = null;
|
|
27006
|
+
}
|
|
27007
|
+
}
|
|
26995
27008
|
function usePreventScroll(options = {}) {
|
|
26996
27009
|
let { isDisabled } = options;
|
|
27010
|
+
const lockIdRef = (0, import_react3.useRef)();
|
|
27011
|
+
if (!lockIdRef.current) {
|
|
27012
|
+
lockIdRef.current = /* @__PURE__ */ Symbol("drawer-prevent-scroll-lock");
|
|
27013
|
+
}
|
|
26997
27014
|
useIsomorphicLayoutEffect2(() => {
|
|
26998
27015
|
if (isDisabled) {
|
|
26999
27016
|
return;
|
|
27000
27017
|
}
|
|
27001
|
-
|
|
27002
|
-
if (preventScrollCount === 1) {
|
|
27003
|
-
if (isIOS()) {
|
|
27004
|
-
restore = preventScrollMobileSafari();
|
|
27005
|
-
}
|
|
27006
|
-
}
|
|
27018
|
+
acquirePreventScrollLock(lockIdRef.current);
|
|
27007
27019
|
return () => {
|
|
27008
|
-
|
|
27009
|
-
if (preventScrollCount === 0) {
|
|
27010
|
-
restore?.();
|
|
27011
|
-
}
|
|
27020
|
+
releasePreventScrollLock(lockIdRef.current);
|
|
27012
27021
|
};
|
|
27013
27022
|
}, [isDisabled]);
|
|
27014
27023
|
}
|
|
@@ -27582,12 +27591,23 @@ function useScaleBackground() {
|
|
|
27582
27591
|
const { direction, isOpen, shouldScaleBackground, setBackgroundColorOnScale, noBodyStyles } = useDrawerContext();
|
|
27583
27592
|
const timeoutIdRef = import_react6.default.useRef(null);
|
|
27584
27593
|
const initialBackgroundColor = (0, import_react6.useMemo)(() => document.body.style.backgroundColor, []);
|
|
27594
|
+
import_react6.default.useEffect(() => {
|
|
27595
|
+
return () => {
|
|
27596
|
+
if (timeoutIdRef.current !== null) {
|
|
27597
|
+
window.clearTimeout(timeoutIdRef.current);
|
|
27598
|
+
timeoutIdRef.current = null;
|
|
27599
|
+
}
|
|
27600
|
+
};
|
|
27601
|
+
}, []);
|
|
27585
27602
|
function getScale() {
|
|
27586
27603
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
27587
27604
|
}
|
|
27588
27605
|
import_react6.default.useEffect(() => {
|
|
27589
27606
|
if (isOpen && shouldScaleBackground) {
|
|
27590
|
-
if (timeoutIdRef.current)
|
|
27607
|
+
if (timeoutIdRef.current !== null) {
|
|
27608
|
+
clearTimeout(timeoutIdRef.current);
|
|
27609
|
+
timeoutIdRef.current = null;
|
|
27610
|
+
}
|
|
27591
27611
|
const wrapper = document.querySelector("[data-drawer-wrapper]");
|
|
27592
27612
|
if (!wrapper) return;
|
|
27593
27613
|
chain(
|
|
@@ -27616,6 +27636,7 @@ function useScaleBackground() {
|
|
|
27616
27636
|
} else {
|
|
27617
27637
|
document.body.style.removeProperty("background");
|
|
27618
27638
|
}
|
|
27639
|
+
timeoutIdRef.current = null;
|
|
27619
27640
|
}, TRANSITIONS.DURATION * 1e3);
|
|
27620
27641
|
};
|
|
27621
27642
|
}
|
|
@@ -27625,6 +27646,14 @@ function useScaleBackground() {
|
|
|
27625
27646
|
// src/use-position-fixed.ts
|
|
27626
27647
|
var import_react7 = __toESM(require_react());
|
|
27627
27648
|
var previousBodyPosition = null;
|
|
27649
|
+
var activeBodyPositionLocks = /* @__PURE__ */ new Set();
|
|
27650
|
+
var bodyPositionTimeoutId = null;
|
|
27651
|
+
function clearBodyPositionTimeout() {
|
|
27652
|
+
if (bodyPositionTimeoutId !== null) {
|
|
27653
|
+
window.clearTimeout(bodyPositionTimeoutId);
|
|
27654
|
+
bodyPositionTimeoutId = null;
|
|
27655
|
+
}
|
|
27656
|
+
}
|
|
27628
27657
|
function usePositionFixed({
|
|
27629
27658
|
isOpen,
|
|
27630
27659
|
modal,
|
|
@@ -27635,8 +27664,17 @@ function usePositionFixed({
|
|
|
27635
27664
|
}) {
|
|
27636
27665
|
const [activeUrl, setActiveUrl] = import_react7.default.useState(() => typeof window !== "undefined" ? window.location.href : "");
|
|
27637
27666
|
const scrollPos = import_react7.default.useRef(0);
|
|
27667
|
+
const lockIdRef = import_react7.default.useRef();
|
|
27668
|
+
if (!lockIdRef.current) {
|
|
27669
|
+
lockIdRef.current = /* @__PURE__ */ Symbol("drawer-body-position-lock");
|
|
27670
|
+
}
|
|
27638
27671
|
const setPositionFixed = import_react7.default.useCallback(() => {
|
|
27639
27672
|
if (!isSafari()) return;
|
|
27673
|
+
const lockId = lockIdRef.current;
|
|
27674
|
+
if (activeBodyPositionLocks.has(lockId)) {
|
|
27675
|
+
return;
|
|
27676
|
+
}
|
|
27677
|
+
activeBodyPositionLocks.add(lockId);
|
|
27640
27678
|
if (previousBodyPosition === null && isOpen && !noBodyStyles) {
|
|
27641
27679
|
previousBodyPosition = {
|
|
27642
27680
|
position: document.body.style.position,
|
|
@@ -27653,7 +27691,8 @@ function usePositionFixed({
|
|
|
27653
27691
|
right: "0px",
|
|
27654
27692
|
height: "auto"
|
|
27655
27693
|
});
|
|
27656
|
-
|
|
27694
|
+
clearBodyPositionTimeout();
|
|
27695
|
+
bodyPositionTimeoutId = window.setTimeout(
|
|
27657
27696
|
() => window.requestAnimationFrame(() => {
|
|
27658
27697
|
const bottomBarHeight = innerHeight - window.innerHeight;
|
|
27659
27698
|
if (bottomBarHeight && scrollPos.current >= innerHeight) {
|
|
@@ -27663,10 +27702,16 @@ function usePositionFixed({
|
|
|
27663
27702
|
300
|
|
27664
27703
|
);
|
|
27665
27704
|
}
|
|
27666
|
-
}, [isOpen]);
|
|
27705
|
+
}, [isOpen, noBodyStyles]);
|
|
27667
27706
|
const restorePositionSetting = import_react7.default.useCallback(() => {
|
|
27668
27707
|
if (!isSafari()) return;
|
|
27708
|
+
const lockId = lockIdRef.current;
|
|
27709
|
+
activeBodyPositionLocks.delete(lockId);
|
|
27710
|
+
if (activeBodyPositionLocks.size > 0) {
|
|
27711
|
+
return;
|
|
27712
|
+
}
|
|
27669
27713
|
if (previousBodyPosition !== null && !noBodyStyles) {
|
|
27714
|
+
clearBodyPositionTimeout();
|
|
27670
27715
|
const y = -parseInt(document.body.style.top, 10);
|
|
27671
27716
|
const x = -parseInt(document.body.style.left, 10);
|
|
27672
27717
|
Object.assign(document.body.style, previousBodyPosition);
|
|
@@ -27679,7 +27724,7 @@ function usePositionFixed({
|
|
|
27679
27724
|
});
|
|
27680
27725
|
previousBodyPosition = null;
|
|
27681
27726
|
}
|
|
27682
|
-
}, [activeUrl]);
|
|
27727
|
+
}, [activeUrl, noBodyStyles, setActiveUrl]);
|
|
27683
27728
|
import_react7.default.useEffect(() => {
|
|
27684
27729
|
function onScroll() {
|
|
27685
27730
|
scrollPos.current = window.scrollY;
|
|
@@ -27946,6 +27991,7 @@ function getDragPermission({
|
|
|
27946
27991
|
}
|
|
27947
27992
|
|
|
27948
27993
|
// src/react/components.tsx
|
|
27994
|
+
var useSafeLayoutEffect = typeof window === "undefined" ? import_react9.default.useEffect : import_react9.default.useLayoutEffect;
|
|
27949
27995
|
function Root2({
|
|
27950
27996
|
open: openProp,
|
|
27951
27997
|
onOpenChange,
|
|
@@ -27977,6 +28023,12 @@ function Root2({
|
|
|
27977
28023
|
container,
|
|
27978
28024
|
autoFocus = false
|
|
27979
28025
|
}) {
|
|
28026
|
+
const animationEndTimeoutRef = import_react9.default.useRef(null);
|
|
28027
|
+
const nonModalPointerEventsRafRef = import_react9.default.useRef(null);
|
|
28028
|
+
const shouldAnimateRafRef = import_react9.default.useRef(null);
|
|
28029
|
+
const snapPointsResetTimeoutRef = import_react9.default.useRef(null);
|
|
28030
|
+
const justReleasedTimeoutRef = import_react9.default.useRef(null);
|
|
28031
|
+
const touchEndHandlerRef = import_react9.default.useRef(null);
|
|
27980
28032
|
const [isOpen = false, setIsOpen] = useControllableState2({
|
|
27981
28033
|
defaultProp: defaultOpen,
|
|
27982
28034
|
prop: openProp,
|
|
@@ -27985,13 +28037,20 @@ function Root2({
|
|
|
27985
28037
|
if (!o && !nested) {
|
|
27986
28038
|
restorePositionSetting();
|
|
27987
28039
|
}
|
|
27988
|
-
|
|
28040
|
+
if (animationEndTimeoutRef.current !== null) {
|
|
28041
|
+
window.clearTimeout(animationEndTimeoutRef.current);
|
|
28042
|
+
}
|
|
28043
|
+
animationEndTimeoutRef.current = window.setTimeout(() => {
|
|
27989
28044
|
onAnimationEnd?.(o);
|
|
27990
28045
|
}, TRANSITIONS.DURATION * 1e3);
|
|
27991
28046
|
if (o && !modal) {
|
|
27992
28047
|
if (typeof window !== "undefined") {
|
|
27993
|
-
|
|
28048
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28049
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28050
|
+
}
|
|
28051
|
+
nonModalPointerEventsRafRef.current = window.requestAnimationFrame(() => {
|
|
27994
28052
|
document.body.style.pointerEvents = "auto";
|
|
28053
|
+
nonModalPointerEventsRafRef.current = null;
|
|
27995
28054
|
});
|
|
27996
28055
|
}
|
|
27997
28056
|
}
|
|
@@ -28076,18 +28135,22 @@ function Root2({
|
|
|
28076
28135
|
noBodyStyles,
|
|
28077
28136
|
autoFocus
|
|
28078
28137
|
});
|
|
28079
|
-
|
|
28138
|
+
useSafeLayoutEffect(() => {
|
|
28080
28139
|
if (!isOpen || !modal || autoFocus || typeof document === "undefined") {
|
|
28081
28140
|
return;
|
|
28082
28141
|
}
|
|
28083
28142
|
const activeElement = document.activeElement;
|
|
28084
|
-
if (!
|
|
28143
|
+
if (!activeElement || activeElement === document.body) {
|
|
28085
28144
|
return;
|
|
28086
28145
|
}
|
|
28087
|
-
|
|
28146
|
+
const activeElementNode = activeElement;
|
|
28147
|
+
if (drawerRef.current?.contains(activeElementNode) || activeElementNode.closest?.("[data-drawer]")) {
|
|
28088
28148
|
return;
|
|
28089
28149
|
}
|
|
28090
|
-
|
|
28150
|
+
if (typeof activeElementNode.blur !== "function") {
|
|
28151
|
+
return;
|
|
28152
|
+
}
|
|
28153
|
+
activeElementNode.blur();
|
|
28091
28154
|
}, [autoFocus, isOpen, modal]);
|
|
28092
28155
|
function getScale() {
|
|
28093
28156
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
@@ -28100,7 +28163,15 @@ function Root2({
|
|
|
28100
28163
|
setIsDragging(true);
|
|
28101
28164
|
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
28102
28165
|
if (isIOS()) {
|
|
28103
|
-
|
|
28166
|
+
if (touchEndHandlerRef.current) {
|
|
28167
|
+
window.removeEventListener("touchend", touchEndHandlerRef.current);
|
|
28168
|
+
}
|
|
28169
|
+
const handleTouchEnd = () => {
|
|
28170
|
+
isAllowedToDrag.current = false;
|
|
28171
|
+
touchEndHandlerRef.current = null;
|
|
28172
|
+
};
|
|
28173
|
+
touchEndHandlerRef.current = handleTouchEnd;
|
|
28174
|
+
window.addEventListener("touchend", handleTouchEnd, { once: true });
|
|
28104
28175
|
}
|
|
28105
28176
|
event.target.setPointerCapture(event.pointerId);
|
|
28106
28177
|
pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
|
|
@@ -28207,9 +28278,15 @@ function Root2({
|
|
|
28207
28278
|
}
|
|
28208
28279
|
}
|
|
28209
28280
|
import_react9.default.useEffect(() => {
|
|
28210
|
-
window.requestAnimationFrame(() => {
|
|
28281
|
+
shouldAnimateRafRef.current = window.requestAnimationFrame(() => {
|
|
28211
28282
|
shouldAnimate.current = true;
|
|
28212
28283
|
});
|
|
28284
|
+
return () => {
|
|
28285
|
+
if (shouldAnimateRafRef.current !== null) {
|
|
28286
|
+
window.cancelAnimationFrame(shouldAnimateRafRef.current);
|
|
28287
|
+
shouldAnimateRafRef.current = null;
|
|
28288
|
+
}
|
|
28289
|
+
};
|
|
28213
28290
|
}, []);
|
|
28214
28291
|
import_react9.default.useEffect(() => {
|
|
28215
28292
|
function onVisualViewportChange() {
|
|
@@ -28250,10 +28327,14 @@ function Root2({
|
|
|
28250
28327
|
if (!fromWithin) {
|
|
28251
28328
|
setIsOpen(false);
|
|
28252
28329
|
}
|
|
28253
|
-
|
|
28330
|
+
if (snapPointsResetTimeoutRef.current !== null) {
|
|
28331
|
+
window.clearTimeout(snapPointsResetTimeoutRef.current);
|
|
28332
|
+
}
|
|
28333
|
+
snapPointsResetTimeoutRef.current = window.setTimeout(() => {
|
|
28254
28334
|
if (snapPoints) {
|
|
28255
28335
|
setActiveSnapPoint(snapPoints[0]);
|
|
28256
28336
|
}
|
|
28337
|
+
snapPointsResetTimeoutRef.current = null;
|
|
28257
28338
|
}, TRANSITIONS.DURATION * 1e3);
|
|
28258
28339
|
}
|
|
28259
28340
|
function resetDrawer() {
|
|
@@ -28328,8 +28409,12 @@ function Root2({
|
|
|
28328
28409
|
});
|
|
28329
28410
|
if (releaseResult.shouldPreventFocus) {
|
|
28330
28411
|
setJustReleased(true);
|
|
28331
|
-
|
|
28412
|
+
if (justReleasedTimeoutRef.current !== null) {
|
|
28413
|
+
window.clearTimeout(justReleasedTimeoutRef.current);
|
|
28414
|
+
}
|
|
28415
|
+
justReleasedTimeoutRef.current = window.setTimeout(() => {
|
|
28332
28416
|
setJustReleased(false);
|
|
28417
|
+
justReleasedTimeoutRef.current = null;
|
|
28333
28418
|
}, 200);
|
|
28334
28419
|
}
|
|
28335
28420
|
if (releaseResult.action === "close") {
|
|
@@ -28403,11 +28488,44 @@ function Root2({
|
|
|
28403
28488
|
});
|
|
28404
28489
|
}
|
|
28405
28490
|
}
|
|
28491
|
+
import_react9.default.useEffect(() => {
|
|
28492
|
+
return () => {
|
|
28493
|
+
if (animationEndTimeoutRef.current !== null) {
|
|
28494
|
+
window.clearTimeout(animationEndTimeoutRef.current);
|
|
28495
|
+
}
|
|
28496
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28497
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28498
|
+
}
|
|
28499
|
+
if (snapPointsResetTimeoutRef.current !== null) {
|
|
28500
|
+
window.clearTimeout(snapPointsResetTimeoutRef.current);
|
|
28501
|
+
}
|
|
28502
|
+
if (justReleasedTimeoutRef.current !== null) {
|
|
28503
|
+
window.clearTimeout(justReleasedTimeoutRef.current);
|
|
28504
|
+
}
|
|
28505
|
+
if (nestedOpenChangeTimer.current) {
|
|
28506
|
+
window.clearTimeout(nestedOpenChangeTimer.current);
|
|
28507
|
+
}
|
|
28508
|
+
if (touchEndHandlerRef.current) {
|
|
28509
|
+
window.removeEventListener("touchend", touchEndHandlerRef.current);
|
|
28510
|
+
touchEndHandlerRef.current = null;
|
|
28511
|
+
}
|
|
28512
|
+
};
|
|
28513
|
+
}, []);
|
|
28406
28514
|
import_react9.default.useEffect(() => {
|
|
28407
28515
|
if (!modal) {
|
|
28408
|
-
|
|
28516
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28517
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28518
|
+
}
|
|
28519
|
+
nonModalPointerEventsRafRef.current = window.requestAnimationFrame(() => {
|
|
28409
28520
|
document.body.style.pointerEvents = "auto";
|
|
28521
|
+
nonModalPointerEventsRafRef.current = null;
|
|
28410
28522
|
});
|
|
28523
|
+
return () => {
|
|
28524
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28525
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28526
|
+
nonModalPointerEventsRafRef.current = null;
|
|
28527
|
+
}
|
|
28528
|
+
};
|
|
28411
28529
|
}
|
|
28412
28530
|
}, [modal]);
|
|
28413
28531
|
return /* @__PURE__ */ import_react9.default.createElement(
|
|
@@ -28514,15 +28632,23 @@ var Content2 = import_react9.default.forwardRef(function({ onPointerDownOutside,
|
|
|
28514
28632
|
const pointerStartRef = import_react9.default.useRef(null);
|
|
28515
28633
|
const lastKnownPointerEventRef = import_react9.default.useRef(null);
|
|
28516
28634
|
const wasBeyondThePointRef = import_react9.default.useRef(false);
|
|
28635
|
+
const delayedSnapPointsRafRef = import_react9.default.useRef(null);
|
|
28517
28636
|
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
28518
28637
|
useScaleBackground();
|
|
28519
28638
|
import_react9.default.useEffect(() => {
|
|
28520
28639
|
if (hasSnapPoints) {
|
|
28521
|
-
window.requestAnimationFrame(() => {
|
|
28640
|
+
delayedSnapPointsRafRef.current = window.requestAnimationFrame(() => {
|
|
28522
28641
|
setDelayedSnapPoints(true);
|
|
28642
|
+
delayedSnapPointsRafRef.current = null;
|
|
28523
28643
|
});
|
|
28524
28644
|
}
|
|
28525
|
-
|
|
28645
|
+
return () => {
|
|
28646
|
+
if (delayedSnapPointsRafRef.current !== null) {
|
|
28647
|
+
window.cancelAnimationFrame(delayedSnapPointsRafRef.current);
|
|
28648
|
+
delayedSnapPointsRafRef.current = null;
|
|
28649
|
+
}
|
|
28650
|
+
};
|
|
28651
|
+
}, [hasSnapPoints]);
|
|
28526
28652
|
function handleOnPointerUp(event) {
|
|
28527
28653
|
pointerStartRef.current = null;
|
|
28528
28654
|
wasBeyondThePointRef.current = false;
|
|
@@ -28631,13 +28757,14 @@ var Handle = import_react9.default.forwardRef(function({ preventCycle = false, c
|
|
|
28631
28757
|
onDrag
|
|
28632
28758
|
} = useDrawerContext();
|
|
28633
28759
|
const closeTimeoutIdRef = import_react9.default.useRef(null);
|
|
28760
|
+
const cycleTimeoutIdRef = import_react9.default.useRef(null);
|
|
28634
28761
|
const shouldCancelInteractionRef = import_react9.default.useRef(false);
|
|
28635
28762
|
function handleStartCycle() {
|
|
28636
28763
|
if (shouldCancelInteractionRef.current) {
|
|
28637
28764
|
handleCancelInteraction();
|
|
28638
28765
|
return;
|
|
28639
28766
|
}
|
|
28640
|
-
window.setTimeout(() => {
|
|
28767
|
+
cycleTimeoutIdRef.current = window.setTimeout(() => {
|
|
28641
28768
|
handleCycleSnapPoints();
|
|
28642
28769
|
}, DOUBLE_TAP_TIMEOUT);
|
|
28643
28770
|
}
|
|
@@ -28668,9 +28795,19 @@ var Handle = import_react9.default.forwardRef(function({ preventCycle = false, c
|
|
|
28668
28795
|
function handleCancelInteraction() {
|
|
28669
28796
|
if (closeTimeoutIdRef.current) {
|
|
28670
28797
|
window.clearTimeout(closeTimeoutIdRef.current);
|
|
28798
|
+
closeTimeoutIdRef.current = null;
|
|
28799
|
+
}
|
|
28800
|
+
if (cycleTimeoutIdRef.current) {
|
|
28801
|
+
window.clearTimeout(cycleTimeoutIdRef.current);
|
|
28802
|
+
cycleTimeoutIdRef.current = null;
|
|
28671
28803
|
}
|
|
28672
28804
|
shouldCancelInteractionRef.current = false;
|
|
28673
28805
|
}
|
|
28806
|
+
import_react9.default.useEffect(() => {
|
|
28807
|
+
return () => {
|
|
28808
|
+
handleCancelInteraction();
|
|
28809
|
+
};
|
|
28810
|
+
}, []);
|
|
28674
28811
|
return /* @__PURE__ */ import_react9.default.createElement(
|
|
28675
28812
|
"div",
|
|
28676
28813
|
{
|
|
@@ -28751,7 +28888,7 @@ var VISUALLY_HIDDEN_STYLE = {
|
|
|
28751
28888
|
whiteSpace: "nowrap",
|
|
28752
28889
|
border: 0
|
|
28753
28890
|
};
|
|
28754
|
-
var
|
|
28891
|
+
var useSafeLayoutEffect2 = typeof window === "undefined" ? import_react10.default.useEffect : import_react10.default.useLayoutEffect;
|
|
28755
28892
|
function toReactDrawerProps(options, open, onOpenChange, internalOnDragChange, internalOnReleaseChange) {
|
|
28756
28893
|
const { id: _id, parentId: _parentId, onDragChange, onReleaseChange, ...drawerOptions } = options;
|
|
28757
28894
|
const baseProps = {
|
|
@@ -28785,7 +28922,7 @@ function VanillaNode({
|
|
|
28785
28922
|
dataAttribute
|
|
28786
28923
|
}) {
|
|
28787
28924
|
const ref = import_react10.default.useRef(null);
|
|
28788
|
-
|
|
28925
|
+
useSafeLayoutEffect2(() => {
|
|
28789
28926
|
const element = ref.current;
|
|
28790
28927
|
if (!element) {
|
|
28791
28928
|
return;
|
|
@@ -28991,6 +29128,7 @@ function openAncestorChain(parentId) {
|
|
|
28991
29128
|
openAncestorChain(nextParentId);
|
|
28992
29129
|
}
|
|
28993
29130
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
29131
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
28994
29132
|
parentRuntime.controller.setOpen(true);
|
|
28995
29133
|
notifyOpenStateChange(parentRuntime, true);
|
|
28996
29134
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -29010,6 +29148,7 @@ function bindTriggerElement(runtime) {
|
|
|
29010
29148
|
}
|
|
29011
29149
|
const triggerElement = runtime.options.triggerElement;
|
|
29012
29150
|
const handleClick = () => {
|
|
29151
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29013
29152
|
runtime.controller.setOpen(true);
|
|
29014
29153
|
renderVanillaDrawer(runtime.id);
|
|
29015
29154
|
};
|
|
@@ -29045,6 +29184,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
29045
29184
|
function canUseDOM3() {
|
|
29046
29185
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
29047
29186
|
}
|
|
29187
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
29188
|
+
if (!canUseDOM3() || options.modal === false || options.autoFocus) {
|
|
29189
|
+
return;
|
|
29190
|
+
}
|
|
29191
|
+
const activeElement = document.activeElement;
|
|
29192
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== "function") {
|
|
29193
|
+
return;
|
|
29194
|
+
}
|
|
29195
|
+
activeElement.blur();
|
|
29196
|
+
}
|
|
29048
29197
|
function getRuntimeDrawerElement(runtime) {
|
|
29049
29198
|
if (!runtime.element) {
|
|
29050
29199
|
return null;
|
|
@@ -29098,6 +29247,9 @@ function renderVanillaDrawer(id) {
|
|
|
29098
29247
|
open: snapshot.state.isOpen,
|
|
29099
29248
|
onOpenChange: (open) => {
|
|
29100
29249
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29250
|
+
if (open) {
|
|
29251
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29252
|
+
}
|
|
29101
29253
|
runtime.controller.setOpen(open);
|
|
29102
29254
|
if (previousOpen !== open) {
|
|
29103
29255
|
notifyOpenStateChange(runtime, open);
|
|
@@ -29144,6 +29296,9 @@ function buildVanillaController(id) {
|
|
|
29144
29296
|
if (!runtime) {
|
|
29145
29297
|
return createDrawer({ id, open }).getSnapshot();
|
|
29146
29298
|
}
|
|
29299
|
+
if (open) {
|
|
29300
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29301
|
+
}
|
|
29147
29302
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29148
29303
|
const snapshot = runtime.controller.setOpen(open);
|
|
29149
29304
|
if (previousOpen !== open) {
|
|
@@ -29214,6 +29369,9 @@ function createDrawer(options = {}) {
|
|
|
29214
29369
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
29215
29370
|
}
|
|
29216
29371
|
}
|
|
29372
|
+
if (nextOptions.open && !previousOpen) {
|
|
29373
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
29374
|
+
}
|
|
29217
29375
|
renderVanillaDrawer(id);
|
|
29218
29376
|
if (nextOptions.parentId && nextOptions.open) {
|
|
29219
29377
|
openAncestorChain(nextOptions.parentId);
|