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