@samline/drawer 2.0.3 → 2.0.5
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/dist/browser/{components-client-CZSt5H60.mjs → components-client-BnT3P9Or.mjs} +164 -28
- package/dist/{svelte/components-client-DXeaMmfk.js → browser/components-client-D4tSixHM.js} +163 -27
- package/dist/browser/index.cjs +211 -34
- package/dist/browser/index.js +211 -34
- package/dist/browser/index.mjs +211 -34
- package/dist/{svelte/components-client-CZSt5H60.mjs → components-client-BnT3P9Or.mjs} +164 -28
- package/dist/{browser/components-client-DXeaMmfk.js → components-client-D4tSixHM.js} +163 -27
- package/dist/index.js +211 -34
- package/dist/index.mjs +211 -34
- package/dist/react/index.js +229 -37
- package/dist/react/index.mjs +230 -38
- package/dist/{components-client-CZSt5H60.mjs → svelte/components-client-BnT3P9Or.mjs} +164 -28
- package/dist/{vue/components-client-DXeaMmfk.js → svelte/components-client-D4tSixHM.js} +163 -27
- package/dist/svelte/index.js +211 -34
- package/dist/svelte/index.mjs +211 -34
- package/dist/vue/{components-client-DZfql3-W.mjs → components-client-CvNPHVej.mjs} +164 -28
- package/dist/{components-client-DXeaMmfk.js → vue/components-client-D4tSixHM.js} +163 -27
- package/dist/vue/index.js +211 -34
- package/dist/vue/index.mjs +211 -34
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -1106,7 +1106,7 @@ var __samlineDrawerBrowser = (() => {
|
|
|
1106
1106
|
var dispatcher = resolveDispatcher();
|
|
1107
1107
|
return dispatcher.useReducer(reducer, initialArg, init);
|
|
1108
1108
|
}
|
|
1109
|
-
function
|
|
1109
|
+
function useRef11(initialValue) {
|
|
1110
1110
|
var dispatcher = resolveDispatcher();
|
|
1111
1111
|
return dispatcher.useRef(initialValue);
|
|
1112
1112
|
}
|
|
@@ -1900,7 +1900,7 @@ var __samlineDrawerBrowser = (() => {
|
|
|
1900
1900
|
exports.useLayoutEffect = useLayoutEffect5;
|
|
1901
1901
|
exports.useMemo = useMemo6;
|
|
1902
1902
|
exports.useReducer = useReducer3;
|
|
1903
|
-
exports.useRef =
|
|
1903
|
+
exports.useRef = useRef11;
|
|
1904
1904
|
exports.useState = useState10;
|
|
1905
1905
|
exports.useSyncExternalStore = useSyncExternalStore;
|
|
1906
1906
|
exports.useTransition = useTransition;
|
|
@@ -26988,25 +26988,34 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
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 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
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 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
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 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
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 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
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 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
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 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
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 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
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;
|
|
@@ -27975,6 +28020,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
27975
28020
|
container,
|
|
27976
28021
|
autoFocus = false
|
|
27977
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);
|
|
27978
28029
|
const [isOpen = false, setIsOpen] = useControllableState2({
|
|
27979
28030
|
defaultProp: defaultOpen,
|
|
27980
28031
|
prop: openProp,
|
|
@@ -27983,13 +28034,20 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
27983
28034
|
if (!o && !nested) {
|
|
27984
28035
|
restorePositionSetting();
|
|
27985
28036
|
}
|
|
27986
|
-
|
|
28037
|
+
if (animationEndTimeoutRef.current !== null) {
|
|
28038
|
+
window.clearTimeout(animationEndTimeoutRef.current);
|
|
28039
|
+
}
|
|
28040
|
+
animationEndTimeoutRef.current = window.setTimeout(() => {
|
|
27987
28041
|
onAnimationEnd?.(o);
|
|
27988
28042
|
}, TRANSITIONS.DURATION * 1e3);
|
|
27989
28043
|
if (o && !modal) {
|
|
27990
28044
|
if (typeof window !== "undefined") {
|
|
27991
|
-
|
|
28045
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28046
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28047
|
+
}
|
|
28048
|
+
nonModalPointerEventsRafRef.current = window.requestAnimationFrame(() => {
|
|
27992
28049
|
document.body.style.pointerEvents = "auto";
|
|
28050
|
+
nonModalPointerEventsRafRef.current = null;
|
|
27993
28051
|
});
|
|
27994
28052
|
}
|
|
27995
28053
|
}
|
|
@@ -28098,7 +28156,15 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28098
28156
|
setIsDragging(true);
|
|
28099
28157
|
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
28100
28158
|
if (isIOS()) {
|
|
28101
|
-
|
|
28159
|
+
if (touchEndHandlerRef.current) {
|
|
28160
|
+
window.removeEventListener("touchend", touchEndHandlerRef.current);
|
|
28161
|
+
}
|
|
28162
|
+
const handleTouchEnd = () => {
|
|
28163
|
+
isAllowedToDrag.current = false;
|
|
28164
|
+
touchEndHandlerRef.current = null;
|
|
28165
|
+
};
|
|
28166
|
+
touchEndHandlerRef.current = handleTouchEnd;
|
|
28167
|
+
window.addEventListener("touchend", handleTouchEnd, { once: true });
|
|
28102
28168
|
}
|
|
28103
28169
|
event.target.setPointerCapture(event.pointerId);
|
|
28104
28170
|
pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
|
|
@@ -28205,9 +28271,15 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28205
28271
|
}
|
|
28206
28272
|
}
|
|
28207
28273
|
import_react9.default.useEffect(() => {
|
|
28208
|
-
window.requestAnimationFrame(() => {
|
|
28274
|
+
shouldAnimateRafRef.current = window.requestAnimationFrame(() => {
|
|
28209
28275
|
shouldAnimate.current = true;
|
|
28210
28276
|
});
|
|
28277
|
+
return () => {
|
|
28278
|
+
if (shouldAnimateRafRef.current !== null) {
|
|
28279
|
+
window.cancelAnimationFrame(shouldAnimateRafRef.current);
|
|
28280
|
+
shouldAnimateRafRef.current = null;
|
|
28281
|
+
}
|
|
28282
|
+
};
|
|
28211
28283
|
}, []);
|
|
28212
28284
|
import_react9.default.useEffect(() => {
|
|
28213
28285
|
function onVisualViewportChange() {
|
|
@@ -28248,10 +28320,14 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28248
28320
|
if (!fromWithin) {
|
|
28249
28321
|
setIsOpen(false);
|
|
28250
28322
|
}
|
|
28251
|
-
|
|
28323
|
+
if (snapPointsResetTimeoutRef.current !== null) {
|
|
28324
|
+
window.clearTimeout(snapPointsResetTimeoutRef.current);
|
|
28325
|
+
}
|
|
28326
|
+
snapPointsResetTimeoutRef.current = window.setTimeout(() => {
|
|
28252
28327
|
if (snapPoints) {
|
|
28253
28328
|
setActiveSnapPoint(snapPoints[0]);
|
|
28254
28329
|
}
|
|
28330
|
+
snapPointsResetTimeoutRef.current = null;
|
|
28255
28331
|
}, TRANSITIONS.DURATION * 1e3);
|
|
28256
28332
|
}
|
|
28257
28333
|
function resetDrawer() {
|
|
@@ -28326,8 +28402,12 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28326
28402
|
});
|
|
28327
28403
|
if (releaseResult.shouldPreventFocus) {
|
|
28328
28404
|
setJustReleased(true);
|
|
28329
|
-
|
|
28405
|
+
if (justReleasedTimeoutRef.current !== null) {
|
|
28406
|
+
window.clearTimeout(justReleasedTimeoutRef.current);
|
|
28407
|
+
}
|
|
28408
|
+
justReleasedTimeoutRef.current = window.setTimeout(() => {
|
|
28330
28409
|
setJustReleased(false);
|
|
28410
|
+
justReleasedTimeoutRef.current = null;
|
|
28331
28411
|
}, 200);
|
|
28332
28412
|
}
|
|
28333
28413
|
if (releaseResult.action === "close") {
|
|
@@ -28401,11 +28481,44 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28401
28481
|
});
|
|
28402
28482
|
}
|
|
28403
28483
|
}
|
|
28484
|
+
import_react9.default.useEffect(() => {
|
|
28485
|
+
return () => {
|
|
28486
|
+
if (animationEndTimeoutRef.current !== null) {
|
|
28487
|
+
window.clearTimeout(animationEndTimeoutRef.current);
|
|
28488
|
+
}
|
|
28489
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28490
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28491
|
+
}
|
|
28492
|
+
if (snapPointsResetTimeoutRef.current !== null) {
|
|
28493
|
+
window.clearTimeout(snapPointsResetTimeoutRef.current);
|
|
28494
|
+
}
|
|
28495
|
+
if (justReleasedTimeoutRef.current !== null) {
|
|
28496
|
+
window.clearTimeout(justReleasedTimeoutRef.current);
|
|
28497
|
+
}
|
|
28498
|
+
if (nestedOpenChangeTimer.current) {
|
|
28499
|
+
window.clearTimeout(nestedOpenChangeTimer.current);
|
|
28500
|
+
}
|
|
28501
|
+
if (touchEndHandlerRef.current) {
|
|
28502
|
+
window.removeEventListener("touchend", touchEndHandlerRef.current);
|
|
28503
|
+
touchEndHandlerRef.current = null;
|
|
28504
|
+
}
|
|
28505
|
+
};
|
|
28506
|
+
}, []);
|
|
28404
28507
|
import_react9.default.useEffect(() => {
|
|
28405
28508
|
if (!modal) {
|
|
28406
|
-
|
|
28509
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28510
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28511
|
+
}
|
|
28512
|
+
nonModalPointerEventsRafRef.current = window.requestAnimationFrame(() => {
|
|
28407
28513
|
document.body.style.pointerEvents = "auto";
|
|
28514
|
+
nonModalPointerEventsRafRef.current = null;
|
|
28408
28515
|
});
|
|
28516
|
+
return () => {
|
|
28517
|
+
if (nonModalPointerEventsRafRef.current !== null) {
|
|
28518
|
+
window.cancelAnimationFrame(nonModalPointerEventsRafRef.current);
|
|
28519
|
+
nonModalPointerEventsRafRef.current = null;
|
|
28520
|
+
}
|
|
28521
|
+
};
|
|
28409
28522
|
}
|
|
28410
28523
|
}, [modal]);
|
|
28411
28524
|
return /* @__PURE__ */ import_react9.default.createElement(
|
|
@@ -28512,15 +28625,23 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28512
28625
|
const pointerStartRef = import_react9.default.useRef(null);
|
|
28513
28626
|
const lastKnownPointerEventRef = import_react9.default.useRef(null);
|
|
28514
28627
|
const wasBeyondThePointRef = import_react9.default.useRef(false);
|
|
28628
|
+
const delayedSnapPointsRafRef = import_react9.default.useRef(null);
|
|
28515
28629
|
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
28516
28630
|
useScaleBackground();
|
|
28517
28631
|
import_react9.default.useEffect(() => {
|
|
28518
28632
|
if (hasSnapPoints) {
|
|
28519
|
-
window.requestAnimationFrame(() => {
|
|
28633
|
+
delayedSnapPointsRafRef.current = window.requestAnimationFrame(() => {
|
|
28520
28634
|
setDelayedSnapPoints(true);
|
|
28635
|
+
delayedSnapPointsRafRef.current = null;
|
|
28521
28636
|
});
|
|
28522
28637
|
}
|
|
28523
|
-
|
|
28638
|
+
return () => {
|
|
28639
|
+
if (delayedSnapPointsRafRef.current !== null) {
|
|
28640
|
+
window.cancelAnimationFrame(delayedSnapPointsRafRef.current);
|
|
28641
|
+
delayedSnapPointsRafRef.current = null;
|
|
28642
|
+
}
|
|
28643
|
+
};
|
|
28644
|
+
}, [hasSnapPoints]);
|
|
28524
28645
|
function handleOnPointerUp(event) {
|
|
28525
28646
|
pointerStartRef.current = null;
|
|
28526
28647
|
wasBeyondThePointRef.current = false;
|
|
@@ -28629,13 +28750,14 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28629
28750
|
onDrag
|
|
28630
28751
|
} = useDrawerContext();
|
|
28631
28752
|
const closeTimeoutIdRef = import_react9.default.useRef(null);
|
|
28753
|
+
const cycleTimeoutIdRef = import_react9.default.useRef(null);
|
|
28632
28754
|
const shouldCancelInteractionRef = import_react9.default.useRef(false);
|
|
28633
28755
|
function handleStartCycle() {
|
|
28634
28756
|
if (shouldCancelInteractionRef.current) {
|
|
28635
28757
|
handleCancelInteraction();
|
|
28636
28758
|
return;
|
|
28637
28759
|
}
|
|
28638
|
-
window.setTimeout(() => {
|
|
28760
|
+
cycleTimeoutIdRef.current = window.setTimeout(() => {
|
|
28639
28761
|
handleCycleSnapPoints();
|
|
28640
28762
|
}, DOUBLE_TAP_TIMEOUT);
|
|
28641
28763
|
}
|
|
@@ -28666,9 +28788,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28666
28788
|
function handleCancelInteraction() {
|
|
28667
28789
|
if (closeTimeoutIdRef.current) {
|
|
28668
28790
|
window.clearTimeout(closeTimeoutIdRef.current);
|
|
28791
|
+
closeTimeoutIdRef.current = null;
|
|
28792
|
+
}
|
|
28793
|
+
if (cycleTimeoutIdRef.current) {
|
|
28794
|
+
window.clearTimeout(cycleTimeoutIdRef.current);
|
|
28795
|
+
cycleTimeoutIdRef.current = null;
|
|
28669
28796
|
}
|
|
28670
28797
|
shouldCancelInteractionRef.current = false;
|
|
28671
28798
|
}
|
|
28799
|
+
import_react9.default.useEffect(() => {
|
|
28800
|
+
return () => {
|
|
28801
|
+
handleCancelInteraction();
|
|
28802
|
+
};
|
|
28803
|
+
}, []);
|
|
28672
28804
|
return /* @__PURE__ */ import_react9.default.createElement(
|
|
28673
28805
|
"div",
|
|
28674
28806
|
{
|
|
@@ -28778,11 +28910,16 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28778
28910
|
fadeFromIndex: void 0
|
|
28779
28911
|
};
|
|
28780
28912
|
}
|
|
28781
|
-
function VanillaNode({
|
|
28913
|
+
function VanillaNode({
|
|
28914
|
+
value,
|
|
28915
|
+
dataAttribute
|
|
28916
|
+
}) {
|
|
28782
28917
|
const ref = import_react10.default.useRef(null);
|
|
28783
28918
|
useSafeLayoutEffect(() => {
|
|
28784
28919
|
const element = ref.current;
|
|
28785
|
-
if (!element)
|
|
28920
|
+
if (!element) {
|
|
28921
|
+
return;
|
|
28922
|
+
}
|
|
28786
28923
|
element.innerHTML = "";
|
|
28787
28924
|
if (value instanceof HTMLElement) {
|
|
28788
28925
|
element.appendChild(value);
|
|
@@ -28803,6 +28940,19 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28803
28940
|
}
|
|
28804
28941
|
return /* @__PURE__ */ import_react10.default.createElement("div", { ...dataAttribute ? { [dataAttribute]: "" } : {}, ref });
|
|
28805
28942
|
}
|
|
28943
|
+
function readAccessibleTextFromRoot(root, elementId) {
|
|
28944
|
+
if (!root || !elementId) {
|
|
28945
|
+
return void 0;
|
|
28946
|
+
}
|
|
28947
|
+
const elements = Array.from(root.querySelectorAll("[id]"));
|
|
28948
|
+
for (const element of elements) {
|
|
28949
|
+
if (element instanceof HTMLElement && element.id === elementId) {
|
|
28950
|
+
const value = element.textContent?.trim();
|
|
28951
|
+
return value ? value : void 0;
|
|
28952
|
+
}
|
|
28953
|
+
}
|
|
28954
|
+
return root.id === elementId ? root.textContent?.trim() || void 0 : void 0;
|
|
28955
|
+
}
|
|
28806
28956
|
function VanillaDrawerRenderer({
|
|
28807
28957
|
options,
|
|
28808
28958
|
open,
|
|
@@ -28831,16 +28981,43 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
|
|
|
28831
28981
|
const rootProps = toReactDrawerProps(drawerOptions, open, onOpenChange, onDragChange, onReleaseChange);
|
|
28832
28982
|
const shouldRenderHandle = Boolean(drawerOptions.handleOnly || showHandle);
|
|
28833
28983
|
const shouldRenderVanillaContent = title != null || description != null || content != null;
|
|
28984
|
+
const resolvedContent = import_react10.default.useMemo(() => {
|
|
28985
|
+
if (content instanceof HTMLElement) {
|
|
28986
|
+
return {
|
|
28987
|
+
value: content,
|
|
28988
|
+
proxyTitle: title == null ? readAccessibleTextFromRoot(content, ariaLabelledBy) : void 0,
|
|
28989
|
+
proxyDescription: description == null ? readAccessibleTextFromRoot(content, ariaDescribedBy) : void 0
|
|
28990
|
+
};
|
|
28991
|
+
}
|
|
28992
|
+
if (typeof content === "function") {
|
|
28993
|
+
const result = content();
|
|
28994
|
+
return {
|
|
28995
|
+
value: result,
|
|
28996
|
+
proxyTitle: title == null && result instanceof HTMLElement ? readAccessibleTextFromRoot(result, ariaLabelledBy) : void 0,
|
|
28997
|
+
proxyDescription: description == null && result instanceof HTMLElement ? readAccessibleTextFromRoot(result, ariaDescribedBy) : void 0
|
|
28998
|
+
};
|
|
28999
|
+
}
|
|
29000
|
+
return {
|
|
29001
|
+
value: content,
|
|
29002
|
+
proxyTitle: void 0,
|
|
29003
|
+
proxyDescription: void 0
|
|
29004
|
+
};
|
|
29005
|
+
}, [ariaDescribedBy, ariaLabelledBy, content, description, title]);
|
|
29006
|
+
const proxyTitle = resolvedContent.proxyTitle ?? (title == null ? ariaLabel : void 0);
|
|
29007
|
+
const proxyDescription = resolvedContent.proxyDescription;
|
|
29008
|
+
const contentAriaLabel = title == null && !proxyTitle ? ariaLabel : void 0;
|
|
29009
|
+
const contentAriaLabelledBy = title == null && !proxyTitle ? ariaLabelledBy : void 0;
|
|
29010
|
+
const contentAriaDescribedBy = description == null && !proxyDescription ? ariaDescribedBy : void 0;
|
|
28834
29011
|
return /* @__PURE__ */ import_react10.default.createElement(Drawer.Root, { ...rootProps }, triggerText ? /* @__PURE__ */ import_react10.default.createElement(Drawer.Trigger, { asChild: true }, /* @__PURE__ */ import_react10.default.createElement("button", { type: "button", "data-drawer-vanilla-trigger": "" }, triggerText)) : null, /* @__PURE__ */ import_react10.default.createElement(Drawer.Portal, null, /* @__PURE__ */ import_react10.default.createElement(Drawer.Overlay, { className: overlayClassName }), /* @__PURE__ */ import_react10.default.createElement(
|
|
28835
29012
|
Drawer.Content,
|
|
28836
29013
|
{
|
|
28837
29014
|
className: contentClassName,
|
|
28838
|
-
"aria-label":
|
|
28839
|
-
"aria-labelledby":
|
|
28840
|
-
"aria-describedby":
|
|
29015
|
+
"aria-label": contentAriaLabel,
|
|
29016
|
+
"aria-labelledby": contentAriaLabelledBy,
|
|
29017
|
+
"aria-describedby": contentAriaDescribedBy
|
|
28841
29018
|
},
|
|
28842
29019
|
shouldRenderHandle ? /* @__PURE__ */ import_react10.default.createElement(Drawer.Handle, { className: handleClassName }) : null,
|
|
28843
|
-
shouldRenderVanillaContent ? /* @__PURE__ */ import_react10.default.createElement("div", { "data-drawer-vanilla-node": "" }, title != null ? /* @__PURE__ */ import_react10.default.createElement(Drawer.Title, { style: titleVisuallyHidden ? VISUALLY_HIDDEN_STYLE : void 0 }, /* @__PURE__ */ import_react10.default.createElement(VanillaNode, { value: title })) : null, description != null ? /* @__PURE__ */ import_react10.default.createElement(Drawer.Description, { style: descriptionVisuallyHidden ? VISUALLY_HIDDEN_STYLE : void 0 }, /* @__PURE__ */ import_react10.default.createElement(VanillaNode, { value: description })) : null, /* @__PURE__ */ import_react10.default.createElement(
|
|
29020
|
+
shouldRenderVanillaContent ? /* @__PURE__ */ import_react10.default.createElement("div", { "data-drawer-vanilla-node": "" }, proxyTitle ? /* @__PURE__ */ import_react10.default.createElement(Drawer.Title, { style: VISUALLY_HIDDEN_STYLE }, proxyTitle) : null, title != null ? /* @__PURE__ */ import_react10.default.createElement(Drawer.Title, { style: titleVisuallyHidden ? VISUALLY_HIDDEN_STYLE : void 0 }, /* @__PURE__ */ import_react10.default.createElement(VanillaNode, { value: title })) : null, proxyDescription ? /* @__PURE__ */ import_react10.default.createElement(Drawer.Description, { style: VISUALLY_HIDDEN_STYLE }, proxyDescription) : null, description != null ? /* @__PURE__ */ import_react10.default.createElement(Drawer.Description, { style: descriptionVisuallyHidden ? VISUALLY_HIDDEN_STYLE : void 0 }, /* @__PURE__ */ import_react10.default.createElement(VanillaNode, { value: description })) : null, /* @__PURE__ */ import_react10.default.createElement("div", { "data-drawer-vanilla-body": "" }, /* @__PURE__ */ import_react10.default.createElement(VanillaNode, { value: resolvedContent.value }))) : null
|
|
28844
29021
|
)));
|
|
28845
29022
|
}
|
|
28846
29023
|
|