@nexub/react 8.6.0 → 8.7.0
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/accessibility.json +1 -1
- package/dist/components/Combobox/Combobox.js +1 -2
- package/dist/vendor/vaul.js +1 -1494
- package/package.json +6 -6
package/dist/vendor/vaul.js
CHANGED
|
@@ -1,1495 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use client";
|
|
3
|
-
|
|
4
|
-
// ../../node_modules/.pnpm/vaul@1.1.2_@types+react-dom@19.3.0_@types+react@19.3.0__@types+react@19.3.0_react-dom@19.3.1_react@19.3.1__react@19.3.1/node_modules/vaul/dist/index.mjs
|
|
5
|
-
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
6
|
-
import * as React from "react";
|
|
7
|
-
import React__default, { useLayoutEffect, useEffect, useMemo } from "react";
|
|
8
|
-
var DrawerContext = React__default.createContext({
|
|
9
|
-
drawerRef: {
|
|
10
|
-
current: null
|
|
11
|
-
},
|
|
12
|
-
overlayRef: {
|
|
13
|
-
current: null
|
|
14
|
-
},
|
|
15
|
-
onPress: () => {
|
|
16
|
-
},
|
|
17
|
-
onRelease: () => {
|
|
18
|
-
},
|
|
19
|
-
onDrag: () => {
|
|
20
|
-
},
|
|
21
|
-
onNestedDrag: () => {
|
|
22
|
-
},
|
|
23
|
-
onNestedOpenChange: () => {
|
|
24
|
-
},
|
|
25
|
-
onNestedRelease: () => {
|
|
26
|
-
},
|
|
27
|
-
openProp: void 0,
|
|
28
|
-
dismissible: false,
|
|
29
|
-
isOpen: false,
|
|
30
|
-
isDragging: false,
|
|
31
|
-
keyboardIsOpen: {
|
|
32
|
-
current: false
|
|
33
|
-
},
|
|
34
|
-
snapPointsOffset: null,
|
|
35
|
-
snapPoints: null,
|
|
36
|
-
handleOnly: false,
|
|
37
|
-
modal: false,
|
|
38
|
-
shouldFade: false,
|
|
39
|
-
activeSnapPoint: null,
|
|
40
|
-
onOpenChange: () => {
|
|
41
|
-
},
|
|
42
|
-
setActiveSnapPoint: () => {
|
|
43
|
-
},
|
|
44
|
-
closeDrawer: () => {
|
|
45
|
-
},
|
|
46
|
-
direction: "bottom",
|
|
47
|
-
shouldAnimate: {
|
|
48
|
-
current: true
|
|
49
|
-
},
|
|
50
|
-
shouldScaleBackground: false,
|
|
51
|
-
setBackgroundColorOnScale: true,
|
|
52
|
-
noBodyStyles: false,
|
|
53
|
-
container: null,
|
|
54
|
-
autoFocus: false
|
|
55
|
-
});
|
|
56
|
-
var useDrawerContext = () => {
|
|
57
|
-
const context = React__default.useContext(DrawerContext);
|
|
58
|
-
if (!context) {
|
|
59
|
-
throw new Error("useDrawerContext must be used within a Drawer.Root");
|
|
60
|
-
}
|
|
61
|
-
return context;
|
|
62
|
-
};
|
|
63
|
-
function isMobileFirefox() {
|
|
64
|
-
const userAgent = navigator.userAgent;
|
|
65
|
-
return typeof window !== "undefined" && (/Firefox/.test(userAgent) && /Mobile/.test(userAgent) || // Android Firefox
|
|
66
|
-
/FxiOS/.test(userAgent));
|
|
67
|
-
}
|
|
68
|
-
function isMac() {
|
|
69
|
-
return testPlatform(/^Mac/);
|
|
70
|
-
}
|
|
71
|
-
function isIPhone() {
|
|
72
|
-
return testPlatform(/^iPhone/);
|
|
73
|
-
}
|
|
74
|
-
function isSafari() {
|
|
75
|
-
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
76
|
-
}
|
|
77
|
-
function isIPad() {
|
|
78
|
-
return testPlatform(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
79
|
-
isMac() && navigator.maxTouchPoints > 1;
|
|
80
|
-
}
|
|
81
|
-
function isIOS() {
|
|
82
|
-
return isIPhone() || isIPad();
|
|
83
|
-
}
|
|
84
|
-
function testPlatform(re) {
|
|
85
|
-
return typeof window !== "undefined" && window.navigator != null ? re.test(window.navigator.platform) : void 0;
|
|
86
|
-
}
|
|
87
|
-
var KEYBOARD_BUFFER = 24;
|
|
88
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
89
|
-
function chain$1(...callbacks) {
|
|
90
|
-
return (...args) => {
|
|
91
|
-
for (let callback of callbacks) {
|
|
92
|
-
if (typeof callback === "function") {
|
|
93
|
-
callback(...args);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
var visualViewport = typeof document !== "undefined" && window.visualViewport;
|
|
99
|
-
function isScrollable(node) {
|
|
100
|
-
let style = window.getComputedStyle(node);
|
|
101
|
-
return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
|
|
102
|
-
}
|
|
103
|
-
function getScrollParent(node) {
|
|
104
|
-
if (isScrollable(node)) {
|
|
105
|
-
node = node.parentElement;
|
|
106
|
-
}
|
|
107
|
-
while (node && !isScrollable(node)) {
|
|
108
|
-
node = node.parentElement;
|
|
109
|
-
}
|
|
110
|
-
return node || document.scrollingElement || document.documentElement;
|
|
111
|
-
}
|
|
112
|
-
var nonTextInputTypes = /* @__PURE__ */ new Set([
|
|
113
|
-
"checkbox",
|
|
114
|
-
"radio",
|
|
115
|
-
"range",
|
|
116
|
-
"color",
|
|
117
|
-
"file",
|
|
118
|
-
"image",
|
|
119
|
-
"button",
|
|
120
|
-
"submit",
|
|
121
|
-
"reset"
|
|
122
|
-
]);
|
|
123
|
-
var preventScrollCount = 0;
|
|
124
|
-
var restore;
|
|
125
|
-
function usePreventScroll(options = {}) {
|
|
126
|
-
let { isDisabled } = options;
|
|
127
|
-
useIsomorphicLayoutEffect(() => {
|
|
128
|
-
if (isDisabled) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
preventScrollCount++;
|
|
132
|
-
if (preventScrollCount === 1) {
|
|
133
|
-
if (isIOS()) {
|
|
134
|
-
restore = preventScrollMobileSafari();
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return () => {
|
|
138
|
-
preventScrollCount--;
|
|
139
|
-
if (preventScrollCount === 0) {
|
|
140
|
-
restore == null ? void 0 : restore();
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
}, [
|
|
144
|
-
isDisabled
|
|
145
|
-
]);
|
|
146
|
-
}
|
|
147
|
-
function preventScrollMobileSafari() {
|
|
148
|
-
let scrollable;
|
|
149
|
-
let lastY = 0;
|
|
150
|
-
let onTouchStart = (e) => {
|
|
151
|
-
scrollable = getScrollParent(e.target);
|
|
152
|
-
if (scrollable === document.documentElement && scrollable === document.body) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
lastY = e.changedTouches[0].pageY;
|
|
156
|
-
};
|
|
157
|
-
let onTouchMove = (e) => {
|
|
158
|
-
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
|
|
159
|
-
e.preventDefault();
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
let y = e.changedTouches[0].pageY;
|
|
163
|
-
let scrollTop = scrollable.scrollTop;
|
|
164
|
-
let bottom = scrollable.scrollHeight - scrollable.clientHeight;
|
|
165
|
-
if (bottom === 0) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) {
|
|
169
|
-
e.preventDefault();
|
|
170
|
-
}
|
|
171
|
-
lastY = y;
|
|
172
|
-
};
|
|
173
|
-
let onTouchEnd = (e) => {
|
|
174
|
-
let target = e.target;
|
|
175
|
-
if (isInput(target) && target !== document.activeElement) {
|
|
176
|
-
e.preventDefault();
|
|
177
|
-
target.style.transform = "translateY(-2000px)";
|
|
178
|
-
target.focus();
|
|
179
|
-
requestAnimationFrame(() => {
|
|
180
|
-
target.style.transform = "";
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
let onFocus = (e) => {
|
|
185
|
-
let target = e.target;
|
|
186
|
-
if (isInput(target)) {
|
|
187
|
-
target.style.transform = "translateY(-2000px)";
|
|
188
|
-
requestAnimationFrame(() => {
|
|
189
|
-
target.style.transform = "";
|
|
190
|
-
if (visualViewport) {
|
|
191
|
-
if (visualViewport.height < window.innerHeight) {
|
|
192
|
-
requestAnimationFrame(() => {
|
|
193
|
-
scrollIntoView(target);
|
|
194
|
-
});
|
|
195
|
-
} else {
|
|
196
|
-
visualViewport.addEventListener("resize", () => scrollIntoView(target), {
|
|
197
|
-
once: true
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
let onWindowScroll = () => {
|
|
205
|
-
window.scrollTo(0, 0);
|
|
206
|
-
};
|
|
207
|
-
let scrollX = window.pageXOffset;
|
|
208
|
-
let scrollY = window.pageYOffset;
|
|
209
|
-
let restoreStyles = chain$1(setStyle(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`));
|
|
210
|
-
window.scrollTo(0, 0);
|
|
211
|
-
let removeEvents = chain$1(addEvent(document, "touchstart", onTouchStart, {
|
|
212
|
-
passive: false,
|
|
213
|
-
capture: true
|
|
214
|
-
}), addEvent(document, "touchmove", onTouchMove, {
|
|
215
|
-
passive: false,
|
|
216
|
-
capture: true
|
|
217
|
-
}), addEvent(document, "touchend", onTouchEnd, {
|
|
218
|
-
passive: false,
|
|
219
|
-
capture: true
|
|
220
|
-
}), addEvent(document, "focus", onFocus, true), addEvent(window, "scroll", onWindowScroll));
|
|
221
|
-
return () => {
|
|
222
|
-
restoreStyles();
|
|
223
|
-
removeEvents();
|
|
224
|
-
window.scrollTo(scrollX, scrollY);
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function setStyle(element, style, value) {
|
|
228
|
-
let cur = element.style[style];
|
|
229
|
-
element.style[style] = value;
|
|
230
|
-
return () => {
|
|
231
|
-
element.style[style] = cur;
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function addEvent(target, event, handler, options) {
|
|
235
|
-
target.addEventListener(event, handler, options);
|
|
236
|
-
return () => {
|
|
237
|
-
target.removeEventListener(event, handler, options);
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
function scrollIntoView(target) {
|
|
241
|
-
let root = document.scrollingElement || document.documentElement;
|
|
242
|
-
while (target && target !== root) {
|
|
243
|
-
let scrollable = getScrollParent(target);
|
|
244
|
-
if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
|
|
245
|
-
let scrollableTop = scrollable.getBoundingClientRect().top;
|
|
246
|
-
let targetTop = target.getBoundingClientRect().top;
|
|
247
|
-
let targetBottom = target.getBoundingClientRect().bottom;
|
|
248
|
-
const keyboardHeight = scrollable.getBoundingClientRect().bottom + KEYBOARD_BUFFER;
|
|
249
|
-
if (targetBottom > keyboardHeight) {
|
|
250
|
-
scrollable.scrollTop += targetTop - scrollableTop;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
target = scrollable.parentElement;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
function isInput(target) {
|
|
257
|
-
return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
|
|
258
|
-
}
|
|
259
|
-
function setRef(ref, value) {
|
|
260
|
-
if (typeof ref === "function") {
|
|
261
|
-
ref(value);
|
|
262
|
-
} else if (ref !== null && ref !== void 0) {
|
|
263
|
-
ref.current = value;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
function composeRefs(...refs) {
|
|
267
|
-
return (node) => refs.forEach((ref) => setRef(ref, node));
|
|
268
|
-
}
|
|
269
|
-
function useComposedRefs(...refs) {
|
|
270
|
-
return React.useCallback(composeRefs(...refs), refs);
|
|
271
|
-
}
|
|
272
|
-
var cache = /* @__PURE__ */ new WeakMap();
|
|
273
|
-
function set(el, styles, ignoreCache = false) {
|
|
274
|
-
if (!el || !(el instanceof HTMLElement)) return;
|
|
275
|
-
let originalStyles = {};
|
|
276
|
-
Object.entries(styles).forEach(([key, value]) => {
|
|
277
|
-
if (key.startsWith("--")) {
|
|
278
|
-
el.style.setProperty(key, value);
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
originalStyles[key] = el.style[key];
|
|
282
|
-
el.style[key] = value;
|
|
283
|
-
});
|
|
284
|
-
if (ignoreCache) return;
|
|
285
|
-
cache.set(el, originalStyles);
|
|
286
|
-
}
|
|
287
|
-
function reset(el, prop) {
|
|
288
|
-
if (!el || !(el instanceof HTMLElement)) return;
|
|
289
|
-
let originalStyles = cache.get(el);
|
|
290
|
-
if (!originalStyles) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
{
|
|
294
|
-
el.style[prop] = originalStyles[prop];
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
var isVertical = (direction) => {
|
|
298
|
-
switch (direction) {
|
|
299
|
-
case "top":
|
|
300
|
-
case "bottom":
|
|
301
|
-
return true;
|
|
302
|
-
case "left":
|
|
303
|
-
case "right":
|
|
304
|
-
return false;
|
|
305
|
-
default:
|
|
306
|
-
return direction;
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
function getTranslate(element, direction) {
|
|
310
|
-
if (!element) {
|
|
311
|
-
return null;
|
|
312
|
-
}
|
|
313
|
-
const style = window.getComputedStyle(element);
|
|
314
|
-
const transform = (
|
|
315
|
-
// @ts-ignore
|
|
316
|
-
style.transform || style.webkitTransform || style.mozTransform
|
|
317
|
-
);
|
|
318
|
-
let mat = transform.match(/^matrix3d\((.+)\)$/);
|
|
319
|
-
if (mat) {
|
|
320
|
-
return parseFloat(mat[1].split(", ")[isVertical(direction) ? 13 : 12]);
|
|
321
|
-
}
|
|
322
|
-
mat = transform.match(/^matrix\((.+)\)$/);
|
|
323
|
-
return mat ? parseFloat(mat[1].split(", ")[isVertical(direction) ? 5 : 4]) : null;
|
|
324
|
-
}
|
|
325
|
-
function dampenValue(v) {
|
|
326
|
-
return 8 * (Math.log(v + 1) - 2);
|
|
327
|
-
}
|
|
328
|
-
function assignStyle(element, style) {
|
|
329
|
-
if (!element) return () => {
|
|
330
|
-
};
|
|
331
|
-
const prevStyle = element.style.cssText;
|
|
332
|
-
Object.assign(element.style, style);
|
|
333
|
-
return () => {
|
|
334
|
-
element.style.cssText = prevStyle;
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
function chain(...fns) {
|
|
338
|
-
return (...args) => {
|
|
339
|
-
for (const fn of fns) {
|
|
340
|
-
if (typeof fn === "function") {
|
|
341
|
-
fn(...args);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
var TRANSITIONS = {
|
|
347
|
-
DURATION: 0.5,
|
|
348
|
-
EASE: [
|
|
349
|
-
0.32,
|
|
350
|
-
0.72,
|
|
351
|
-
0,
|
|
352
|
-
1
|
|
353
|
-
]
|
|
354
|
-
};
|
|
355
|
-
var VELOCITY_THRESHOLD = 0.4;
|
|
356
|
-
var CLOSE_THRESHOLD = 0.25;
|
|
357
|
-
var SCROLL_LOCK_TIMEOUT = 100;
|
|
358
|
-
var BORDER_RADIUS = 8;
|
|
359
|
-
var NESTED_DISPLACEMENT = 16;
|
|
360
|
-
var WINDOW_TOP_OFFSET = 26;
|
|
361
|
-
var DRAG_CLASS = "vaul-dragging";
|
|
362
|
-
function useCallbackRef(callback) {
|
|
363
|
-
const callbackRef = React__default.useRef(callback);
|
|
364
|
-
React__default.useEffect(() => {
|
|
365
|
-
callbackRef.current = callback;
|
|
366
|
-
});
|
|
367
|
-
return React__default.useMemo(() => (...args) => callbackRef.current == null ? void 0 : callbackRef.current.call(callbackRef, ...args), []);
|
|
368
|
-
}
|
|
369
|
-
function useUncontrolledState({ defaultProp, onChange }) {
|
|
370
|
-
const uncontrolledState = React__default.useState(defaultProp);
|
|
371
|
-
const [value] = uncontrolledState;
|
|
372
|
-
const prevValueRef = React__default.useRef(value);
|
|
373
|
-
const handleChange = useCallbackRef(onChange);
|
|
374
|
-
React__default.useEffect(() => {
|
|
375
|
-
if (prevValueRef.current !== value) {
|
|
376
|
-
handleChange(value);
|
|
377
|
-
prevValueRef.current = value;
|
|
378
|
-
}
|
|
379
|
-
}, [
|
|
380
|
-
value,
|
|
381
|
-
prevValueRef,
|
|
382
|
-
handleChange
|
|
383
|
-
]);
|
|
384
|
-
return uncontrolledState;
|
|
385
|
-
}
|
|
386
|
-
function useControllableState({ prop, defaultProp, onChange = () => {
|
|
387
|
-
} }) {
|
|
388
|
-
const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({
|
|
389
|
-
defaultProp,
|
|
390
|
-
onChange
|
|
391
|
-
});
|
|
392
|
-
const isControlled = prop !== void 0;
|
|
393
|
-
const value = isControlled ? prop : uncontrolledProp;
|
|
394
|
-
const handleChange = useCallbackRef(onChange);
|
|
395
|
-
const setValue = React__default.useCallback((nextValue) => {
|
|
396
|
-
if (isControlled) {
|
|
397
|
-
const setter = nextValue;
|
|
398
|
-
const value2 = typeof nextValue === "function" ? setter(prop) : nextValue;
|
|
399
|
-
if (value2 !== prop) handleChange(value2);
|
|
400
|
-
} else {
|
|
401
|
-
setUncontrolledProp(nextValue);
|
|
402
|
-
}
|
|
403
|
-
}, [
|
|
404
|
-
isControlled,
|
|
405
|
-
prop,
|
|
406
|
-
setUncontrolledProp,
|
|
407
|
-
handleChange
|
|
408
|
-
]);
|
|
409
|
-
return [
|
|
410
|
-
value,
|
|
411
|
-
setValue
|
|
412
|
-
];
|
|
413
|
-
}
|
|
414
|
-
function useSnapPoints({ activeSnapPointProp, setActiveSnapPointProp, snapPoints, drawerRef, overlayRef, fadeFromIndex, onSnapPointChange, direction = "bottom", container, snapToSequentialPoint }) {
|
|
415
|
-
const [activeSnapPoint, setActiveSnapPoint] = useControllableState({
|
|
416
|
-
prop: activeSnapPointProp,
|
|
417
|
-
defaultProp: snapPoints == null ? void 0 : snapPoints[0],
|
|
418
|
-
onChange: setActiveSnapPointProp
|
|
419
|
-
});
|
|
420
|
-
const [windowDimensions, setWindowDimensions] = React__default.useState(typeof window !== "undefined" ? {
|
|
421
|
-
innerWidth: window.innerWidth,
|
|
422
|
-
innerHeight: window.innerHeight
|
|
423
|
-
} : void 0);
|
|
424
|
-
React__default.useEffect(() => {
|
|
425
|
-
function onResize() {
|
|
426
|
-
setWindowDimensions({
|
|
427
|
-
innerWidth: window.innerWidth,
|
|
428
|
-
innerHeight: window.innerHeight
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
window.addEventListener("resize", onResize);
|
|
432
|
-
return () => window.removeEventListener("resize", onResize);
|
|
433
|
-
}, []);
|
|
434
|
-
const isLastSnapPoint = React__default.useMemo(() => activeSnapPoint === (snapPoints == null ? void 0 : snapPoints[snapPoints.length - 1]) || null, [
|
|
435
|
-
snapPoints,
|
|
436
|
-
activeSnapPoint
|
|
437
|
-
]);
|
|
438
|
-
const activeSnapPointIndex = React__default.useMemo(() => {
|
|
439
|
-
var _snapPoints_findIndex;
|
|
440
|
-
return (_snapPoints_findIndex = snapPoints == null ? void 0 : snapPoints.findIndex((snapPoint) => snapPoint === activeSnapPoint)) != null ? _snapPoints_findIndex : null;
|
|
441
|
-
}, [
|
|
442
|
-
snapPoints,
|
|
443
|
-
activeSnapPoint
|
|
444
|
-
]);
|
|
445
|
-
const shouldFade = snapPoints && snapPoints.length > 0 && (fadeFromIndex || fadeFromIndex === 0) && !Number.isNaN(fadeFromIndex) && snapPoints[fadeFromIndex] === activeSnapPoint || !snapPoints;
|
|
446
|
-
const snapPointsOffset = React__default.useMemo(() => {
|
|
447
|
-
const containerSize = container ? {
|
|
448
|
-
width: container.getBoundingClientRect().width,
|
|
449
|
-
height: container.getBoundingClientRect().height
|
|
450
|
-
} : typeof window !== "undefined" ? {
|
|
451
|
-
width: window.innerWidth,
|
|
452
|
-
height: window.innerHeight
|
|
453
|
-
} : {
|
|
454
|
-
width: 0,
|
|
455
|
-
height: 0
|
|
456
|
-
};
|
|
457
|
-
var _snapPoints_map;
|
|
458
|
-
return (_snapPoints_map = snapPoints == null ? void 0 : snapPoints.map((snapPoint) => {
|
|
459
|
-
const isPx = typeof snapPoint === "string";
|
|
460
|
-
let snapPointAsNumber = 0;
|
|
461
|
-
if (isPx) {
|
|
462
|
-
snapPointAsNumber = parseInt(snapPoint, 10);
|
|
463
|
-
}
|
|
464
|
-
if (isVertical(direction)) {
|
|
465
|
-
const height = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.height : 0;
|
|
466
|
-
if (windowDimensions) {
|
|
467
|
-
return direction === "bottom" ? containerSize.height - height : -containerSize.height + height;
|
|
468
|
-
}
|
|
469
|
-
return height;
|
|
470
|
-
}
|
|
471
|
-
const width = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.width : 0;
|
|
472
|
-
if (windowDimensions) {
|
|
473
|
-
return direction === "right" ? containerSize.width - width : -containerSize.width + width;
|
|
474
|
-
}
|
|
475
|
-
return width;
|
|
476
|
-
})) != null ? _snapPoints_map : [];
|
|
477
|
-
}, [
|
|
478
|
-
snapPoints,
|
|
479
|
-
windowDimensions,
|
|
480
|
-
container
|
|
481
|
-
]);
|
|
482
|
-
const activeSnapPointOffset = React__default.useMemo(() => activeSnapPointIndex !== null ? snapPointsOffset == null ? void 0 : snapPointsOffset[activeSnapPointIndex] : null, [
|
|
483
|
-
snapPointsOffset,
|
|
484
|
-
activeSnapPointIndex
|
|
485
|
-
]);
|
|
486
|
-
const snapToPoint = React__default.useCallback((dimension) => {
|
|
487
|
-
var _snapPointsOffset_findIndex;
|
|
488
|
-
const newSnapPointIndex = (_snapPointsOffset_findIndex = snapPointsOffset == null ? void 0 : snapPointsOffset.findIndex((snapPointDim) => snapPointDim === dimension)) != null ? _snapPointsOffset_findIndex : null;
|
|
489
|
-
onSnapPointChange(newSnapPointIndex);
|
|
490
|
-
set(drawerRef.current, {
|
|
491
|
-
transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
|
|
492
|
-
transform: isVertical(direction) ? `translate3d(0, ${dimension}px, 0)` : `translate3d(${dimension}px, 0, 0)`
|
|
493
|
-
});
|
|
494
|
-
if (snapPointsOffset && newSnapPointIndex !== snapPointsOffset.length - 1 && fadeFromIndex !== void 0 && newSnapPointIndex !== fadeFromIndex && newSnapPointIndex < fadeFromIndex) {
|
|
495
|
-
set(overlayRef.current, {
|
|
496
|
-
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
|
|
497
|
-
opacity: "0"
|
|
498
|
-
});
|
|
499
|
-
} else {
|
|
500
|
-
set(overlayRef.current, {
|
|
501
|
-
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
|
|
502
|
-
opacity: "1"
|
|
503
|
-
});
|
|
504
|
-
}
|
|
505
|
-
setActiveSnapPoint(snapPoints == null ? void 0 : snapPoints[Math.max(newSnapPointIndex, 0)]);
|
|
506
|
-
}, [
|
|
507
|
-
drawerRef.current,
|
|
508
|
-
snapPoints,
|
|
509
|
-
snapPointsOffset,
|
|
510
|
-
fadeFromIndex,
|
|
511
|
-
overlayRef,
|
|
512
|
-
setActiveSnapPoint
|
|
513
|
-
]);
|
|
514
|
-
React__default.useEffect(() => {
|
|
515
|
-
if (activeSnapPoint || activeSnapPointProp) {
|
|
516
|
-
var _snapPoints_findIndex;
|
|
517
|
-
const newIndex = (_snapPoints_findIndex = snapPoints == null ? void 0 : snapPoints.findIndex((snapPoint) => snapPoint === activeSnapPointProp || snapPoint === activeSnapPoint)) != null ? _snapPoints_findIndex : -1;
|
|
518
|
-
if (snapPointsOffset && newIndex !== -1 && typeof snapPointsOffset[newIndex] === "number") {
|
|
519
|
-
snapToPoint(snapPointsOffset[newIndex]);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}, [
|
|
523
|
-
activeSnapPoint,
|
|
524
|
-
activeSnapPointProp,
|
|
525
|
-
snapPoints,
|
|
526
|
-
snapPointsOffset,
|
|
527
|
-
snapToPoint
|
|
528
|
-
]);
|
|
529
|
-
function onRelease({ draggedDistance, closeDrawer, velocity, dismissible }) {
|
|
530
|
-
if (fadeFromIndex === void 0) return;
|
|
531
|
-
const currentPosition = direction === "bottom" || direction === "right" ? (activeSnapPointOffset != null ? activeSnapPointOffset : 0) - draggedDistance : (activeSnapPointOffset != null ? activeSnapPointOffset : 0) + draggedDistance;
|
|
532
|
-
const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
|
|
533
|
-
const isFirst = activeSnapPointIndex === 0;
|
|
534
|
-
const hasDraggedUp = draggedDistance > 0;
|
|
535
|
-
if (isOverlaySnapPoint) {
|
|
536
|
-
set(overlayRef.current, {
|
|
537
|
-
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`
|
|
538
|
-
});
|
|
539
|
-
}
|
|
540
|
-
if (!snapToSequentialPoint && velocity > 2 && !hasDraggedUp) {
|
|
541
|
-
if (dismissible) closeDrawer();
|
|
542
|
-
else snapToPoint(snapPointsOffset[0]);
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
if (!snapToSequentialPoint && velocity > 2 && hasDraggedUp && snapPointsOffset && snapPoints) {
|
|
546
|
-
snapToPoint(snapPointsOffset[snapPoints.length - 1]);
|
|
547
|
-
return;
|
|
548
|
-
}
|
|
549
|
-
const closestSnapPoint = snapPointsOffset == null ? void 0 : snapPointsOffset.reduce((prev, curr) => {
|
|
550
|
-
if (typeof prev !== "number" || typeof curr !== "number") return prev;
|
|
551
|
-
return Math.abs(curr - currentPosition) < Math.abs(prev - currentPosition) ? curr : prev;
|
|
552
|
-
});
|
|
553
|
-
const dim = isVertical(direction) ? window.innerHeight : window.innerWidth;
|
|
554
|
-
if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedDistance) < dim * 0.4) {
|
|
555
|
-
const dragDirection = hasDraggedUp ? 1 : -1;
|
|
556
|
-
if (dragDirection > 0 && isLastSnapPoint && snapPoints) {
|
|
557
|
-
snapToPoint(snapPointsOffset[snapPoints.length - 1]);
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
if (isFirst && dragDirection < 0 && dismissible) {
|
|
561
|
-
closeDrawer();
|
|
562
|
-
}
|
|
563
|
-
if (activeSnapPointIndex === null) return;
|
|
564
|
-
snapToPoint(snapPointsOffset[activeSnapPointIndex + dragDirection]);
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
snapToPoint(closestSnapPoint);
|
|
568
|
-
}
|
|
569
|
-
function onDrag({ draggedDistance }) {
|
|
570
|
-
if (activeSnapPointOffset === null) return;
|
|
571
|
-
const newValue = direction === "bottom" || direction === "right" ? activeSnapPointOffset - draggedDistance : activeSnapPointOffset + draggedDistance;
|
|
572
|
-
if ((direction === "bottom" || direction === "right") && newValue < snapPointsOffset[snapPointsOffset.length - 1]) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
if ((direction === "top" || direction === "left") && newValue > snapPointsOffset[snapPointsOffset.length - 1]) {
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
set(drawerRef.current, {
|
|
579
|
-
transform: isVertical(direction) ? `translate3d(0, ${newValue}px, 0)` : `translate3d(${newValue}px, 0, 0)`
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
function getPercentageDragged(absDraggedDistance, isDraggingDown) {
|
|
583
|
-
if (!snapPoints || typeof activeSnapPointIndex !== "number" || !snapPointsOffset || fadeFromIndex === void 0) return null;
|
|
584
|
-
const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
|
|
585
|
-
const isOverlaySnapPointOrHigher = activeSnapPointIndex >= fadeFromIndex;
|
|
586
|
-
if (isOverlaySnapPointOrHigher && isDraggingDown) {
|
|
587
|
-
return 0;
|
|
588
|
-
}
|
|
589
|
-
if (isOverlaySnapPoint && !isDraggingDown) return 1;
|
|
590
|
-
if (!shouldFade && !isOverlaySnapPoint) return null;
|
|
591
|
-
const targetSnapPointIndex = isOverlaySnapPoint ? activeSnapPointIndex + 1 : activeSnapPointIndex - 1;
|
|
592
|
-
const snapPointDistance = isOverlaySnapPoint ? snapPointsOffset[targetSnapPointIndex] - snapPointsOffset[targetSnapPointIndex - 1] : snapPointsOffset[targetSnapPointIndex + 1] - snapPointsOffset[targetSnapPointIndex];
|
|
593
|
-
const percentageDragged = absDraggedDistance / Math.abs(snapPointDistance);
|
|
594
|
-
if (isOverlaySnapPoint) {
|
|
595
|
-
return 1 - percentageDragged;
|
|
596
|
-
} else {
|
|
597
|
-
return percentageDragged;
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
return {
|
|
601
|
-
isLastSnapPoint,
|
|
602
|
-
activeSnapPoint,
|
|
603
|
-
shouldFade,
|
|
604
|
-
getPercentageDragged,
|
|
605
|
-
setActiveSnapPoint,
|
|
606
|
-
activeSnapPointIndex,
|
|
607
|
-
onRelease,
|
|
608
|
-
onDrag,
|
|
609
|
-
snapPointsOffset
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
var noop = () => () => {
|
|
613
|
-
};
|
|
614
|
-
function useScaleBackground() {
|
|
615
|
-
const { direction, isOpen, shouldScaleBackground, setBackgroundColorOnScale, noBodyStyles } = useDrawerContext();
|
|
616
|
-
const timeoutIdRef = React__default.useRef(null);
|
|
617
|
-
const initialBackgroundColor = useMemo(() => document.body.style.backgroundColor, []);
|
|
618
|
-
function getScale() {
|
|
619
|
-
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
620
|
-
}
|
|
621
|
-
React__default.useEffect(() => {
|
|
622
|
-
if (isOpen && shouldScaleBackground) {
|
|
623
|
-
if (timeoutIdRef.current) clearTimeout(timeoutIdRef.current);
|
|
624
|
-
const wrapper = document.querySelector("[data-vaul-drawer-wrapper]") || document.querySelector("[vaul-drawer-wrapper]");
|
|
625
|
-
if (!wrapper) return;
|
|
626
|
-
chain(setBackgroundColorOnScale && !noBodyStyles ? assignStyle(document.body, {
|
|
627
|
-
background: "black"
|
|
628
|
-
}) : noop, assignStyle(wrapper, {
|
|
629
|
-
transformOrigin: isVertical(direction) ? "top" : "left",
|
|
630
|
-
transitionProperty: "transform, border-radius",
|
|
631
|
-
transitionDuration: `${TRANSITIONS.DURATION}s`,
|
|
632
|
-
transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(",")})`
|
|
633
|
-
}));
|
|
634
|
-
const wrapperStylesCleanup = assignStyle(wrapper, {
|
|
635
|
-
borderRadius: `${BORDER_RADIUS}px`,
|
|
636
|
-
overflow: "hidden",
|
|
637
|
-
...isVertical(direction) ? {
|
|
638
|
-
transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`
|
|
639
|
-
} : {
|
|
640
|
-
transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`
|
|
641
|
-
}
|
|
642
|
-
});
|
|
643
|
-
return () => {
|
|
644
|
-
wrapperStylesCleanup();
|
|
645
|
-
timeoutIdRef.current = window.setTimeout(() => {
|
|
646
|
-
if (initialBackgroundColor) {
|
|
647
|
-
document.body.style.background = initialBackgroundColor;
|
|
648
|
-
} else {
|
|
649
|
-
document.body.style.removeProperty("background");
|
|
650
|
-
}
|
|
651
|
-
}, TRANSITIONS.DURATION * 1e3);
|
|
652
|
-
};
|
|
653
|
-
}
|
|
654
|
-
}, [
|
|
655
|
-
isOpen,
|
|
656
|
-
shouldScaleBackground,
|
|
657
|
-
initialBackgroundColor
|
|
658
|
-
]);
|
|
659
|
-
}
|
|
660
|
-
var previousBodyPosition = null;
|
|
661
|
-
function usePositionFixed({ isOpen, modal, nested, hasBeenOpened, preventScrollRestoration, noBodyStyles }) {
|
|
662
|
-
const [activeUrl, setActiveUrl] = React__default.useState(() => typeof window !== "undefined" ? window.location.href : "");
|
|
663
|
-
const scrollPos = React__default.useRef(0);
|
|
664
|
-
const setPositionFixed = React__default.useCallback(() => {
|
|
665
|
-
if (!isSafari()) return;
|
|
666
|
-
if (previousBodyPosition === null && isOpen && !noBodyStyles) {
|
|
667
|
-
previousBodyPosition = {
|
|
668
|
-
position: document.body.style.position,
|
|
669
|
-
top: document.body.style.top,
|
|
670
|
-
left: document.body.style.left,
|
|
671
|
-
height: document.body.style.height,
|
|
672
|
-
right: "unset"
|
|
673
|
-
};
|
|
674
|
-
const { scrollX, innerHeight } = window;
|
|
675
|
-
document.body.style.setProperty("position", "fixed", "important");
|
|
676
|
-
Object.assign(document.body.style, {
|
|
677
|
-
top: `${-scrollPos.current}px`,
|
|
678
|
-
left: `${-scrollX}px`,
|
|
679
|
-
right: "0px",
|
|
680
|
-
height: "auto"
|
|
681
|
-
});
|
|
682
|
-
window.setTimeout(() => window.requestAnimationFrame(() => {
|
|
683
|
-
const bottomBarHeight = innerHeight - window.innerHeight;
|
|
684
|
-
if (bottomBarHeight && scrollPos.current >= innerHeight) {
|
|
685
|
-
document.body.style.top = `${-(scrollPos.current + bottomBarHeight)}px`;
|
|
686
|
-
}
|
|
687
|
-
}), 300);
|
|
688
|
-
}
|
|
689
|
-
}, [
|
|
690
|
-
isOpen
|
|
691
|
-
]);
|
|
692
|
-
const restorePositionSetting = React__default.useCallback(() => {
|
|
693
|
-
if (!isSafari()) return;
|
|
694
|
-
if (previousBodyPosition !== null && !noBodyStyles) {
|
|
695
|
-
const y = -parseInt(document.body.style.top, 10);
|
|
696
|
-
const x = -parseInt(document.body.style.left, 10);
|
|
697
|
-
Object.assign(document.body.style, previousBodyPosition);
|
|
698
|
-
window.requestAnimationFrame(() => {
|
|
699
|
-
if (preventScrollRestoration && activeUrl !== window.location.href) {
|
|
700
|
-
setActiveUrl(window.location.href);
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
window.scrollTo(x, y);
|
|
704
|
-
});
|
|
705
|
-
previousBodyPosition = null;
|
|
706
|
-
}
|
|
707
|
-
}, [
|
|
708
|
-
activeUrl
|
|
709
|
-
]);
|
|
710
|
-
React__default.useEffect(() => {
|
|
711
|
-
function onScroll() {
|
|
712
|
-
scrollPos.current = window.scrollY;
|
|
713
|
-
}
|
|
714
|
-
onScroll();
|
|
715
|
-
window.addEventListener("scroll", onScroll);
|
|
716
|
-
return () => {
|
|
717
|
-
window.removeEventListener("scroll", onScroll);
|
|
718
|
-
};
|
|
719
|
-
}, []);
|
|
720
|
-
React__default.useEffect(() => {
|
|
721
|
-
if (!modal) return;
|
|
722
|
-
return () => {
|
|
723
|
-
if (typeof document === "undefined") return;
|
|
724
|
-
const hasDrawerOpened = !!document.querySelector("[data-vaul-drawer]");
|
|
725
|
-
if (hasDrawerOpened) return;
|
|
726
|
-
restorePositionSetting();
|
|
727
|
-
};
|
|
728
|
-
}, [
|
|
729
|
-
modal,
|
|
730
|
-
restorePositionSetting
|
|
731
|
-
]);
|
|
732
|
-
React__default.useEffect(() => {
|
|
733
|
-
if (nested || !hasBeenOpened) return;
|
|
734
|
-
if (isOpen) {
|
|
735
|
-
const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
|
|
736
|
-
!isStandalone && setPositionFixed();
|
|
737
|
-
if (!modal) {
|
|
738
|
-
window.setTimeout(() => {
|
|
739
|
-
restorePositionSetting();
|
|
740
|
-
}, 500);
|
|
741
|
-
}
|
|
742
|
-
} else {
|
|
743
|
-
restorePositionSetting();
|
|
744
|
-
}
|
|
745
|
-
}, [
|
|
746
|
-
isOpen,
|
|
747
|
-
hasBeenOpened,
|
|
748
|
-
activeUrl,
|
|
749
|
-
modal,
|
|
750
|
-
nested,
|
|
751
|
-
setPositionFixed,
|
|
752
|
-
restorePositionSetting
|
|
753
|
-
]);
|
|
754
|
-
return {
|
|
755
|
-
restorePositionSetting
|
|
756
|
-
};
|
|
757
|
-
}
|
|
758
|
-
function Root2({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = "bottom", defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, onAnimationEnd, container, autoFocus = false }) {
|
|
759
|
-
var _drawerRef_current, _drawerRef_current1;
|
|
760
|
-
const [isOpen = false, setIsOpen] = useControllableState({
|
|
761
|
-
defaultProp: defaultOpen,
|
|
762
|
-
prop: openProp,
|
|
763
|
-
onChange: (o) => {
|
|
764
|
-
onOpenChange == null ? void 0 : onOpenChange(o);
|
|
765
|
-
if (!o && !nested) {
|
|
766
|
-
restorePositionSetting();
|
|
767
|
-
}
|
|
768
|
-
setTimeout(() => {
|
|
769
|
-
onAnimationEnd == null ? void 0 : onAnimationEnd(o);
|
|
770
|
-
}, TRANSITIONS.DURATION * 1e3);
|
|
771
|
-
if (o && !modal) {
|
|
772
|
-
if (typeof window !== "undefined") {
|
|
773
|
-
window.requestAnimationFrame(() => {
|
|
774
|
-
document.body.style.pointerEvents = "auto";
|
|
775
|
-
});
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
if (!o) {
|
|
779
|
-
document.body.style.pointerEvents = "auto";
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
const [hasBeenOpened, setHasBeenOpened] = React__default.useState(false);
|
|
784
|
-
const [isDragging, setIsDragging] = React__default.useState(false);
|
|
785
|
-
const [justReleased, setJustReleased] = React__default.useState(false);
|
|
786
|
-
const overlayRef = React__default.useRef(null);
|
|
787
|
-
const openTime = React__default.useRef(null);
|
|
788
|
-
const dragStartTime = React__default.useRef(null);
|
|
789
|
-
const dragEndTime = React__default.useRef(null);
|
|
790
|
-
const lastTimeDragPrevented = React__default.useRef(null);
|
|
791
|
-
const isAllowedToDrag = React__default.useRef(false);
|
|
792
|
-
const nestedOpenChangeTimer = React__default.useRef(null);
|
|
793
|
-
const pointerStart = React__default.useRef(0);
|
|
794
|
-
const keyboardIsOpen = React__default.useRef(false);
|
|
795
|
-
const shouldAnimate = React__default.useRef(!defaultOpen);
|
|
796
|
-
const previousDiffFromInitial = React__default.useRef(0);
|
|
797
|
-
const drawerRef = React__default.useRef(null);
|
|
798
|
-
const drawerHeightRef = React__default.useRef(((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.getBoundingClientRect().height) || 0);
|
|
799
|
-
const drawerWidthRef = React__default.useRef(((_drawerRef_current1 = drawerRef.current) == null ? void 0 : _drawerRef_current1.getBoundingClientRect().width) || 0);
|
|
800
|
-
const initialDrawerHeight = React__default.useRef(0);
|
|
801
|
-
const onSnapPointChange = React__default.useCallback((activeSnapPointIndex2) => {
|
|
802
|
-
if (snapPoints && activeSnapPointIndex2 === snapPointsOffset.length - 1) openTime.current = /* @__PURE__ */ new Date();
|
|
803
|
-
}, []);
|
|
804
|
-
const { activeSnapPoint, activeSnapPointIndex, setActiveSnapPoint, onRelease: onReleaseSnapPoints, snapPointsOffset, onDrag: onDragSnapPoints, shouldFade, getPercentageDragged: getSnapPointsPercentageDragged } = useSnapPoints({
|
|
805
|
-
snapPoints,
|
|
806
|
-
activeSnapPointProp,
|
|
807
|
-
setActiveSnapPointProp,
|
|
808
|
-
drawerRef,
|
|
809
|
-
fadeFromIndex,
|
|
810
|
-
overlayRef,
|
|
811
|
-
onSnapPointChange,
|
|
812
|
-
direction,
|
|
813
|
-
container,
|
|
814
|
-
snapToSequentialPoint
|
|
815
|
-
});
|
|
816
|
-
usePreventScroll({
|
|
817
|
-
isDisabled: !isOpen || isDragging || !modal || justReleased || !hasBeenOpened || !repositionInputs || !disablePreventScroll
|
|
818
|
-
});
|
|
819
|
-
const { restorePositionSetting } = usePositionFixed({
|
|
820
|
-
isOpen,
|
|
821
|
-
modal,
|
|
822
|
-
nested: nested != null ? nested : false,
|
|
823
|
-
hasBeenOpened,
|
|
824
|
-
preventScrollRestoration,
|
|
825
|
-
noBodyStyles
|
|
826
|
-
});
|
|
827
|
-
function getScale() {
|
|
828
|
-
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
829
|
-
}
|
|
830
|
-
function onPress(event) {
|
|
831
|
-
var _drawerRef_current2, _drawerRef_current12;
|
|
832
|
-
if (!dismissible && !snapPoints) return;
|
|
833
|
-
if (drawerRef.current && !drawerRef.current.contains(event.target)) return;
|
|
834
|
-
drawerHeightRef.current = ((_drawerRef_current2 = drawerRef.current) == null ? void 0 : _drawerRef_current2.getBoundingClientRect().height) || 0;
|
|
835
|
-
drawerWidthRef.current = ((_drawerRef_current12 = drawerRef.current) == null ? void 0 : _drawerRef_current12.getBoundingClientRect().width) || 0;
|
|
836
|
-
setIsDragging(true);
|
|
837
|
-
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
838
|
-
if (isIOS()) {
|
|
839
|
-
window.addEventListener("touchend", () => isAllowedToDrag.current = false, {
|
|
840
|
-
once: true
|
|
841
|
-
});
|
|
842
|
-
}
|
|
843
|
-
event.target.setPointerCapture(event.pointerId);
|
|
844
|
-
pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
|
|
845
|
-
}
|
|
846
|
-
function shouldDrag(el, isDraggingInDirection) {
|
|
847
|
-
var _window_getSelection;
|
|
848
|
-
let element = el;
|
|
849
|
-
const highlightedText = (_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString();
|
|
850
|
-
const swipeAmount = drawerRef.current ? getTranslate(drawerRef.current, direction) : null;
|
|
851
|
-
const date = /* @__PURE__ */ new Date();
|
|
852
|
-
if (element.tagName === "SELECT") {
|
|
853
|
-
return false;
|
|
854
|
-
}
|
|
855
|
-
if (element.hasAttribute("data-vaul-no-drag") || element.closest("[data-vaul-no-drag]")) {
|
|
856
|
-
return false;
|
|
857
|
-
}
|
|
858
|
-
if (direction === "right" || direction === "left") {
|
|
859
|
-
return true;
|
|
860
|
-
}
|
|
861
|
-
if (openTime.current && date.getTime() - openTime.current.getTime() < 500) {
|
|
862
|
-
return false;
|
|
863
|
-
}
|
|
864
|
-
if (swipeAmount !== null) {
|
|
865
|
-
if (direction === "bottom" ? swipeAmount > 0 : swipeAmount < 0) {
|
|
866
|
-
return true;
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
if (highlightedText && highlightedText.length > 0) {
|
|
870
|
-
return false;
|
|
871
|
-
}
|
|
872
|
-
if (lastTimeDragPrevented.current && date.getTime() - lastTimeDragPrevented.current.getTime() < scrollLockTimeout && swipeAmount === 0) {
|
|
873
|
-
lastTimeDragPrevented.current = date;
|
|
874
|
-
return false;
|
|
875
|
-
}
|
|
876
|
-
if (isDraggingInDirection) {
|
|
877
|
-
lastTimeDragPrevented.current = date;
|
|
878
|
-
return false;
|
|
879
|
-
}
|
|
880
|
-
while (element) {
|
|
881
|
-
if (element.scrollHeight > element.clientHeight) {
|
|
882
|
-
if (element.scrollTop !== 0) {
|
|
883
|
-
lastTimeDragPrevented.current = /* @__PURE__ */ new Date();
|
|
884
|
-
return false;
|
|
885
|
-
}
|
|
886
|
-
if (element.getAttribute("role") === "dialog") {
|
|
887
|
-
return true;
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
element = element.parentNode;
|
|
891
|
-
}
|
|
892
|
-
return true;
|
|
893
|
-
}
|
|
894
|
-
function onDrag(event) {
|
|
895
|
-
if (!drawerRef.current) {
|
|
896
|
-
return;
|
|
897
|
-
}
|
|
898
|
-
if (isDragging) {
|
|
899
|
-
const directionMultiplier = direction === "bottom" || direction === "right" ? 1 : -1;
|
|
900
|
-
const draggedDistance = (pointerStart.current - (isVertical(direction) ? event.pageY : event.pageX)) * directionMultiplier;
|
|
901
|
-
const isDraggingInDirection = draggedDistance > 0;
|
|
902
|
-
const noCloseSnapPointsPreCondition = snapPoints && !dismissible && !isDraggingInDirection;
|
|
903
|
-
if (noCloseSnapPointsPreCondition && activeSnapPointIndex === 0) return;
|
|
904
|
-
const absDraggedDistance = Math.abs(draggedDistance);
|
|
905
|
-
const wrapper = document.querySelector("[data-vaul-drawer-wrapper]");
|
|
906
|
-
const drawerDimension = direction === "bottom" || direction === "top" ? drawerHeightRef.current : drawerWidthRef.current;
|
|
907
|
-
let percentageDragged = absDraggedDistance / drawerDimension;
|
|
908
|
-
const snapPointPercentageDragged = getSnapPointsPercentageDragged(absDraggedDistance, isDraggingInDirection);
|
|
909
|
-
if (snapPointPercentageDragged !== null) {
|
|
910
|
-
percentageDragged = snapPointPercentageDragged;
|
|
911
|
-
}
|
|
912
|
-
if (noCloseSnapPointsPreCondition && percentageDragged >= 1) {
|
|
913
|
-
return;
|
|
914
|
-
}
|
|
915
|
-
if (!isAllowedToDrag.current && !shouldDrag(event.target, isDraggingInDirection)) return;
|
|
916
|
-
drawerRef.current.classList.add(DRAG_CLASS);
|
|
917
|
-
isAllowedToDrag.current = true;
|
|
918
|
-
set(drawerRef.current, {
|
|
919
|
-
transition: "none"
|
|
920
|
-
});
|
|
921
|
-
set(overlayRef.current, {
|
|
922
|
-
transition: "none"
|
|
923
|
-
});
|
|
924
|
-
if (snapPoints) {
|
|
925
|
-
onDragSnapPoints({
|
|
926
|
-
draggedDistance
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
if (isDraggingInDirection && !snapPoints) {
|
|
930
|
-
const dampenedDraggedDistance = dampenValue(draggedDistance);
|
|
931
|
-
const translateValue = Math.min(dampenedDraggedDistance * -1, 0) * directionMultiplier;
|
|
932
|
-
set(drawerRef.current, {
|
|
933
|
-
transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
|
|
934
|
-
});
|
|
935
|
-
return;
|
|
936
|
-
}
|
|
937
|
-
const opacityValue = 1 - percentageDragged;
|
|
938
|
-
if (shouldFade || fadeFromIndex && activeSnapPointIndex === fadeFromIndex - 1) {
|
|
939
|
-
onDragProp == null ? void 0 : onDragProp(event, percentageDragged);
|
|
940
|
-
set(overlayRef.current, {
|
|
941
|
-
opacity: `${opacityValue}`,
|
|
942
|
-
transition: "none"
|
|
943
|
-
}, true);
|
|
944
|
-
}
|
|
945
|
-
if (wrapper && overlayRef.current && shouldScaleBackground) {
|
|
946
|
-
const scaleValue = Math.min(getScale() + percentageDragged * (1 - getScale()), 1);
|
|
947
|
-
const borderRadiusValue = 8 - percentageDragged * 8;
|
|
948
|
-
const translateValue = Math.max(0, 14 - percentageDragged * 14);
|
|
949
|
-
set(wrapper, {
|
|
950
|
-
borderRadius: `${borderRadiusValue}px`,
|
|
951
|
-
transform: isVertical(direction) ? `scale(${scaleValue}) translate3d(0, ${translateValue}px, 0)` : `scale(${scaleValue}) translate3d(${translateValue}px, 0, 0)`,
|
|
952
|
-
transition: "none"
|
|
953
|
-
}, true);
|
|
954
|
-
}
|
|
955
|
-
if (!snapPoints) {
|
|
956
|
-
const translateValue = absDraggedDistance * directionMultiplier;
|
|
957
|
-
set(drawerRef.current, {
|
|
958
|
-
transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
React__default.useEffect(() => {
|
|
964
|
-
window.requestAnimationFrame(() => {
|
|
965
|
-
shouldAnimate.current = true;
|
|
966
|
-
});
|
|
967
|
-
}, []);
|
|
968
|
-
React__default.useEffect(() => {
|
|
969
|
-
var _window_visualViewport;
|
|
970
|
-
function onVisualViewportChange() {
|
|
971
|
-
if (!drawerRef.current || !repositionInputs) return;
|
|
972
|
-
const focusedElement = document.activeElement;
|
|
973
|
-
if (isInput(focusedElement) || keyboardIsOpen.current) {
|
|
974
|
-
var _window_visualViewport2;
|
|
975
|
-
const visualViewportHeight = ((_window_visualViewport2 = window.visualViewport) == null ? void 0 : _window_visualViewport2.height) || 0;
|
|
976
|
-
const totalHeight = window.innerHeight;
|
|
977
|
-
let diffFromInitial = totalHeight - visualViewportHeight;
|
|
978
|
-
const drawerHeight = drawerRef.current.getBoundingClientRect().height || 0;
|
|
979
|
-
const isTallEnough = drawerHeight > totalHeight * 0.8;
|
|
980
|
-
if (!initialDrawerHeight.current) {
|
|
981
|
-
initialDrawerHeight.current = drawerHeight;
|
|
982
|
-
}
|
|
983
|
-
const offsetFromTop = drawerRef.current.getBoundingClientRect().top;
|
|
984
|
-
if (Math.abs(previousDiffFromInitial.current - diffFromInitial) > 60) {
|
|
985
|
-
keyboardIsOpen.current = !keyboardIsOpen.current;
|
|
986
|
-
}
|
|
987
|
-
if (snapPoints && snapPoints.length > 0 && snapPointsOffset && activeSnapPointIndex) {
|
|
988
|
-
const activeSnapPointHeight = snapPointsOffset[activeSnapPointIndex] || 0;
|
|
989
|
-
diffFromInitial += activeSnapPointHeight;
|
|
990
|
-
}
|
|
991
|
-
previousDiffFromInitial.current = diffFromInitial;
|
|
992
|
-
if (drawerHeight > visualViewportHeight || keyboardIsOpen.current) {
|
|
993
|
-
const height = drawerRef.current.getBoundingClientRect().height;
|
|
994
|
-
let newDrawerHeight = height;
|
|
995
|
-
if (height > visualViewportHeight) {
|
|
996
|
-
newDrawerHeight = visualViewportHeight - (isTallEnough ? offsetFromTop : WINDOW_TOP_OFFSET);
|
|
997
|
-
}
|
|
998
|
-
if (fixed) {
|
|
999
|
-
drawerRef.current.style.height = `${height - Math.max(diffFromInitial, 0)}px`;
|
|
1000
|
-
} else {
|
|
1001
|
-
drawerRef.current.style.height = `${Math.max(newDrawerHeight, visualViewportHeight - offsetFromTop)}px`;
|
|
1002
|
-
}
|
|
1003
|
-
} else if (!isMobileFirefox()) {
|
|
1004
|
-
drawerRef.current.style.height = `${initialDrawerHeight.current}px`;
|
|
1005
|
-
}
|
|
1006
|
-
if (snapPoints && snapPoints.length > 0 && !keyboardIsOpen.current) {
|
|
1007
|
-
drawerRef.current.style.bottom = `0px`;
|
|
1008
|
-
} else {
|
|
1009
|
-
drawerRef.current.style.bottom = `${Math.max(diffFromInitial, 0)}px`;
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
(_window_visualViewport = window.visualViewport) == null ? void 0 : _window_visualViewport.addEventListener("resize", onVisualViewportChange);
|
|
1014
|
-
return () => {
|
|
1015
|
-
var _window_visualViewport2;
|
|
1016
|
-
return (_window_visualViewport2 = window.visualViewport) == null ? void 0 : _window_visualViewport2.removeEventListener("resize", onVisualViewportChange);
|
|
1017
|
-
};
|
|
1018
|
-
}, [
|
|
1019
|
-
activeSnapPointIndex,
|
|
1020
|
-
snapPoints,
|
|
1021
|
-
snapPointsOffset
|
|
1022
|
-
]);
|
|
1023
|
-
function closeDrawer(fromWithin) {
|
|
1024
|
-
cancelDrag();
|
|
1025
|
-
onClose == null ? void 0 : onClose();
|
|
1026
|
-
if (!fromWithin) {
|
|
1027
|
-
setIsOpen(false);
|
|
1028
|
-
}
|
|
1029
|
-
setTimeout(() => {
|
|
1030
|
-
if (snapPoints) {
|
|
1031
|
-
setActiveSnapPoint(snapPoints[0]);
|
|
1032
|
-
}
|
|
1033
|
-
}, TRANSITIONS.DURATION * 1e3);
|
|
1034
|
-
}
|
|
1035
|
-
function resetDrawer() {
|
|
1036
|
-
if (!drawerRef.current) return;
|
|
1037
|
-
const wrapper = document.querySelector("[data-vaul-drawer-wrapper]");
|
|
1038
|
-
const currentSwipeAmount = getTranslate(drawerRef.current, direction);
|
|
1039
|
-
set(drawerRef.current, {
|
|
1040
|
-
transform: "translate3d(0, 0, 0)",
|
|
1041
|
-
transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`
|
|
1042
|
-
});
|
|
1043
|
-
set(overlayRef.current, {
|
|
1044
|
-
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
|
|
1045
|
-
opacity: "1"
|
|
1046
|
-
});
|
|
1047
|
-
if (shouldScaleBackground && currentSwipeAmount && currentSwipeAmount > 0 && isOpen) {
|
|
1048
|
-
set(wrapper, {
|
|
1049
|
-
borderRadius: `${BORDER_RADIUS}px`,
|
|
1050
|
-
overflow: "hidden",
|
|
1051
|
-
...isVertical(direction) ? {
|
|
1052
|
-
transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
|
|
1053
|
-
transformOrigin: "top"
|
|
1054
|
-
} : {
|
|
1055
|
-
transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
|
|
1056
|
-
transformOrigin: "left"
|
|
1057
|
-
},
|
|
1058
|
-
transitionProperty: "transform, border-radius",
|
|
1059
|
-
transitionDuration: `${TRANSITIONS.DURATION}s`,
|
|
1060
|
-
transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(",")})`
|
|
1061
|
-
}, true);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
function cancelDrag() {
|
|
1065
|
-
if (!isDragging || !drawerRef.current) return;
|
|
1066
|
-
drawerRef.current.classList.remove(DRAG_CLASS);
|
|
1067
|
-
isAllowedToDrag.current = false;
|
|
1068
|
-
setIsDragging(false);
|
|
1069
|
-
dragEndTime.current = /* @__PURE__ */ new Date();
|
|
1070
|
-
}
|
|
1071
|
-
function onRelease(event) {
|
|
1072
|
-
if (!isDragging || !drawerRef.current) return;
|
|
1073
|
-
drawerRef.current.classList.remove(DRAG_CLASS);
|
|
1074
|
-
isAllowedToDrag.current = false;
|
|
1075
|
-
setIsDragging(false);
|
|
1076
|
-
dragEndTime.current = /* @__PURE__ */ new Date();
|
|
1077
|
-
const swipeAmount = getTranslate(drawerRef.current, direction);
|
|
1078
|
-
if (!event || !shouldDrag(event.target, false) || !swipeAmount || Number.isNaN(swipeAmount)) return;
|
|
1079
|
-
if (dragStartTime.current === null) return;
|
|
1080
|
-
const timeTaken = dragEndTime.current.getTime() - dragStartTime.current.getTime();
|
|
1081
|
-
const distMoved = pointerStart.current - (isVertical(direction) ? event.pageY : event.pageX);
|
|
1082
|
-
const velocity = Math.abs(distMoved) / timeTaken;
|
|
1083
|
-
if (velocity > 0.05) {
|
|
1084
|
-
setJustReleased(true);
|
|
1085
|
-
setTimeout(() => {
|
|
1086
|
-
setJustReleased(false);
|
|
1087
|
-
}, 200);
|
|
1088
|
-
}
|
|
1089
|
-
if (snapPoints) {
|
|
1090
|
-
const directionMultiplier = direction === "bottom" || direction === "right" ? 1 : -1;
|
|
1091
|
-
onReleaseSnapPoints({
|
|
1092
|
-
draggedDistance: distMoved * directionMultiplier,
|
|
1093
|
-
closeDrawer,
|
|
1094
|
-
velocity,
|
|
1095
|
-
dismissible
|
|
1096
|
-
});
|
|
1097
|
-
onReleaseProp == null ? void 0 : onReleaseProp(event, true);
|
|
1098
|
-
return;
|
|
1099
|
-
}
|
|
1100
|
-
if (direction === "bottom" || direction === "right" ? distMoved > 0 : distMoved < 0) {
|
|
1101
|
-
resetDrawer();
|
|
1102
|
-
onReleaseProp == null ? void 0 : onReleaseProp(event, true);
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1105
|
-
if (velocity > VELOCITY_THRESHOLD) {
|
|
1106
|
-
closeDrawer();
|
|
1107
|
-
onReleaseProp == null ? void 0 : onReleaseProp(event, false);
|
|
1108
|
-
return;
|
|
1109
|
-
}
|
|
1110
|
-
var _drawerRef_current_getBoundingClientRect_height;
|
|
1111
|
-
const visibleDrawerHeight = Math.min((_drawerRef_current_getBoundingClientRect_height = drawerRef.current.getBoundingClientRect().height) != null ? _drawerRef_current_getBoundingClientRect_height : 0, window.innerHeight);
|
|
1112
|
-
var _drawerRef_current_getBoundingClientRect_width;
|
|
1113
|
-
const visibleDrawerWidth = Math.min((_drawerRef_current_getBoundingClientRect_width = drawerRef.current.getBoundingClientRect().width) != null ? _drawerRef_current_getBoundingClientRect_width : 0, window.innerWidth);
|
|
1114
|
-
const isHorizontalSwipe = direction === "left" || direction === "right";
|
|
1115
|
-
if (Math.abs(swipeAmount) >= (isHorizontalSwipe ? visibleDrawerWidth : visibleDrawerHeight) * closeThreshold) {
|
|
1116
|
-
closeDrawer();
|
|
1117
|
-
onReleaseProp == null ? void 0 : onReleaseProp(event, false);
|
|
1118
|
-
return;
|
|
1119
|
-
}
|
|
1120
|
-
onReleaseProp == null ? void 0 : onReleaseProp(event, true);
|
|
1121
|
-
resetDrawer();
|
|
1122
|
-
}
|
|
1123
|
-
React__default.useEffect(() => {
|
|
1124
|
-
if (isOpen) {
|
|
1125
|
-
set(document.documentElement, {
|
|
1126
|
-
scrollBehavior: "auto"
|
|
1127
|
-
});
|
|
1128
|
-
openTime.current = /* @__PURE__ */ new Date();
|
|
1129
|
-
}
|
|
1130
|
-
return () => {
|
|
1131
|
-
reset(document.documentElement, "scrollBehavior");
|
|
1132
|
-
};
|
|
1133
|
-
}, [
|
|
1134
|
-
isOpen
|
|
1135
|
-
]);
|
|
1136
|
-
function onNestedOpenChange(o) {
|
|
1137
|
-
const scale = o ? (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth : 1;
|
|
1138
|
-
const initialTranslate = o ? -NESTED_DISPLACEMENT : 0;
|
|
1139
|
-
if (nestedOpenChangeTimer.current) {
|
|
1140
|
-
window.clearTimeout(nestedOpenChangeTimer.current);
|
|
1141
|
-
}
|
|
1142
|
-
set(drawerRef.current, {
|
|
1143
|
-
transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
|
|
1144
|
-
transform: isVertical(direction) ? `scale(${scale}) translate3d(0, ${initialTranslate}px, 0)` : `scale(${scale}) translate3d(${initialTranslate}px, 0, 0)`
|
|
1145
|
-
});
|
|
1146
|
-
if (!o && drawerRef.current) {
|
|
1147
|
-
nestedOpenChangeTimer.current = setTimeout(() => {
|
|
1148
|
-
const translateValue = getTranslate(drawerRef.current, direction);
|
|
1149
|
-
set(drawerRef.current, {
|
|
1150
|
-
transition: "none",
|
|
1151
|
-
transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
|
|
1152
|
-
});
|
|
1153
|
-
}, 500);
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
function onNestedDrag(_event, percentageDragged) {
|
|
1157
|
-
if (percentageDragged < 0) return;
|
|
1158
|
-
const initialScale = (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth;
|
|
1159
|
-
const newScale = initialScale + percentageDragged * (1 - initialScale);
|
|
1160
|
-
const newTranslate = -NESTED_DISPLACEMENT + percentageDragged * NESTED_DISPLACEMENT;
|
|
1161
|
-
set(drawerRef.current, {
|
|
1162
|
-
transform: isVertical(direction) ? `scale(${newScale}) translate3d(0, ${newTranslate}px, 0)` : `scale(${newScale}) translate3d(${newTranslate}px, 0, 0)`,
|
|
1163
|
-
transition: "none"
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
function onNestedRelease(_event, o) {
|
|
1167
|
-
const dim = isVertical(direction) ? window.innerHeight : window.innerWidth;
|
|
1168
|
-
const scale = o ? (dim - NESTED_DISPLACEMENT) / dim : 1;
|
|
1169
|
-
const translate = o ? -NESTED_DISPLACEMENT : 0;
|
|
1170
|
-
if (o) {
|
|
1171
|
-
set(drawerRef.current, {
|
|
1172
|
-
transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(",")})`,
|
|
1173
|
-
transform: isVertical(direction) ? `scale(${scale}) translate3d(0, ${translate}px, 0)` : `scale(${scale}) translate3d(${translate}px, 0, 0)`
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
React__default.useEffect(() => {
|
|
1178
|
-
if (!modal) {
|
|
1179
|
-
window.requestAnimationFrame(() => {
|
|
1180
|
-
document.body.style.pointerEvents = "auto";
|
|
1181
|
-
});
|
|
1182
|
-
}
|
|
1183
|
-
}, [
|
|
1184
|
-
modal
|
|
1185
|
-
]);
|
|
1186
|
-
return /* @__PURE__ */ React__default.createElement(DialogPrimitive.Root, {
|
|
1187
|
-
defaultOpen,
|
|
1188
|
-
onOpenChange: (open) => {
|
|
1189
|
-
if (!dismissible && !open) return;
|
|
1190
|
-
if (open) {
|
|
1191
|
-
setHasBeenOpened(true);
|
|
1192
|
-
} else {
|
|
1193
|
-
closeDrawer(true);
|
|
1194
|
-
}
|
|
1195
|
-
setIsOpen(open);
|
|
1196
|
-
},
|
|
1197
|
-
open: isOpen
|
|
1198
|
-
}, /* @__PURE__ */ React__default.createElement(DrawerContext.Provider, {
|
|
1199
|
-
value: {
|
|
1200
|
-
activeSnapPoint,
|
|
1201
|
-
snapPoints,
|
|
1202
|
-
setActiveSnapPoint,
|
|
1203
|
-
drawerRef,
|
|
1204
|
-
overlayRef,
|
|
1205
|
-
onOpenChange,
|
|
1206
|
-
onPress,
|
|
1207
|
-
onRelease,
|
|
1208
|
-
onDrag,
|
|
1209
|
-
dismissible,
|
|
1210
|
-
shouldAnimate,
|
|
1211
|
-
handleOnly,
|
|
1212
|
-
isOpen,
|
|
1213
|
-
isDragging,
|
|
1214
|
-
shouldFade,
|
|
1215
|
-
closeDrawer,
|
|
1216
|
-
onNestedDrag,
|
|
1217
|
-
onNestedOpenChange,
|
|
1218
|
-
onNestedRelease,
|
|
1219
|
-
keyboardIsOpen,
|
|
1220
|
-
modal,
|
|
1221
|
-
snapPointsOffset,
|
|
1222
|
-
activeSnapPointIndex,
|
|
1223
|
-
direction,
|
|
1224
|
-
shouldScaleBackground,
|
|
1225
|
-
setBackgroundColorOnScale,
|
|
1226
|
-
noBodyStyles,
|
|
1227
|
-
container,
|
|
1228
|
-
autoFocus
|
|
1229
|
-
}
|
|
1230
|
-
}, children));
|
|
1231
|
-
}
|
|
1232
|
-
var Overlay2 = /* @__PURE__ */ React__default.forwardRef(function({ ...rest }, ref) {
|
|
1233
|
-
const { overlayRef, snapPoints, onRelease, shouldFade, isOpen, modal, shouldAnimate } = useDrawerContext();
|
|
1234
|
-
const composedRef = useComposedRefs(ref, overlayRef);
|
|
1235
|
-
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
1236
|
-
if (!modal) {
|
|
1237
|
-
return null;
|
|
1238
|
-
}
|
|
1239
|
-
const onMouseUp = React__default.useCallback((event) => onRelease(event), [
|
|
1240
|
-
onRelease
|
|
1241
|
-
]);
|
|
1242
|
-
return /* @__PURE__ */ React__default.createElement(DialogPrimitive.Overlay, {
|
|
1243
|
-
onMouseUp,
|
|
1244
|
-
ref: composedRef,
|
|
1245
|
-
"data-vaul-overlay": "",
|
|
1246
|
-
"data-vaul-snap-points": isOpen && hasSnapPoints ? "true" : "false",
|
|
1247
|
-
"data-vaul-snap-points-overlay": isOpen && shouldFade ? "true" : "false",
|
|
1248
|
-
"data-vaul-animate": (shouldAnimate == null ? void 0 : shouldAnimate.current) ? "true" : "false",
|
|
1249
|
-
...rest
|
|
1250
|
-
});
|
|
1251
|
-
});
|
|
1252
|
-
Overlay2.displayName = "Drawer.Overlay";
|
|
1253
|
-
var Content2 = /* @__PURE__ */ React__default.forwardRef(function({ onPointerDownOutside, style, onOpenAutoFocus, ...rest }, ref) {
|
|
1254
|
-
const { drawerRef, onPress, onRelease, onDrag, keyboardIsOpen, snapPointsOffset, activeSnapPointIndex, modal, isOpen, direction, snapPoints, container, handleOnly, shouldAnimate, autoFocus } = useDrawerContext();
|
|
1255
|
-
const [delayedSnapPoints, setDelayedSnapPoints] = React__default.useState(false);
|
|
1256
|
-
const composedRef = useComposedRefs(ref, drawerRef);
|
|
1257
|
-
const pointerStartRef = React__default.useRef(null);
|
|
1258
|
-
const lastKnownPointerEventRef = React__default.useRef(null);
|
|
1259
|
-
const wasBeyondThePointRef = React__default.useRef(false);
|
|
1260
|
-
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
1261
|
-
useScaleBackground();
|
|
1262
|
-
const isDeltaInDirection = (delta, direction2, threshold = 0) => {
|
|
1263
|
-
if (wasBeyondThePointRef.current) return true;
|
|
1264
|
-
const deltaY = Math.abs(delta.y);
|
|
1265
|
-
const deltaX = Math.abs(delta.x);
|
|
1266
|
-
const isDeltaX = deltaX > deltaY;
|
|
1267
|
-
const dFactor = [
|
|
1268
|
-
"bottom",
|
|
1269
|
-
"right"
|
|
1270
|
-
].includes(direction2) ? 1 : -1;
|
|
1271
|
-
if (direction2 === "left" || direction2 === "right") {
|
|
1272
|
-
const isReverseDirection = delta.x * dFactor < 0;
|
|
1273
|
-
if (!isReverseDirection && deltaX >= 0 && deltaX <= threshold) {
|
|
1274
|
-
return isDeltaX;
|
|
1275
|
-
}
|
|
1276
|
-
} else {
|
|
1277
|
-
const isReverseDirection = delta.y * dFactor < 0;
|
|
1278
|
-
if (!isReverseDirection && deltaY >= 0 && deltaY <= threshold) {
|
|
1279
|
-
return !isDeltaX;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
wasBeyondThePointRef.current = true;
|
|
1283
|
-
return true;
|
|
1284
|
-
};
|
|
1285
|
-
React__default.useEffect(() => {
|
|
1286
|
-
if (hasSnapPoints) {
|
|
1287
|
-
window.requestAnimationFrame(() => {
|
|
1288
|
-
setDelayedSnapPoints(true);
|
|
1289
|
-
});
|
|
1290
|
-
}
|
|
1291
|
-
}, []);
|
|
1292
|
-
function handleOnPointerUp(event) {
|
|
1293
|
-
pointerStartRef.current = null;
|
|
1294
|
-
wasBeyondThePointRef.current = false;
|
|
1295
|
-
onRelease(event);
|
|
1296
|
-
}
|
|
1297
|
-
return /* @__PURE__ */ React__default.createElement(DialogPrimitive.Content, {
|
|
1298
|
-
"data-vaul-drawer-direction": direction,
|
|
1299
|
-
"data-vaul-drawer": "",
|
|
1300
|
-
"data-vaul-delayed-snap-points": delayedSnapPoints ? "true" : "false",
|
|
1301
|
-
"data-vaul-snap-points": isOpen && hasSnapPoints ? "true" : "false",
|
|
1302
|
-
"data-vaul-custom-container": container ? "true" : "false",
|
|
1303
|
-
"data-vaul-animate": (shouldAnimate == null ? void 0 : shouldAnimate.current) ? "true" : "false",
|
|
1304
|
-
...rest,
|
|
1305
|
-
ref: composedRef,
|
|
1306
|
-
style: snapPointsOffset && snapPointsOffset.length > 0 ? {
|
|
1307
|
-
"--snap-point-height": `${snapPointsOffset[activeSnapPointIndex != null ? activeSnapPointIndex : 0]}px`,
|
|
1308
|
-
...style
|
|
1309
|
-
} : style,
|
|
1310
|
-
onPointerDown: (event) => {
|
|
1311
|
-
if (handleOnly) return;
|
|
1312
|
-
rest.onPointerDown == null ? void 0 : rest.onPointerDown.call(rest, event);
|
|
1313
|
-
pointerStartRef.current = {
|
|
1314
|
-
x: event.pageX,
|
|
1315
|
-
y: event.pageY
|
|
1316
|
-
};
|
|
1317
|
-
onPress(event);
|
|
1318
|
-
},
|
|
1319
|
-
onOpenAutoFocus: (e) => {
|
|
1320
|
-
onOpenAutoFocus == null ? void 0 : onOpenAutoFocus(e);
|
|
1321
|
-
if (!autoFocus) {
|
|
1322
|
-
e.preventDefault();
|
|
1323
|
-
}
|
|
1324
|
-
},
|
|
1325
|
-
onPointerDownOutside: (e) => {
|
|
1326
|
-
onPointerDownOutside == null ? void 0 : onPointerDownOutside(e);
|
|
1327
|
-
if (!modal || e.defaultPrevented) {
|
|
1328
|
-
e.preventDefault();
|
|
1329
|
-
return;
|
|
1330
|
-
}
|
|
1331
|
-
if (keyboardIsOpen.current) {
|
|
1332
|
-
keyboardIsOpen.current = false;
|
|
1333
|
-
}
|
|
1334
|
-
},
|
|
1335
|
-
onFocusOutside: (e) => {
|
|
1336
|
-
if (!modal) {
|
|
1337
|
-
e.preventDefault();
|
|
1338
|
-
return;
|
|
1339
|
-
}
|
|
1340
|
-
},
|
|
1341
|
-
onPointerMove: (event) => {
|
|
1342
|
-
lastKnownPointerEventRef.current = event;
|
|
1343
|
-
if (handleOnly) return;
|
|
1344
|
-
rest.onPointerMove == null ? void 0 : rest.onPointerMove.call(rest, event);
|
|
1345
|
-
if (!pointerStartRef.current) return;
|
|
1346
|
-
const yPosition = event.pageY - pointerStartRef.current.y;
|
|
1347
|
-
const xPosition = event.pageX - pointerStartRef.current.x;
|
|
1348
|
-
const swipeStartThreshold = event.pointerType === "touch" ? 10 : 2;
|
|
1349
|
-
const delta = {
|
|
1350
|
-
x: xPosition,
|
|
1351
|
-
y: yPosition
|
|
1352
|
-
};
|
|
1353
|
-
const isAllowedToSwipe = isDeltaInDirection(delta, direction, swipeStartThreshold);
|
|
1354
|
-
if (isAllowedToSwipe) onDrag(event);
|
|
1355
|
-
else if (Math.abs(xPosition) > swipeStartThreshold || Math.abs(yPosition) > swipeStartThreshold) {
|
|
1356
|
-
pointerStartRef.current = null;
|
|
1357
|
-
}
|
|
1358
|
-
},
|
|
1359
|
-
onPointerUp: (event) => {
|
|
1360
|
-
rest.onPointerUp == null ? void 0 : rest.onPointerUp.call(rest, event);
|
|
1361
|
-
pointerStartRef.current = null;
|
|
1362
|
-
wasBeyondThePointRef.current = false;
|
|
1363
|
-
onRelease(event);
|
|
1364
|
-
},
|
|
1365
|
-
onPointerOut: (event) => {
|
|
1366
|
-
rest.onPointerOut == null ? void 0 : rest.onPointerOut.call(rest, event);
|
|
1367
|
-
handleOnPointerUp(lastKnownPointerEventRef.current);
|
|
1368
|
-
},
|
|
1369
|
-
onContextMenu: (event) => {
|
|
1370
|
-
rest.onContextMenu == null ? void 0 : rest.onContextMenu.call(rest, event);
|
|
1371
|
-
if (lastKnownPointerEventRef.current) {
|
|
1372
|
-
handleOnPointerUp(lastKnownPointerEventRef.current);
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
});
|
|
1376
|
-
});
|
|
1377
|
-
Content2.displayName = "Drawer.Content";
|
|
1378
|
-
var LONG_HANDLE_PRESS_TIMEOUT = 250;
|
|
1379
|
-
var DOUBLE_TAP_TIMEOUT = 120;
|
|
1380
|
-
var Handle = /* @__PURE__ */ React__default.forwardRef(function({ preventCycle = false, children, ...rest }, ref) {
|
|
1381
|
-
const { closeDrawer, isDragging, snapPoints, activeSnapPoint, setActiveSnapPoint, dismissible, handleOnly, isOpen, onPress, onDrag } = useDrawerContext();
|
|
1382
|
-
const closeTimeoutIdRef = React__default.useRef(null);
|
|
1383
|
-
const shouldCancelInteractionRef = React__default.useRef(false);
|
|
1384
|
-
function handleStartCycle() {
|
|
1385
|
-
if (shouldCancelInteractionRef.current) {
|
|
1386
|
-
handleCancelInteraction();
|
|
1387
|
-
return;
|
|
1388
|
-
}
|
|
1389
|
-
window.setTimeout(() => {
|
|
1390
|
-
handleCycleSnapPoints();
|
|
1391
|
-
}, DOUBLE_TAP_TIMEOUT);
|
|
1392
|
-
}
|
|
1393
|
-
function handleCycleSnapPoints() {
|
|
1394
|
-
if (isDragging || preventCycle || shouldCancelInteractionRef.current) {
|
|
1395
|
-
handleCancelInteraction();
|
|
1396
|
-
return;
|
|
1397
|
-
}
|
|
1398
|
-
handleCancelInteraction();
|
|
1399
|
-
if (!snapPoints || snapPoints.length === 0) {
|
|
1400
|
-
if (!dismissible) {
|
|
1401
|
-
closeDrawer();
|
|
1402
|
-
}
|
|
1403
|
-
return;
|
|
1404
|
-
}
|
|
1405
|
-
const isLastSnapPoint = activeSnapPoint === snapPoints[snapPoints.length - 1];
|
|
1406
|
-
if (isLastSnapPoint && dismissible) {
|
|
1407
|
-
closeDrawer();
|
|
1408
|
-
return;
|
|
1409
|
-
}
|
|
1410
|
-
const currentSnapIndex = snapPoints.findIndex((point) => point === activeSnapPoint);
|
|
1411
|
-
if (currentSnapIndex === -1) return;
|
|
1412
|
-
const nextSnapPoint = snapPoints[currentSnapIndex + 1];
|
|
1413
|
-
setActiveSnapPoint(nextSnapPoint);
|
|
1414
|
-
}
|
|
1415
|
-
function handleStartInteraction() {
|
|
1416
|
-
closeTimeoutIdRef.current = window.setTimeout(() => {
|
|
1417
|
-
shouldCancelInteractionRef.current = true;
|
|
1418
|
-
}, LONG_HANDLE_PRESS_TIMEOUT);
|
|
1419
|
-
}
|
|
1420
|
-
function handleCancelInteraction() {
|
|
1421
|
-
if (closeTimeoutIdRef.current) {
|
|
1422
|
-
window.clearTimeout(closeTimeoutIdRef.current);
|
|
1423
|
-
}
|
|
1424
|
-
shouldCancelInteractionRef.current = false;
|
|
1425
|
-
}
|
|
1426
|
-
return /* @__PURE__ */ React__default.createElement("div", {
|
|
1427
|
-
onClick: handleStartCycle,
|
|
1428
|
-
onPointerCancel: handleCancelInteraction,
|
|
1429
|
-
onPointerDown: (e) => {
|
|
1430
|
-
if (handleOnly) onPress(e);
|
|
1431
|
-
handleStartInteraction();
|
|
1432
|
-
},
|
|
1433
|
-
onPointerMove: (e) => {
|
|
1434
|
-
if (handleOnly) onDrag(e);
|
|
1435
|
-
},
|
|
1436
|
-
// onPointerUp is already handled by the content component
|
|
1437
|
-
ref,
|
|
1438
|
-
"data-vaul-drawer-visible": isOpen ? "true" : "false",
|
|
1439
|
-
"data-vaul-handle": "",
|
|
1440
|
-
"aria-hidden": "true",
|
|
1441
|
-
...rest
|
|
1442
|
-
}, /* @__PURE__ */ React__default.createElement("span", {
|
|
1443
|
-
"data-vaul-handle-hitarea": "",
|
|
1444
|
-
"aria-hidden": "true"
|
|
1445
|
-
}, children));
|
|
1446
|
-
});
|
|
1447
|
-
Handle.displayName = "Drawer.Handle";
|
|
1448
|
-
function NestedRoot({ onDrag, onOpenChange, open: nestedIsOpen, ...rest }) {
|
|
1449
|
-
const { onNestedDrag, onNestedOpenChange, onNestedRelease } = useDrawerContext();
|
|
1450
|
-
if (!onNestedDrag) {
|
|
1451
|
-
throw new Error("Drawer.NestedRoot must be placed in another drawer");
|
|
1452
|
-
}
|
|
1453
|
-
return /* @__PURE__ */ React__default.createElement(Root2, {
|
|
1454
|
-
nested: true,
|
|
1455
|
-
open: nestedIsOpen,
|
|
1456
|
-
onClose: () => {
|
|
1457
|
-
onNestedOpenChange(false);
|
|
1458
|
-
},
|
|
1459
|
-
onDrag: (e, p) => {
|
|
1460
|
-
onNestedDrag(e, p);
|
|
1461
|
-
onDrag == null ? void 0 : onDrag(e, p);
|
|
1462
|
-
},
|
|
1463
|
-
onOpenChange: (o) => {
|
|
1464
|
-
if (o) {
|
|
1465
|
-
onNestedOpenChange(o);
|
|
1466
|
-
}
|
|
1467
|
-
onOpenChange == null ? void 0 : onOpenChange(o);
|
|
1468
|
-
},
|
|
1469
|
-
onRelease: onNestedRelease,
|
|
1470
|
-
...rest
|
|
1471
|
-
});
|
|
1472
|
-
}
|
|
1473
|
-
function Portal2(props) {
|
|
1474
|
-
const context = useDrawerContext();
|
|
1475
|
-
const { container = context.container, ...portalProps } = props;
|
|
1476
|
-
return /* @__PURE__ */ React__default.createElement(DialogPrimitive.Portal, {
|
|
1477
|
-
container,
|
|
1478
|
-
...portalProps
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1481
|
-
var Drawer = {
|
|
1482
|
-
Root: Root2,
|
|
1483
|
-
NestedRoot,
|
|
1484
|
-
Content: Content2,
|
|
1485
|
-
Overlay: Overlay2,
|
|
1486
|
-
Trigger: DialogPrimitive.Trigger,
|
|
1487
|
-
Portal: Portal2,
|
|
1488
|
-
Handle,
|
|
1489
|
-
Close: DialogPrimitive.Close,
|
|
1490
|
-
Title: DialogPrimitive.Title,
|
|
1491
|
-
Description: DialogPrimitive.Description
|
|
1492
|
-
};
|
|
1493
|
-
export {
|
|
1494
|
-
Drawer
|
|
1495
|
-
};
|
|
2
|
+
"use client";import*as N from"@radix-ui/react-dialog";import*as Ve from"react";import r,{useLayoutEffect as pt,useEffect as vt,useMemo as yt}from"react";var ze=r.createContext({drawerRef:{current:null},overlayRef:{current:null},onPress:()=>{},onRelease:()=>{},onDrag:()=>{},onNestedDrag:()=>{},onNestedOpenChange:()=>{},onNestedRelease:()=>{},openProp:void 0,dismissible:!1,isOpen:!1,isDragging:!1,keyboardIsOpen:{current:!1},snapPointsOffset:null,snapPoints:null,handleOnly:!1,modal:!1,shouldFade:!1,activeSnapPoint:null,onOpenChange:()=>{},setActiveSnapPoint:()=>{},closeDrawer:()=>{},direction:"bottom",shouldAnimate:{current:!0},shouldScaleBackground:!1,setBackgroundColorOnScale:!0,noBodyStyles:!1,container:null,autoFocus:!1}),oe=()=>{let e=r.useContext(ze);if(!e)throw new Error("useDrawerContext must be used within a Drawer.Root");return e};function bt(){let e=navigator.userAgent;return typeof window<"u"&&(/Firefox/.test(e)&&/Mobile/.test(e)||/FxiOS/.test(e))}function St(){return xe(/^Mac/)}function Dt(){return xe(/^iPhone/)}function Ue(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function Rt(){return xe(/^iPad/)||St()&&navigator.maxTouchPoints>1}function Ye(){return Dt()||Rt()}function xe(e){return typeof window<"u"&&window.navigator!=null?e.test(window.navigator.platform):void 0}var Et=24,Tt=typeof window<"u"?pt:vt;function We(...e){return(...n)=>{for(let t of e)typeof t=="function"&&t(...n)}}var De=typeof document<"u"&&window.visualViewport;function ke(e){let n=window.getComputedStyle(e);return/(auto|scroll)/.test(n.overflow+n.overflowX+n.overflowY)}function je(e){for(ke(e)&&(e=e.parentElement);e&&!ke(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}var Ot=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]),he=0,Re;function Ct(e={}){let{isDisabled:n}=e;Tt(()=>{if(!n)return he++,he===1&&Ye()&&(Re=xt()),()=>{he--,he===0&&Re?.()}},[n])}function xt(){let e,n=0,t=g=>{e=je(g.target),!(e===document.documentElement&&e===document.body)&&(n=g.changedTouches[0].pageY)},i=g=>{if(!e||e===document.documentElement||e===document.body){g.preventDefault();return}let w=g.changedTouches[0].pageY,W=e.scrollTop,B=e.scrollHeight-e.clientHeight;B!==0&&((W<=0&&w>n||W>=B&&w<n)&&g.preventDefault(),n=w)},u=g=>{let w=g.target;Oe(w)&&w!==document.activeElement&&(g.preventDefault(),w.style.transform="translateY(-2000px)",w.focus(),requestAnimationFrame(()=>{w.style.transform=""}))},o=g=>{let w=g.target;Oe(w)&&(w.style.transform="translateY(-2000px)",requestAnimationFrame(()=>{w.style.transform="",De&&(De.height<window.innerHeight?requestAnimationFrame(()=>{Fe(w)}):De.addEventListener("resize",()=>Fe(w),{once:!0}))}))},p=()=>{window.scrollTo(0,0)},l=window.pageXOffset,b=window.pageYOffset,E=We($t(document.documentElement,"paddingRight",`${window.innerWidth-document.documentElement.clientWidth}px`));window.scrollTo(0,0);let m=We(ce(document,"touchstart",t,{passive:!1,capture:!0}),ce(document,"touchmove",i,{passive:!1,capture:!0}),ce(document,"touchend",u,{passive:!1,capture:!0}),ce(document,"focus",o,!0),ce(window,"scroll",p));return()=>{E(),m(),window.scrollTo(l,b)}}function $t(e,n,t){let i=e.style[n];return e.style[n]=t,()=>{e.style[n]=i}}function ce(e,n,t,i){return e.addEventListener(n,t,i),()=>{e.removeEventListener(n,t,i)}}function Fe(e){let n=document.scrollingElement||document.documentElement;for(;e&&e!==n;){let t=je(e);if(t!==document.documentElement&&t!==document.body&&t!==e){let i=t.getBoundingClientRect().top,u=e.getBoundingClientRect().top,o=e.getBoundingClientRect().bottom,p=t.getBoundingClientRect().bottom+Et;o>p&&(t.scrollTop+=u-i)}e=t.parentElement}}function Oe(e){return e instanceof HTMLInputElement&&!Ot.has(e.type)||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function At(e,n){typeof e=="function"?e(n):e!=null&&(e.current=n)}function Pt(...e){return n=>e.forEach(t=>At(t,n))}function qe(...e){return Ve.useCallback(Pt(...e),e)}var Xe=new WeakMap;function $(e,n,t=!1){if(!e||!(e instanceof HTMLElement))return;let i={};Object.entries(n).forEach(([u,o])=>{if(u.startsWith("--")){e.style.setProperty(u,o);return}i[u]=e.style[u],e.style[u]=o}),!t&&Xe.set(e,i)}function Mt(e,n){if(!e||!(e instanceof HTMLElement))return;let t=Xe.get(e);t&&(e.style[n]=t[n])}var x=e=>{switch(e){case"top":case"bottom":return!0;case"left":case"right":return!1;default:return e}};function me(e,n){if(!e)return null;let t=window.getComputedStyle(e),i=t.transform||t.webkitTransform||t.mozTransform,u=i.match(/^matrix3d\((.+)\)$/);return u?parseFloat(u[1].split(", ")[x(n)?13:12]):(u=i.match(/^matrix\((.+)\)$/),u?parseFloat(u[1].split(", ")[x(n)?5:4]):null)}function It(e){return 8*(Math.log(e+1)-2)}function Ee(e,n){if(!e)return()=>{};let t=e.style.cssText;return Object.assign(e.style,n),()=>{e.style.cssText=t}}function Nt(...e){return(...n)=>{for(let t of e)typeof t=="function"&&t(...n)}}var O={DURATION:.5,EASE:[.32,.72,0,1]},Ke=.4,_t=.25,Ht=100,Ge=8,ee=16,Ce=26,Te="vaul-dragging";function Je(e){let n=r.useRef(e);return r.useEffect(()=>{n.current=e}),r.useMemo(()=>(...t)=>n.current==null?void 0:n.current.call(n,...t),[])}function Lt({defaultProp:e,onChange:n}){let t=r.useState(e),[i]=t,u=r.useRef(i),o=Je(n);return r.useEffect(()=>{u.current!==i&&(o(i),u.current=i)},[i,u,o]),t}function Qe({prop:e,defaultProp:n,onChange:t=()=>{}}){let[i,u]=Lt({defaultProp:n,onChange:t}),o=e!==void 0,p=o?e:i,l=Je(t),b=r.useCallback(E=>{if(o){let g=typeof E=="function"?E(e):E;g!==e&&l(g)}else u(E)},[o,e,u,l]);return[p,b]}function Bt({activeSnapPointProp:e,setActiveSnapPointProp:n,snapPoints:t,drawerRef:i,overlayRef:u,fadeFromIndex:o,onSnapPointChange:p,direction:l="bottom",container:b,snapToSequentialPoint:E}){let[m,g]=Qe({prop:e,defaultProp:t?.[0],onChange:n}),[w,W]=r.useState(typeof window<"u"?{innerWidth:window.innerWidth,innerHeight:window.innerHeight}:void 0);r.useEffect(()=>{function c(){W({innerWidth:window.innerWidth,innerHeight:window.innerHeight})}return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]);let B=r.useMemo(()=>m===t?.[t.length-1]||null,[t,m]),T=r.useMemo(()=>{var c;return(c=t?.findIndex(S=>S===m))!=null?c:null},[t,m]),k=t&&t.length>0&&(o||o===0)&&!Number.isNaN(o)&&t[o]===m||!t,h=r.useMemo(()=>{let c=b?{width:b.getBoundingClientRect().width,height:b.getBoundingClientRect().height}:typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0};var S;return(S=t?.map(y=>{let _=typeof y=="string",M=0;if(_&&(M=parseInt(y,10)),x(l)){let s=_?M:w?y*c.height:0;return w?l==="bottom"?c.height-s:-c.height+s:s}let V=_?M:w?y*c.width:0;return w?l==="right"?c.width-V:-c.width+V:V}))!=null?S:[]},[t,w,b]),P=r.useMemo(()=>T!==null?h?.[T]:null,[h,T]),A=r.useCallback(c=>{var S;let y=(S=h?.findIndex(_=>_===c))!=null?S:null;p(y),$(i.current,{transition:`transform ${O.DURATION}s cubic-bezier(${O.EASE.join(",")})`,transform:x(l)?`translate3d(0, ${c}px, 0)`:`translate3d(${c}px, 0, 0)`}),h&&y!==h.length-1&&o!==void 0&&y!==o&&y<o?$(u.current,{transition:`opacity ${O.DURATION}s cubic-bezier(${O.EASE.join(",")})`,opacity:"0"}):$(u.current,{transition:`opacity ${O.DURATION}s cubic-bezier(${O.EASE.join(",")})`,opacity:"1"}),g(t?.[Math.max(y,0)])},[i.current,t,h,o,u,g]);r.useEffect(()=>{if(m||e){var c;let S=(c=t?.findIndex(y=>y===e||y===m))!=null?c:-1;h&&S!==-1&&typeof h[S]=="number"&&A(h[S])}},[m,e,t,h,A]);function f({draggedDistance:c,closeDrawer:S,velocity:y,dismissible:_}){if(o===void 0)return;let M=l==="bottom"||l==="right"?(P??0)-c:(P??0)+c,V=T===o-1,s=T===0,F=c>0;if(V&&$(u.current,{transition:`opacity ${O.DURATION}s cubic-bezier(${O.EASE.join(",")})`}),!E&&y>2&&!F){_?S():A(h[0]);return}if(!E&&y>2&&F&&h&&t){A(h[t.length-1]);return}let H=h?.reduce((I,X)=>typeof I!="number"||typeof X!="number"?I:Math.abs(X-M)<Math.abs(I-M)?X:I),z=x(l)?window.innerHeight:window.innerWidth;if(y>Ke&&Math.abs(c)<z*.4){let I=F?1:-1;if(I>0&&B&&t){A(h[t.length-1]);return}if(s&&I<0&&_&&S(),T===null)return;A(h[T+I]);return}A(H)}function j({draggedDistance:c}){if(P===null)return;let S=l==="bottom"||l==="right"?P-c:P+c;(l==="bottom"||l==="right")&&S<h[h.length-1]||(l==="top"||l==="left")&&S>h[h.length-1]||$(i.current,{transform:x(l)?`translate3d(0, ${S}px, 0)`:`translate3d(${S}px, 0, 0)`})}function Q(c,S){if(!t||typeof T!="number"||!h||o===void 0)return null;let y=T===o-1;if(T>=o&&S)return 0;if(y&&!S)return 1;if(!k&&!y)return null;let M=y?T+1:T-1,V=y?h[M]-h[M-1]:h[M+1]-h[M],s=c/Math.abs(V);return y?1-s:s}return{isLastSnapPoint:B,activeSnapPoint:m,shouldFade:k,getPercentageDragged:Q,setActiveSnapPoint:g,activeSnapPointIndex:T,onRelease:f,onDrag:j,snapPointsOffset:h}}var Ut=()=>()=>{};function Wt(){let{direction:e,isOpen:n,shouldScaleBackground:t,setBackgroundColorOnScale:i,noBodyStyles:u}=oe(),o=r.useRef(null),p=yt(()=>document.body.style.backgroundColor,[]);function l(){return(window.innerWidth-Ce)/window.innerWidth}r.useEffect(()=>{if(n&&t){o.current&&clearTimeout(o.current);let b=document.querySelector("[data-vaul-drawer-wrapper]")||document.querySelector("[vaul-drawer-wrapper]");if(!b)return;Nt(i&&!u?Ee(document.body,{background:"black"}):Ut,Ee(b,{transformOrigin:x(e)?"top":"left",transitionProperty:"transform, border-radius",transitionDuration:`${O.DURATION}s`,transitionTimingFunction:`cubic-bezier(${O.EASE.join(",")})`}));let E=Ee(b,{borderRadius:`${Ge}px`,overflow:"hidden",...x(e)?{transform:`scale(${l()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`}:{transform:`scale(${l()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`}});return()=>{E(),o.current=window.setTimeout(()=>{p?document.body.style.background=p:document.body.style.removeProperty("background")},O.DURATION*1e3)}}},[n,t,p])}var fe=null;function kt({isOpen:e,modal:n,nested:t,hasBeenOpened:i,preventScrollRestoration:u,noBodyStyles:o}){let[p,l]=r.useState(()=>typeof window<"u"?window.location.href:""),b=r.useRef(0),E=r.useCallback(()=>{if(Ue()&&fe===null&&e&&!o){fe={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,height:document.body.style.height,right:"unset"};let{scrollX:g,innerHeight:w}=window;document.body.style.setProperty("position","fixed","important"),Object.assign(document.body.style,{top:`${-b.current}px`,left:`${-g}px`,right:"0px",height:"auto"}),window.setTimeout(()=>window.requestAnimationFrame(()=>{let W=w-window.innerHeight;W&&b.current>=w&&(document.body.style.top=`${-(b.current+W)}px`)}),300)}},[e]),m=r.useCallback(()=>{if(Ue()&&fe!==null&&!o){let g=-parseInt(document.body.style.top,10),w=-parseInt(document.body.style.left,10);Object.assign(document.body.style,fe),window.requestAnimationFrame(()=>{if(u&&p!==window.location.href){l(window.location.href);return}window.scrollTo(w,g)}),fe=null}},[p]);return r.useEffect(()=>{function g(){b.current=window.scrollY}return g(),window.addEventListener("scroll",g),()=>{window.removeEventListener("scroll",g)}},[]),r.useEffect(()=>{if(n)return()=>{typeof document>"u"||document.querySelector("[data-vaul-drawer]")||m()}},[n,m]),r.useEffect(()=>{t||!i||(e?(!window.matchMedia("(display-mode: standalone)").matches&&E(),n||window.setTimeout(()=>{m()},500)):m())},[e,i,p,n,t,E,m]),{restorePositionSetting:m}}function Ze({open:e,onOpenChange:n,children:t,onDrag:i,onRelease:u,snapPoints:o,shouldScaleBackground:p=!1,setBackgroundColorOnScale:l=!0,closeThreshold:b=_t,scrollLockTimeout:E=Ht,dismissible:m=!0,handleOnly:g=!1,fadeFromIndex:w=o&&o.length-1,activeSnapPoint:W,setActiveSnapPoint:B,fixed:T,modal:k=!0,onClose:h,nested:P,noBodyStyles:A=!1,direction:f="bottom",defaultOpen:j=!1,disablePreventScroll:Q=!0,snapToSequentialPoint:c=!1,preventScrollRestoration:S=!1,repositionInputs:y=!0,onAnimationEnd:_,container:M,autoFocus:V=!1}){var s,F;let[H=!1,z]=Qe({defaultProp:j,prop:e,onChange:a=>{n?.(a),!a&&!P&<(),setTimeout(()=>{_?.(a)},O.DURATION*1e3),a&&!k&&typeof window<"u"&&window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"}),a||(document.body.style.pointerEvents="auto")}}),[I,X]=r.useState(!1),[K,ie]=r.useState(!1),[rt,$e]=r.useState(!1),te=r.useRef(null),de=r.useRef(null),pe=r.useRef(null),ve=r.useRef(null),ue=r.useRef(null),ae=r.useRef(!1),ye=r.useRef(null),be=r.useRef(0),ne=r.useRef(!1),Ae=r.useRef(!j),Pe=r.useRef(0),d=r.useRef(null),Me=r.useRef(((s=d.current)==null?void 0:s.getBoundingClientRect().height)||0),Ie=r.useRef(((F=d.current)==null?void 0:F.getBoundingClientRect().width)||0),Se=r.useRef(0),ot=r.useCallback(a=>{o&&a===se.length-1&&(de.current=new Date)},[]),{activeSnapPoint:it,activeSnapPointIndex:re,setActiveSnapPoint:Ne,onRelease:ut,snapPointsOffset:se,onDrag:at,shouldFade:_e,getPercentageDragged:st}=Bt({snapPoints:o,activeSnapPointProp:W,setActiveSnapPointProp:B,drawerRef:d,fadeFromIndex:w,overlayRef:te,onSnapPointChange:ot,direction:f,container:M,snapToSequentialPoint:c});Ct({isDisabled:!H||K||!k||rt||!I||!y||!Q});let{restorePositionSetting:lt}=kt({isOpen:H,modal:k,nested:P??!1,hasBeenOpened:I,preventScrollRestoration:S,noBodyStyles:A});function ge(){return(window.innerWidth-Ce)/window.innerWidth}function ct(a){var D,R;!m&&!o||d.current&&!d.current.contains(a.target)||(Me.current=((D=d.current)==null?void 0:D.getBoundingClientRect().height)||0,Ie.current=((R=d.current)==null?void 0:R.getBoundingClientRect().width)||0,ie(!0),pe.current=new Date,Ye()&&window.addEventListener("touchend",()=>ae.current=!1,{once:!0}),a.target.setPointerCapture(a.pointerId),be.current=x(f)?a.pageY:a.pageX)}function He(a,D){var R;let v=a,C=(R=window.getSelection())==null?void 0:R.toString(),U=d.current?me(d.current,f):null,L=new Date;if(v.tagName==="SELECT"||v.hasAttribute("data-vaul-no-drag")||v.closest("[data-vaul-no-drag]"))return!1;if(f==="right"||f==="left")return!0;if(de.current&&L.getTime()-de.current.getTime()<500)return!1;if(U!==null&&(f==="bottom"?U>0:U<0))return!0;if(C&&C.length>0)return!1;if(ue.current&&L.getTime()-ue.current.getTime()<E&&U===0||D)return ue.current=L,!1;for(;v;){if(v.scrollHeight>v.clientHeight){if(v.scrollTop!==0)return ue.current=new Date,!1;if(v.getAttribute("role")==="dialog")return!0}v=v.parentNode}return!0}function ft(a){if(d.current&&K){let D=f==="bottom"||f==="right"?1:-1,R=(be.current-(x(f)?a.pageY:a.pageX))*D,v=R>0,C=o&&!m&&!v;if(C&&re===0)return;let U=Math.abs(R),L=document.querySelector("[data-vaul-drawer-wrapper]"),G=f==="bottom"||f==="top"?Me.current:Ie.current,Y=U/G,Z=st(U,v);if(Z!==null&&(Y=Z),C&&Y>=1||!ae.current&&!He(a.target,v))return;if(d.current.classList.add(Te),ae.current=!0,$(d.current,{transition:"none"}),$(te.current,{transition:"none"}),o&&at({draggedDistance:R}),v&&!o){let q=It(R),we=Math.min(q*-1,0)*D;$(d.current,{transform:x(f)?`translate3d(0, ${we}px, 0)`:`translate3d(${we}px, 0, 0)`});return}let J=1-Y;if((_e||w&&re===w-1)&&(i?.(a,Y),$(te.current,{opacity:`${J}`,transition:"none"},!0)),L&&te.current&&p){let q=Math.min(ge()+Y*(1-ge()),1),we=8-Y*8,Be=Math.max(0,14-Y*14);$(L,{borderRadius:`${we}px`,transform:x(f)?`scale(${q}) translate3d(0, ${Be}px, 0)`:`scale(${q}) translate3d(${Be}px, 0, 0)`,transition:"none"},!0)}if(!o){let q=U*D;$(d.current,{transform:x(f)?`translate3d(0, ${q}px, 0)`:`translate3d(${q}px, 0, 0)`})}}}r.useEffect(()=>{window.requestAnimationFrame(()=>{Ae.current=!0})},[]),r.useEffect(()=>{var a;function D(){if(!d.current||!y)return;let R=document.activeElement;if(Oe(R)||ne.current){var v;let C=((v=window.visualViewport)==null?void 0:v.height)||0,U=window.innerHeight,L=U-C,G=d.current.getBoundingClientRect().height||0,Y=G>U*.8;Se.current||(Se.current=G);let Z=d.current.getBoundingClientRect().top;if(Math.abs(Pe.current-L)>60&&(ne.current=!ne.current),o&&o.length>0&&se&&re){let J=se[re]||0;L+=J}if(Pe.current=L,G>C||ne.current){let J=d.current.getBoundingClientRect().height,q=J;J>C&&(q=C-(Y?Z:Ce)),T?d.current.style.height=`${J-Math.max(L,0)}px`:d.current.style.height=`${Math.max(q,C-Z)}px`}else bt()||(d.current.style.height=`${Se.current}px`);o&&o.length>0&&!ne.current?d.current.style.bottom="0px":d.current.style.bottom=`${Math.max(L,0)}px`}}return(a=window.visualViewport)==null||a.addEventListener("resize",D),()=>{var R;return(R=window.visualViewport)==null?void 0:R.removeEventListener("resize",D)}},[re,o,se]);function le(a){dt(),h?.(),a||z(!1),setTimeout(()=>{o&&Ne(o[0])},O.DURATION*1e3)}function Le(){if(!d.current)return;let a=document.querySelector("[data-vaul-drawer-wrapper]"),D=me(d.current,f);$(d.current,{transform:"translate3d(0, 0, 0)",transition:`transform ${O.DURATION}s cubic-bezier(${O.EASE.join(",")})`}),$(te.current,{transition:`opacity ${O.DURATION}s cubic-bezier(${O.EASE.join(",")})`,opacity:"1"}),p&&D&&D>0&&H&&$(a,{borderRadius:`${Ge}px`,overflow:"hidden",...x(f)?{transform:`scale(${ge()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,transformOrigin:"top"}:{transform:`scale(${ge()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,transformOrigin:"left"},transitionProperty:"transform, border-radius",transitionDuration:`${O.DURATION}s`,transitionTimingFunction:`cubic-bezier(${O.EASE.join(",")})`},!0)}function dt(){!K||!d.current||(d.current.classList.remove(Te),ae.current=!1,ie(!1),ve.current=new Date)}function gt(a){if(!K||!d.current)return;d.current.classList.remove(Te),ae.current=!1,ie(!1),ve.current=new Date;let D=me(d.current,f);if(!a||!He(a.target,!1)||!D||Number.isNaN(D)||pe.current===null)return;let R=ve.current.getTime()-pe.current.getTime(),v=be.current-(x(f)?a.pageY:a.pageX),C=Math.abs(v)/R;if(C>.05&&($e(!0),setTimeout(()=>{$e(!1)},200)),o){ut({draggedDistance:v*(f==="bottom"||f==="right"?1:-1),closeDrawer:le,velocity:C,dismissible:m}),u?.(a,!0);return}if(f==="bottom"||f==="right"?v>0:v<0){Le(),u?.(a,!0);return}if(C>Ke){le(),u?.(a,!1);return}var U;let L=Math.min((U=d.current.getBoundingClientRect().height)!=null?U:0,window.innerHeight);var G;let Y=Math.min((G=d.current.getBoundingClientRect().width)!=null?G:0,window.innerWidth),Z=f==="left"||f==="right";if(Math.abs(D)>=(Z?Y:L)*b){le(),u?.(a,!1);return}u?.(a,!0),Le()}r.useEffect(()=>(H&&($(document.documentElement,{scrollBehavior:"auto"}),de.current=new Date),()=>{Mt(document.documentElement,"scrollBehavior")}),[H]);function wt(a){let D=a?(window.innerWidth-ee)/window.innerWidth:1,R=a?-ee:0;ye.current&&window.clearTimeout(ye.current),$(d.current,{transition:`transform ${O.DURATION}s cubic-bezier(${O.EASE.join(",")})`,transform:x(f)?`scale(${D}) translate3d(0, ${R}px, 0)`:`scale(${D}) translate3d(${R}px, 0, 0)`}),!a&&d.current&&(ye.current=setTimeout(()=>{let v=me(d.current,f);$(d.current,{transition:"none",transform:x(f)?`translate3d(0, ${v}px, 0)`:`translate3d(${v}px, 0, 0)`})},500))}function ht(a,D){if(D<0)return;let R=(window.innerWidth-ee)/window.innerWidth,v=R+D*(1-R),C=-ee+D*ee;$(d.current,{transform:x(f)?`scale(${v}) translate3d(0, ${C}px, 0)`:`scale(${v}) translate3d(${C}px, 0, 0)`,transition:"none"})}function mt(a,D){let R=x(f)?window.innerHeight:window.innerWidth,v=D?(R-ee)/R:1,C=D?-ee:0;D&&$(d.current,{transition:`transform ${O.DURATION}s cubic-bezier(${O.EASE.join(",")})`,transform:x(f)?`scale(${v}) translate3d(0, ${C}px, 0)`:`scale(${v}) translate3d(${C}px, 0, 0)`})}return r.useEffect(()=>{k||window.requestAnimationFrame(()=>{document.body.style.pointerEvents="auto"})},[k]),r.createElement(N.Root,{defaultOpen:j,onOpenChange:a=>{!m&&!a||(a?X(!0):le(!0),z(a))},open:H},r.createElement(ze.Provider,{value:{activeSnapPoint:it,snapPoints:o,setActiveSnapPoint:Ne,drawerRef:d,overlayRef:te,onOpenChange:n,onPress:ct,onRelease:gt,onDrag:ft,dismissible:m,shouldAnimate:Ae,handleOnly:g,isOpen:H,isDragging:K,shouldFade:_e,closeDrawer:le,onNestedDrag:ht,onNestedOpenChange:wt,onNestedRelease:mt,keyboardIsOpen:ne,modal:k,snapPointsOffset:se,activeSnapPointIndex:re,direction:f,shouldScaleBackground:p,setBackgroundColorOnScale:l,noBodyStyles:A,container:M,autoFocus:V}},t))}var et=r.forwardRef(function({...e},n){let{overlayRef:t,snapPoints:i,onRelease:u,shouldFade:o,isOpen:p,modal:l,shouldAnimate:b}=oe(),E=qe(n,t),m=i&&i.length>0;if(!l)return null;let g=r.useCallback(w=>u(w),[u]);return r.createElement(N.Overlay,{onMouseUp:g,ref:E,"data-vaul-overlay":"","data-vaul-snap-points":p&&m?"true":"false","data-vaul-snap-points-overlay":p&&o?"true":"false","data-vaul-animate":b?.current?"true":"false",...e})});et.displayName="Drawer.Overlay";var tt=r.forwardRef(function({onPointerDownOutside:e,style:n,onOpenAutoFocus:t,...i},u){let{drawerRef:o,onPress:p,onRelease:l,onDrag:b,keyboardIsOpen:E,snapPointsOffset:m,activeSnapPointIndex:g,modal:w,isOpen:W,direction:B,snapPoints:T,container:k,handleOnly:h,shouldAnimate:P,autoFocus:A}=oe(),[f,j]=r.useState(!1),Q=qe(u,o),c=r.useRef(null),S=r.useRef(null),y=r.useRef(!1),_=T&&T.length>0;Wt();let M=(s,F,H=0)=>{if(y.current)return!0;let z=Math.abs(s.y),I=Math.abs(s.x),X=I>z,K=["bottom","right"].includes(F)?1:-1;if(F==="left"||F==="right"){if(!(s.x*K<0)&&I>=0&&I<=H)return X}else if(!(s.y*K<0)&&z>=0&&z<=H)return!X;return y.current=!0,!0};r.useEffect(()=>{_&&window.requestAnimationFrame(()=>{j(!0)})},[]);function V(s){c.current=null,y.current=!1,l(s)}return r.createElement(N.Content,{"data-vaul-drawer-direction":B,"data-vaul-drawer":"","data-vaul-delayed-snap-points":f?"true":"false","data-vaul-snap-points":W&&_?"true":"false","data-vaul-custom-container":k?"true":"false","data-vaul-animate":P?.current?"true":"false",...i,ref:Q,style:m&&m.length>0?{"--snap-point-height":`${m[g??0]}px`,...n}:n,onPointerDown:s=>{h||(i.onPointerDown==null||i.onPointerDown.call(i,s),c.current={x:s.pageX,y:s.pageY},p(s))},onOpenAutoFocus:s=>{t?.(s),A||s.preventDefault()},onPointerDownOutside:s=>{if(e?.(s),!w||s.defaultPrevented){s.preventDefault();return}E.current&&(E.current=!1)},onFocusOutside:s=>{if(!w){s.preventDefault();return}},onPointerMove:s=>{if(S.current=s,h||(i.onPointerMove==null||i.onPointerMove.call(i,s),!c.current))return;let F=s.pageY-c.current.y,H=s.pageX-c.current.x,z=s.pointerType==="touch"?10:2;M({x:H,y:F},B,z)?b(s):(Math.abs(H)>z||Math.abs(F)>z)&&(c.current=null)},onPointerUp:s=>{i.onPointerUp==null||i.onPointerUp.call(i,s),c.current=null,y.current=!1,l(s)},onPointerOut:s=>{i.onPointerOut==null||i.onPointerOut.call(i,s),V(S.current)},onContextMenu:s=>{i.onContextMenu==null||i.onContextMenu.call(i,s),S.current&&V(S.current)}})});tt.displayName="Drawer.Content";var Ft=250,Vt=120,nt=r.forwardRef(function({preventCycle:e=!1,children:n,...t},i){let{closeDrawer:u,isDragging:o,snapPoints:p,activeSnapPoint:l,setActiveSnapPoint:b,dismissible:E,handleOnly:m,isOpen:g,onPress:w,onDrag:W}=oe(),B=r.useRef(null),T=r.useRef(!1);function k(){if(T.current){A();return}window.setTimeout(()=>{h()},Vt)}function h(){if(o||e||T.current){A();return}if(A(),!p||p.length===0){E||u();return}if(l===p[p.length-1]&&E){u();return}let j=p.findIndex(c=>c===l);if(j===-1)return;let Q=p[j+1];b(Q)}function P(){B.current=window.setTimeout(()=>{T.current=!0},Ft)}function A(){B.current&&window.clearTimeout(B.current),T.current=!1}return r.createElement("div",{onClick:k,onPointerCancel:A,onPointerDown:f=>{m&&w(f),P()},onPointerMove:f=>{m&&W(f)},ref:i,"data-vaul-drawer-visible":g?"true":"false","data-vaul-handle":"","aria-hidden":"true",...t},r.createElement("span",{"data-vaul-handle-hitarea":"","aria-hidden":"true"},n))});nt.displayName="Drawer.Handle";function zt({onDrag:e,onOpenChange:n,open:t,...i}){let{onNestedDrag:u,onNestedOpenChange:o,onNestedRelease:p}=oe();if(!u)throw new Error("Drawer.NestedRoot must be placed in another drawer");return r.createElement(Ze,{nested:!0,open:t,onClose:()=>{o(!1)},onDrag:(l,b)=>{u(l,b),e?.(l,b)},onOpenChange:l=>{l&&o(l),n?.(l)},onRelease:p,...i})}function Yt(e){let n=oe(),{container:t=n.container,...i}=e;return r.createElement(N.Portal,{container:t,...i})}var jt={Root:Ze,NestedRoot:zt,Content:tt,Overlay:et,Trigger:N.Trigger,Portal:Yt,Handle:nt,Close:N.Close,Title:N.Title,Description:N.Description};export{jt as Drawer};
|