@spear-ai/spectral 1.1.3 → 1.1.4
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/assets/index.css +1 -0
- package/dist/{loader-circle-Btf6jOd5.js → icons-nlFaUIaL.js} +1 -0
- package/dist/index.js +244 -27
- package/dist/radix-ui-CnUQ0w36.js +1598 -0
- package/dist/third-party-BsAWbOJh.js +1261 -0
- package/dist/{twUtils-B9ArqCOv.js → utilities-DgyfzOnd.js} +471 -447
- package/package.json +3 -1
- package/dist/Button.d.ts +0 -2
- package/dist/Button.js +0 -118
- package/dist/Card.d.ts +0 -2
- package/dist/Card.js +0 -25
- package/dist/Drawer.d.ts +0 -2
- package/dist/Drawer.js +0 -2163
- package/dist/Skeleton.d.ts +0 -2
- package/dist/Skeleton.js +0 -9
- package/dist/Slider.d.ts +0 -2
- package/dist/Slider.js +0 -563
- package/dist/assets/spectral.css +0 -1
- package/dist/index-C-ErIYr7.js +0 -225
|
@@ -0,0 +1,1261 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as O from "react";
|
|
3
|
+
import i, { useLayoutEffect as je, useEffect as Ye, useMemo as qe } from "react";
|
|
4
|
+
import { c as Xe, u as Lt, P as gt, a as mt, b as Ge, d as At, e as Ft, f as Ke, R as Je, g as Ze, h as Qe, i as tn, F as en, D as nn, j as rn } from "./radix-ui-CnUQ0w36.js";
|
|
5
|
+
import { jsx as A, jsxs as Zt, Fragment as Qt } from "react/jsx-runtime";
|
|
6
|
+
var Et = "Dialog", [ae, Qn] = Xe(Et), [an, q] = ae(Et), oe = (t) => {
|
|
7
|
+
const {
|
|
8
|
+
__scopeDialog: n,
|
|
9
|
+
children: e,
|
|
10
|
+
open: a,
|
|
11
|
+
defaultOpen: o,
|
|
12
|
+
onOpenChange: r,
|
|
13
|
+
modal: c = !0
|
|
14
|
+
} = t, s = O.useRef(null), v = O.useRef(null), [E, g] = Ge({
|
|
15
|
+
prop: a,
|
|
16
|
+
defaultProp: o ?? !1,
|
|
17
|
+
onChange: r,
|
|
18
|
+
caller: Et
|
|
19
|
+
});
|
|
20
|
+
return /* @__PURE__ */ A(
|
|
21
|
+
an,
|
|
22
|
+
{
|
|
23
|
+
scope: n,
|
|
24
|
+
triggerRef: s,
|
|
25
|
+
contentRef: v,
|
|
26
|
+
contentId: At(),
|
|
27
|
+
titleId: At(),
|
|
28
|
+
descriptionId: At(),
|
|
29
|
+
open: E,
|
|
30
|
+
onOpenChange: g,
|
|
31
|
+
onOpenToggle: O.useCallback(() => g((m) => !m), [g]),
|
|
32
|
+
modal: c,
|
|
33
|
+
children: e
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
oe.displayName = Et;
|
|
38
|
+
var ie = "DialogTrigger", se = O.forwardRef(
|
|
39
|
+
(t, n) => {
|
|
40
|
+
const { __scopeDialog: e, ...a } = t, o = q(ie, e), r = Lt(n, o.triggerRef);
|
|
41
|
+
return /* @__PURE__ */ A(
|
|
42
|
+
gt.button,
|
|
43
|
+
{
|
|
44
|
+
type: "button",
|
|
45
|
+
"aria-haspopup": "dialog",
|
|
46
|
+
"aria-expanded": o.open,
|
|
47
|
+
"aria-controls": o.contentId,
|
|
48
|
+
"data-state": Bt(o.open),
|
|
49
|
+
...a,
|
|
50
|
+
ref: r,
|
|
51
|
+
onClick: mt(t.onClick, o.onOpenToggle)
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
se.displayName = ie;
|
|
57
|
+
var kt = "DialogPortal", [on, le] = ae(kt, {
|
|
58
|
+
forceMount: void 0
|
|
59
|
+
}), ue = (t) => {
|
|
60
|
+
const { __scopeDialog: n, forceMount: e, children: a, container: o } = t, r = q(kt, n);
|
|
61
|
+
return /* @__PURE__ */ A(on, { scope: n, forceMount: e, children: O.Children.map(a, (c) => /* @__PURE__ */ A(Ft, { present: e || r.open, children: /* @__PURE__ */ A(Ke, { asChild: !0, container: o, children: c }) })) });
|
|
62
|
+
};
|
|
63
|
+
ue.displayName = kt;
|
|
64
|
+
var Rt = "DialogOverlay", ce = O.forwardRef(
|
|
65
|
+
(t, n) => {
|
|
66
|
+
const e = le(Rt, t.__scopeDialog), { forceMount: a = e.forceMount, ...o } = t, r = q(Rt, t.__scopeDialog);
|
|
67
|
+
return r.modal ? /* @__PURE__ */ A(Ft, { present: a || r.open, children: /* @__PURE__ */ A(ln, { ...o, ref: n }) }) : null;
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
ce.displayName = Rt;
|
|
71
|
+
var sn = Ze("DialogOverlay.RemoveScroll"), ln = O.forwardRef(
|
|
72
|
+
(t, n) => {
|
|
73
|
+
const { __scopeDialog: e, ...a } = t, o = q(Rt, e);
|
|
74
|
+
return (
|
|
75
|
+
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
76
|
+
// ie. when `Overlay` and `Content` are siblings
|
|
77
|
+
/* @__PURE__ */ A(Je, { as: sn, allowPinchZoom: !0, shards: [o.contentRef], children: /* @__PURE__ */ A(
|
|
78
|
+
gt.div,
|
|
79
|
+
{
|
|
80
|
+
"data-state": Bt(o.open),
|
|
81
|
+
...a,
|
|
82
|
+
ref: n,
|
|
83
|
+
style: { pointerEvents: "auto", ...a.style }
|
|
84
|
+
}
|
|
85
|
+
) })
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
), rt = "DialogContent", de = O.forwardRef(
|
|
89
|
+
(t, n) => {
|
|
90
|
+
const e = le(rt, t.__scopeDialog), { forceMount: a = e.forceMount, ...o } = t, r = q(rt, t.__scopeDialog);
|
|
91
|
+
return /* @__PURE__ */ A(Ft, { present: a || r.open, children: r.modal ? /* @__PURE__ */ A(un, { ...o, ref: n }) : /* @__PURE__ */ A(cn, { ...o, ref: n }) });
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
de.displayName = rt;
|
|
95
|
+
var un = O.forwardRef(
|
|
96
|
+
(t, n) => {
|
|
97
|
+
const e = q(rt, t.__scopeDialog), a = O.useRef(null), o = Lt(n, e.contentRef, a);
|
|
98
|
+
return O.useEffect(() => {
|
|
99
|
+
const r = a.current;
|
|
100
|
+
if (r) return Qe(r);
|
|
101
|
+
}, []), /* @__PURE__ */ A(
|
|
102
|
+
fe,
|
|
103
|
+
{
|
|
104
|
+
...t,
|
|
105
|
+
ref: o,
|
|
106
|
+
trapFocus: e.open,
|
|
107
|
+
disableOutsidePointerEvents: !0,
|
|
108
|
+
onCloseAutoFocus: mt(t.onCloseAutoFocus, (r) => {
|
|
109
|
+
r.preventDefault(), e.triggerRef.current?.focus();
|
|
110
|
+
}),
|
|
111
|
+
onPointerDownOutside: mt(t.onPointerDownOutside, (r) => {
|
|
112
|
+
const c = r.detail.originalEvent, s = c.button === 0 && c.ctrlKey === !0;
|
|
113
|
+
(c.button === 2 || s) && r.preventDefault();
|
|
114
|
+
}),
|
|
115
|
+
onFocusOutside: mt(
|
|
116
|
+
t.onFocusOutside,
|
|
117
|
+
(r) => r.preventDefault()
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
), cn = O.forwardRef(
|
|
123
|
+
(t, n) => {
|
|
124
|
+
const e = q(rt, t.__scopeDialog), a = O.useRef(!1), o = O.useRef(!1);
|
|
125
|
+
return /* @__PURE__ */ A(
|
|
126
|
+
fe,
|
|
127
|
+
{
|
|
128
|
+
...t,
|
|
129
|
+
ref: n,
|
|
130
|
+
trapFocus: !1,
|
|
131
|
+
disableOutsidePointerEvents: !1,
|
|
132
|
+
onCloseAutoFocus: (r) => {
|
|
133
|
+
t.onCloseAutoFocus?.(r), r.defaultPrevented || (a.current || e.triggerRef.current?.focus(), r.preventDefault()), a.current = !1, o.current = !1;
|
|
134
|
+
},
|
|
135
|
+
onInteractOutside: (r) => {
|
|
136
|
+
t.onInteractOutside?.(r), r.defaultPrevented || (a.current = !0, r.detail.originalEvent.type === "pointerdown" && (o.current = !0));
|
|
137
|
+
const c = r.target;
|
|
138
|
+
e.triggerRef.current?.contains(c) && r.preventDefault(), r.detail.originalEvent.type === "focusin" && o.current && r.preventDefault();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
), fe = O.forwardRef(
|
|
144
|
+
(t, n) => {
|
|
145
|
+
const { __scopeDialog: e, trapFocus: a, onOpenAutoFocus: o, onCloseAutoFocus: r, ...c } = t, s = q(rt, e), v = O.useRef(null), E = Lt(n, v);
|
|
146
|
+
return tn(), /* @__PURE__ */ Zt(Qt, { children: [
|
|
147
|
+
/* @__PURE__ */ A(
|
|
148
|
+
en,
|
|
149
|
+
{
|
|
150
|
+
asChild: !0,
|
|
151
|
+
loop: !0,
|
|
152
|
+
trapped: a,
|
|
153
|
+
onMountAutoFocus: o,
|
|
154
|
+
onUnmountAutoFocus: r,
|
|
155
|
+
children: /* @__PURE__ */ A(
|
|
156
|
+
nn,
|
|
157
|
+
{
|
|
158
|
+
role: "dialog",
|
|
159
|
+
id: s.contentId,
|
|
160
|
+
"aria-describedby": s.descriptionId,
|
|
161
|
+
"aria-labelledby": s.titleId,
|
|
162
|
+
"data-state": Bt(s.open),
|
|
163
|
+
...c,
|
|
164
|
+
ref: E,
|
|
165
|
+
onDismiss: () => s.onOpenChange(!1)
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
/* @__PURE__ */ Zt(Qt, { children: [
|
|
171
|
+
/* @__PURE__ */ A(dn, { titleId: s.titleId }),
|
|
172
|
+
/* @__PURE__ */ A(pn, { contentRef: v, descriptionId: s.descriptionId })
|
|
173
|
+
] })
|
|
174
|
+
] });
|
|
175
|
+
}
|
|
176
|
+
), Ht = "DialogTitle", pe = O.forwardRef(
|
|
177
|
+
(t, n) => {
|
|
178
|
+
const { __scopeDialog: e, ...a } = t, o = q(Ht, e);
|
|
179
|
+
return /* @__PURE__ */ A(gt.h2, { id: o.titleId, ...a, ref: n });
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
pe.displayName = Ht;
|
|
183
|
+
var me = "DialogDescription", ge = O.forwardRef(
|
|
184
|
+
(t, n) => {
|
|
185
|
+
const { __scopeDialog: e, ...a } = t, o = q(me, e);
|
|
186
|
+
return /* @__PURE__ */ A(gt.p, { id: o.descriptionId, ...a, ref: n });
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
ge.displayName = me;
|
|
190
|
+
var he = "DialogClose", we = O.forwardRef(
|
|
191
|
+
(t, n) => {
|
|
192
|
+
const { __scopeDialog: e, ...a } = t, o = q(he, e);
|
|
193
|
+
return /* @__PURE__ */ A(
|
|
194
|
+
gt.button,
|
|
195
|
+
{
|
|
196
|
+
type: "button",
|
|
197
|
+
...a,
|
|
198
|
+
ref: n,
|
|
199
|
+
onClick: mt(t.onClick, () => o.onOpenChange(!1))
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
);
|
|
204
|
+
we.displayName = he;
|
|
205
|
+
function Bt(t) {
|
|
206
|
+
return t ? "open" : "closed";
|
|
207
|
+
}
|
|
208
|
+
var ve = "DialogTitleWarning", [tr, ye] = rn(ve, {
|
|
209
|
+
contentName: rt,
|
|
210
|
+
titleName: Ht,
|
|
211
|
+
docsSlug: "dialog"
|
|
212
|
+
}), dn = ({ titleId: t }) => {
|
|
213
|
+
const n = ye(ve), e = `\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
|
|
214
|
+
|
|
215
|
+
If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
216
|
+
|
|
217
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;
|
|
218
|
+
return O.useEffect(() => {
|
|
219
|
+
t && (document.getElementById(t) || console.error(e));
|
|
220
|
+
}, [e, t]), null;
|
|
221
|
+
}, fn = "DialogDescriptionWarning", pn = ({ contentRef: t, descriptionId: n }) => {
|
|
222
|
+
const a = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ye(fn).contentName}}.`;
|
|
223
|
+
return O.useEffect(() => {
|
|
224
|
+
const o = t.current?.getAttribute("aria-describedby");
|
|
225
|
+
n && o && (document.getElementById(n) || console.warn(a));
|
|
226
|
+
}, [a, t, n]), null;
|
|
227
|
+
}, mn = oe, gn = se, hn = ue, wn = ce, vn = de, yn = pe, bn = ge, Dn = we;
|
|
228
|
+
function Rn(t) {
|
|
229
|
+
if (typeof document > "u") return;
|
|
230
|
+
let n = document.head || document.getElementsByTagName("head")[0], e = document.createElement("style");
|
|
231
|
+
e.type = "text/css", n.appendChild(e), e.styleSheet ? e.styleSheet.cssText = t : e.appendChild(document.createTextNode(t));
|
|
232
|
+
}
|
|
233
|
+
const be = i.createContext({
|
|
234
|
+
drawerRef: {
|
|
235
|
+
current: null
|
|
236
|
+
},
|
|
237
|
+
overlayRef: {
|
|
238
|
+
current: null
|
|
239
|
+
},
|
|
240
|
+
onPress: () => {
|
|
241
|
+
},
|
|
242
|
+
onRelease: () => {
|
|
243
|
+
},
|
|
244
|
+
onDrag: () => {
|
|
245
|
+
},
|
|
246
|
+
onNestedDrag: () => {
|
|
247
|
+
},
|
|
248
|
+
onNestedOpenChange: () => {
|
|
249
|
+
},
|
|
250
|
+
onNestedRelease: () => {
|
|
251
|
+
},
|
|
252
|
+
openProp: void 0,
|
|
253
|
+
dismissible: !1,
|
|
254
|
+
isOpen: !1,
|
|
255
|
+
isDragging: !1,
|
|
256
|
+
keyboardIsOpen: {
|
|
257
|
+
current: !1
|
|
258
|
+
},
|
|
259
|
+
snapPointsOffset: null,
|
|
260
|
+
snapPoints: null,
|
|
261
|
+
handleOnly: !1,
|
|
262
|
+
modal: !1,
|
|
263
|
+
shouldFade: !1,
|
|
264
|
+
activeSnapPoint: null,
|
|
265
|
+
onOpenChange: () => {
|
|
266
|
+
},
|
|
267
|
+
setActiveSnapPoint: () => {
|
|
268
|
+
},
|
|
269
|
+
closeDrawer: () => {
|
|
270
|
+
},
|
|
271
|
+
direction: "bottom",
|
|
272
|
+
shouldAnimate: {
|
|
273
|
+
current: !0
|
|
274
|
+
},
|
|
275
|
+
shouldScaleBackground: !1,
|
|
276
|
+
setBackgroundColorOnScale: !0,
|
|
277
|
+
noBodyStyles: !1,
|
|
278
|
+
container: null,
|
|
279
|
+
autoFocus: !1
|
|
280
|
+
}), ht = () => {
|
|
281
|
+
const t = i.useContext(be);
|
|
282
|
+
if (!t)
|
|
283
|
+
throw new Error("useDrawerContext must be used within a Drawer.Root");
|
|
284
|
+
return t;
|
|
285
|
+
};
|
|
286
|
+
Rn(`[data-vaul-drawer]{touch-action:none;will-change:transform;transition:transform .5s cubic-bezier(.32, .72, 0, 1);animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=open]{animation-name:slideFromBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=bottom][data-state=closed]{animation-name:slideToBottom}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=open]{animation-name:slideFromTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=top][data-state=closed]{animation-name:slideToTop}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=open]{animation-name:slideFromLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=left][data-state=closed]{animation-name:slideToLeft}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=open]{animation-name:slideFromRight}[data-vaul-drawer][data-vaul-snap-points=false][data-vaul-drawer-direction=right][data-state=closed]{animation-name:slideToRight}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--initial-transform,100%),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}[data-vaul-drawer][data-vaul-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--initial-transform,100%),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=top]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=bottom]{transform:translate3d(0,var(--snap-point-height,0),0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=left]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-drawer][data-vaul-delayed-snap-points=true][data-vaul-drawer-direction=right]{transform:translate3d(var(--snap-point-height,0),0,0)}[data-vaul-overlay][data-vaul-snap-points=false]{animation-duration:.5s;animation-timing-function:cubic-bezier(0.32,0.72,0,1)}[data-vaul-overlay][data-vaul-snap-points=false][data-state=open]{animation-name:fadeIn}[data-vaul-overlay][data-state=closed]{animation-name:fadeOut}[data-vaul-animate=false]{animation:none!important}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:0;transition:opacity .5s cubic-bezier(.32, .72, 0, 1)}[data-vaul-overlay][data-vaul-snap-points=true]{opacity:1}[data-vaul-drawer]:not([data-vaul-custom-container=true])::after{content:'';position:absolute;background:inherit;background-color:inherit}[data-vaul-drawer][data-vaul-drawer-direction=top]::after{top:initial;bottom:100%;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=bottom]::after{top:100%;bottom:initial;left:0;right:0;height:200%}[data-vaul-drawer][data-vaul-drawer-direction=left]::after{left:initial;right:100%;top:0;bottom:0;width:200%}[data-vaul-drawer][data-vaul-drawer-direction=right]::after{left:100%;right:initial;top:0;bottom:0;width:200%}[data-vaul-overlay][data-vaul-snap-points=true]:not([data-vaul-snap-points-overlay=true]):not(
|
|
287
|
+
[data-state=closed]
|
|
288
|
+
){opacity:0}[data-vaul-overlay][data-vaul-snap-points-overlay=true]{opacity:1}[data-vaul-handle]{display:block;position:relative;opacity:.7;background:#e2e2e4;margin-left:auto;margin-right:auto;height:5px;width:32px;border-radius:1rem;touch-action:pan-y}[data-vaul-handle]:active,[data-vaul-handle]:hover{opacity:1}[data-vaul-handle-hitarea]{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:max(100%,2.75rem);height:max(100%,2.75rem);touch-action:inherit}@media (hover:hover) and (pointer:fine){[data-vaul-drawer]{user-select:none}}@media (pointer:fine){[data-vaul-handle-hitarea]:{width:100%;height:100%}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}@keyframes fadeOut{to{opacity:0}}@keyframes slideFromBottom{from{transform:translate3d(0,var(--initial-transform,100%),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToBottom{to{transform:translate3d(0,var(--initial-transform,100%),0)}}@keyframes slideFromTop{from{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}to{transform:translate3d(0,0,0)}}@keyframes slideToTop{to{transform:translate3d(0,calc(var(--initial-transform,100%) * -1),0)}}@keyframes slideFromLeft{from{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToLeft{to{transform:translate3d(calc(var(--initial-transform,100%) * -1),0,0)}}@keyframes slideFromRight{from{transform:translate3d(var(--initial-transform,100%),0,0)}to{transform:translate3d(0,0,0)}}@keyframes slideToRight{to{transform:translate3d(var(--initial-transform,100%),0,0)}}`);
|
|
289
|
+
function En() {
|
|
290
|
+
const t = navigator.userAgent;
|
|
291
|
+
return typeof window < "u" && (/Firefox/.test(t) && /Mobile/.test(t) || // Android Firefox
|
|
292
|
+
/FxiOS/.test(t));
|
|
293
|
+
}
|
|
294
|
+
function Sn() {
|
|
295
|
+
return Wt(/^Mac/);
|
|
296
|
+
}
|
|
297
|
+
function Tn() {
|
|
298
|
+
return Wt(/^iPhone/);
|
|
299
|
+
}
|
|
300
|
+
function te() {
|
|
301
|
+
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
302
|
+
}
|
|
303
|
+
function Cn() {
|
|
304
|
+
return Wt(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
305
|
+
Sn() && navigator.maxTouchPoints > 1;
|
|
306
|
+
}
|
|
307
|
+
function De() {
|
|
308
|
+
return Tn() || Cn();
|
|
309
|
+
}
|
|
310
|
+
function Wt(t) {
|
|
311
|
+
return typeof window < "u" && window.navigator != null ? t.test(window.navigator.platform) : void 0;
|
|
312
|
+
}
|
|
313
|
+
const On = 24, xn = typeof window < "u" ? je : Ye;
|
|
314
|
+
function ee(...t) {
|
|
315
|
+
return (...n) => {
|
|
316
|
+
for (let e of t)
|
|
317
|
+
typeof e == "function" && e(...n);
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
const Pt = typeof document < "u" && window.visualViewport;
|
|
321
|
+
function ne(t) {
|
|
322
|
+
let n = window.getComputedStyle(t);
|
|
323
|
+
return /(auto|scroll)/.test(n.overflow + n.overflowX + n.overflowY);
|
|
324
|
+
}
|
|
325
|
+
function Re(t) {
|
|
326
|
+
for (ne(t) && (t = t.parentElement); t && !ne(t); )
|
|
327
|
+
t = t.parentElement;
|
|
328
|
+
return t || document.scrollingElement || document.documentElement;
|
|
329
|
+
}
|
|
330
|
+
const An = /* @__PURE__ */ new Set([
|
|
331
|
+
"checkbox",
|
|
332
|
+
"radio",
|
|
333
|
+
"range",
|
|
334
|
+
"color",
|
|
335
|
+
"file",
|
|
336
|
+
"image",
|
|
337
|
+
"button",
|
|
338
|
+
"submit",
|
|
339
|
+
"reset"
|
|
340
|
+
]);
|
|
341
|
+
let bt = 0, _t;
|
|
342
|
+
function Pn(t = {}) {
|
|
343
|
+
let { isDisabled: n } = t;
|
|
344
|
+
xn(() => {
|
|
345
|
+
if (!n)
|
|
346
|
+
return bt++, bt === 1 && De() && (_t = _n()), () => {
|
|
347
|
+
bt--, bt === 0 && _t?.();
|
|
348
|
+
};
|
|
349
|
+
}, [
|
|
350
|
+
n
|
|
351
|
+
]);
|
|
352
|
+
}
|
|
353
|
+
function _n() {
|
|
354
|
+
let t, n = 0, e = (m) => {
|
|
355
|
+
t = Re(m.target), !(t === document.documentElement && t === document.body) && (n = m.changedTouches[0].pageY);
|
|
356
|
+
}, a = (m) => {
|
|
357
|
+
if (!t || t === document.documentElement || t === document.body) {
|
|
358
|
+
m.preventDefault();
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
let h = m.changedTouches[0].pageY, W = t.scrollTop, H = t.scrollHeight - t.clientHeight;
|
|
362
|
+
H !== 0 && ((W <= 0 && h > n || W >= H && h < n) && m.preventDefault(), n = h);
|
|
363
|
+
}, o = (m) => {
|
|
364
|
+
let h = m.target;
|
|
365
|
+
$t(h) && h !== document.activeElement && (m.preventDefault(), h.style.transform = "translateY(-2000px)", h.focus(), requestAnimationFrame(() => {
|
|
366
|
+
h.style.transform = "";
|
|
367
|
+
}));
|
|
368
|
+
}, r = (m) => {
|
|
369
|
+
let h = m.target;
|
|
370
|
+
$t(h) && (h.style.transform = "translateY(-2000px)", requestAnimationFrame(() => {
|
|
371
|
+
h.style.transform = "", Pt && (Pt.height < window.innerHeight ? requestAnimationFrame(() => {
|
|
372
|
+
re(h);
|
|
373
|
+
}) : Pt.addEventListener("resize", () => re(h), {
|
|
374
|
+
once: !0
|
|
375
|
+
}));
|
|
376
|
+
}));
|
|
377
|
+
}, c = () => {
|
|
378
|
+
window.scrollTo(0, 0);
|
|
379
|
+
}, s = window.pageXOffset, v = window.pageYOffset, E = ee(Mn(document.documentElement, "paddingRight", `${window.innerWidth - document.documentElement.clientWidth}px`));
|
|
380
|
+
window.scrollTo(0, 0);
|
|
381
|
+
let g = ee(ft(document, "touchstart", e, {
|
|
382
|
+
passive: !1,
|
|
383
|
+
capture: !0
|
|
384
|
+
}), ft(document, "touchmove", a, {
|
|
385
|
+
passive: !1,
|
|
386
|
+
capture: !0
|
|
387
|
+
}), ft(document, "touchend", o, {
|
|
388
|
+
passive: !1,
|
|
389
|
+
capture: !0
|
|
390
|
+
}), ft(document, "focus", r, !0), ft(window, "scroll", c));
|
|
391
|
+
return () => {
|
|
392
|
+
E(), g(), window.scrollTo(s, v);
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function Mn(t, n, e) {
|
|
396
|
+
let a = t.style[n];
|
|
397
|
+
return t.style[n] = e, () => {
|
|
398
|
+
t.style[n] = a;
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function ft(t, n, e, a) {
|
|
402
|
+
return t.addEventListener(n, e, a), () => {
|
|
403
|
+
t.removeEventListener(n, e, a);
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function re(t) {
|
|
407
|
+
let n = document.scrollingElement || document.documentElement;
|
|
408
|
+
for (; t && t !== n; ) {
|
|
409
|
+
let e = Re(t);
|
|
410
|
+
if (e !== document.documentElement && e !== document.body && e !== t) {
|
|
411
|
+
let a = e.getBoundingClientRect().top, o = t.getBoundingClientRect().top, r = t.getBoundingClientRect().bottom;
|
|
412
|
+
const c = e.getBoundingClientRect().bottom + On;
|
|
413
|
+
r > c && (e.scrollTop += o - a);
|
|
414
|
+
}
|
|
415
|
+
t = e.parentElement;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function $t(t) {
|
|
419
|
+
return t instanceof HTMLInputElement && !An.has(t.type) || t instanceof HTMLTextAreaElement || t instanceof HTMLElement && t.isContentEditable;
|
|
420
|
+
}
|
|
421
|
+
function In(t, n) {
|
|
422
|
+
typeof t == "function" ? t(n) : t != null && (t.current = n);
|
|
423
|
+
}
|
|
424
|
+
function $n(...t) {
|
|
425
|
+
return (n) => t.forEach((e) => In(e, n));
|
|
426
|
+
}
|
|
427
|
+
function Ee(...t) {
|
|
428
|
+
return O.useCallback($n(...t), t);
|
|
429
|
+
}
|
|
430
|
+
const Se = /* @__PURE__ */ new WeakMap();
|
|
431
|
+
function _(t, n, e = !1) {
|
|
432
|
+
if (!t || !(t instanceof HTMLElement)) return;
|
|
433
|
+
let a = {};
|
|
434
|
+
Object.entries(n).forEach(([o, r]) => {
|
|
435
|
+
if (o.startsWith("--")) {
|
|
436
|
+
t.style.setProperty(o, r);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
a[o] = t.style[o], t.style[o] = r;
|
|
440
|
+
}), !e && Se.set(t, a);
|
|
441
|
+
}
|
|
442
|
+
function Nn(t, n) {
|
|
443
|
+
if (!t || !(t instanceof HTMLElement)) return;
|
|
444
|
+
let e = Se.get(t);
|
|
445
|
+
e && (t.style[n] = e[n]);
|
|
446
|
+
}
|
|
447
|
+
const P = (t) => {
|
|
448
|
+
switch (t) {
|
|
449
|
+
case "top":
|
|
450
|
+
case "bottom":
|
|
451
|
+
return !0;
|
|
452
|
+
case "left":
|
|
453
|
+
case "right":
|
|
454
|
+
return !1;
|
|
455
|
+
default:
|
|
456
|
+
return t;
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
function Dt(t, n) {
|
|
460
|
+
if (!t)
|
|
461
|
+
return null;
|
|
462
|
+
const e = window.getComputedStyle(t), a = (
|
|
463
|
+
// @ts-ignore
|
|
464
|
+
e.transform || e.webkitTransform || e.mozTransform
|
|
465
|
+
);
|
|
466
|
+
let o = a.match(/^matrix3d\((.+)\)$/);
|
|
467
|
+
return o ? parseFloat(o[1].split(", ")[P(n) ? 13 : 12]) : (o = a.match(/^matrix\((.+)\)$/), o ? parseFloat(o[1].split(", ")[P(n) ? 5 : 4]) : null);
|
|
468
|
+
}
|
|
469
|
+
function Ln(t) {
|
|
470
|
+
return 8 * (Math.log(t + 1) - 2);
|
|
471
|
+
}
|
|
472
|
+
function Mt(t, n) {
|
|
473
|
+
if (!t) return () => {
|
|
474
|
+
};
|
|
475
|
+
const e = t.style.cssText;
|
|
476
|
+
return Object.assign(t.style, n), () => {
|
|
477
|
+
t.style.cssText = e;
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
function Fn(...t) {
|
|
481
|
+
return (...n) => {
|
|
482
|
+
for (const e of t)
|
|
483
|
+
typeof e == "function" && e(...n);
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
const C = {
|
|
487
|
+
DURATION: 0.5,
|
|
488
|
+
EASE: [
|
|
489
|
+
0.32,
|
|
490
|
+
0.72,
|
|
491
|
+
0,
|
|
492
|
+
1
|
|
493
|
+
]
|
|
494
|
+
}, Te = 0.4, kn = 0.25, Hn = 100, Ce = 8, nt = 16, Nt = 26, It = "vaul-dragging";
|
|
495
|
+
function Oe(t) {
|
|
496
|
+
const n = i.useRef(t);
|
|
497
|
+
return i.useEffect(() => {
|
|
498
|
+
n.current = t;
|
|
499
|
+
}), i.useMemo(() => (...e) => n.current == null ? void 0 : n.current.call(n, ...e), []);
|
|
500
|
+
}
|
|
501
|
+
function Bn({ defaultProp: t, onChange: n }) {
|
|
502
|
+
const e = i.useState(t), [a] = e, o = i.useRef(a), r = Oe(n);
|
|
503
|
+
return i.useEffect(() => {
|
|
504
|
+
o.current !== a && (r(a), o.current = a);
|
|
505
|
+
}, [
|
|
506
|
+
a,
|
|
507
|
+
o,
|
|
508
|
+
r
|
|
509
|
+
]), e;
|
|
510
|
+
}
|
|
511
|
+
function xe({ prop: t, defaultProp: n, onChange: e = () => {
|
|
512
|
+
} }) {
|
|
513
|
+
const [a, o] = Bn({
|
|
514
|
+
defaultProp: n,
|
|
515
|
+
onChange: e
|
|
516
|
+
}), r = t !== void 0, c = r ? t : a, s = Oe(e), v = i.useCallback((E) => {
|
|
517
|
+
if (r) {
|
|
518
|
+
const m = typeof E == "function" ? E(t) : E;
|
|
519
|
+
m !== t && s(m);
|
|
520
|
+
} else
|
|
521
|
+
o(E);
|
|
522
|
+
}, [
|
|
523
|
+
r,
|
|
524
|
+
t,
|
|
525
|
+
o,
|
|
526
|
+
s
|
|
527
|
+
]);
|
|
528
|
+
return [
|
|
529
|
+
c,
|
|
530
|
+
v
|
|
531
|
+
];
|
|
532
|
+
}
|
|
533
|
+
function Wn({ activeSnapPointProp: t, setActiveSnapPointProp: n, snapPoints: e, drawerRef: a, overlayRef: o, fadeFromIndex: r, onSnapPointChange: c, direction: s = "bottom", container: v, snapToSequentialPoint: E }) {
|
|
534
|
+
const [g, m] = xe({
|
|
535
|
+
prop: t,
|
|
536
|
+
defaultProp: e?.[0],
|
|
537
|
+
onChange: n
|
|
538
|
+
}), [h, W] = i.useState(typeof window < "u" ? {
|
|
539
|
+
innerWidth: window.innerWidth,
|
|
540
|
+
innerHeight: window.innerHeight
|
|
541
|
+
} : void 0);
|
|
542
|
+
i.useEffect(() => {
|
|
543
|
+
function d() {
|
|
544
|
+
W({
|
|
545
|
+
innerWidth: window.innerWidth,
|
|
546
|
+
innerHeight: window.innerHeight
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
return window.addEventListener("resize", d), () => window.removeEventListener("resize", d);
|
|
550
|
+
}, []);
|
|
551
|
+
const H = i.useMemo(() => g === e?.[e.length - 1] || null, [
|
|
552
|
+
e,
|
|
553
|
+
g
|
|
554
|
+
]), T = i.useMemo(() => {
|
|
555
|
+
var d;
|
|
556
|
+
return (d = e?.findIndex((D) => D === g)) != null ? d : null;
|
|
557
|
+
}, [
|
|
558
|
+
e,
|
|
559
|
+
g
|
|
560
|
+
]), U = e && e.length > 0 && (r || r === 0) && !Number.isNaN(r) && e[r] === g || !e, w = i.useMemo(() => {
|
|
561
|
+
const d = v ? {
|
|
562
|
+
width: v.getBoundingClientRect().width,
|
|
563
|
+
height: v.getBoundingClientRect().height
|
|
564
|
+
} : typeof window < "u" ? {
|
|
565
|
+
width: window.innerWidth,
|
|
566
|
+
height: window.innerHeight
|
|
567
|
+
} : {
|
|
568
|
+
width: 0,
|
|
569
|
+
height: 0
|
|
570
|
+
};
|
|
571
|
+
var D;
|
|
572
|
+
return (D = e?.map((b) => {
|
|
573
|
+
const L = typeof b == "string";
|
|
574
|
+
let $ = 0;
|
|
575
|
+
if (L && ($ = parseInt(b, 10)), P(s)) {
|
|
576
|
+
const u = L ? $ : h ? b * d.height : 0;
|
|
577
|
+
return h ? s === "bottom" ? d.height - u : -d.height + u : u;
|
|
578
|
+
}
|
|
579
|
+
const V = L ? $ : h ? b * d.width : 0;
|
|
580
|
+
return h ? s === "right" ? d.width - V : -d.width + V : V;
|
|
581
|
+
})) != null ? D : [];
|
|
582
|
+
}, [
|
|
583
|
+
e,
|
|
584
|
+
h,
|
|
585
|
+
v
|
|
586
|
+
]), I = i.useMemo(() => T !== null ? w?.[T] : null, [
|
|
587
|
+
w,
|
|
588
|
+
T
|
|
589
|
+
]), M = i.useCallback((d) => {
|
|
590
|
+
var D;
|
|
591
|
+
const b = (D = w?.findIndex((L) => L === d)) != null ? D : null;
|
|
592
|
+
c(b), _(a.current, {
|
|
593
|
+
transition: `transform ${C.DURATION}s cubic-bezier(${C.EASE.join(",")})`,
|
|
594
|
+
transform: P(s) ? `translate3d(0, ${d}px, 0)` : `translate3d(${d}px, 0, 0)`
|
|
595
|
+
}), w && b !== w.length - 1 && r !== void 0 && b !== r && b < r ? _(o.current, {
|
|
596
|
+
transition: `opacity ${C.DURATION}s cubic-bezier(${C.EASE.join(",")})`,
|
|
597
|
+
opacity: "0"
|
|
598
|
+
}) : _(o.current, {
|
|
599
|
+
transition: `opacity ${C.DURATION}s cubic-bezier(${C.EASE.join(",")})`,
|
|
600
|
+
opacity: "1"
|
|
601
|
+
}), m(e?.[Math.max(b, 0)]);
|
|
602
|
+
}, [
|
|
603
|
+
a.current,
|
|
604
|
+
e,
|
|
605
|
+
w,
|
|
606
|
+
r,
|
|
607
|
+
o,
|
|
608
|
+
m
|
|
609
|
+
]);
|
|
610
|
+
i.useEffect(() => {
|
|
611
|
+
if (g || t) {
|
|
612
|
+
var d;
|
|
613
|
+
const D = (d = e?.findIndex((b) => b === t || b === g)) != null ? d : -1;
|
|
614
|
+
w && D !== -1 && typeof w[D] == "number" && M(w[D]);
|
|
615
|
+
}
|
|
616
|
+
}, [
|
|
617
|
+
g,
|
|
618
|
+
t,
|
|
619
|
+
e,
|
|
620
|
+
w,
|
|
621
|
+
M
|
|
622
|
+
]);
|
|
623
|
+
function f({ draggedDistance: d, closeDrawer: D, velocity: b, dismissible: L }) {
|
|
624
|
+
if (r === void 0) return;
|
|
625
|
+
const $ = s === "bottom" || s === "right" ? (I ?? 0) - d : (I ?? 0) + d, V = T === r - 1, u = T === 0, z = d > 0;
|
|
626
|
+
if (V && _(o.current, {
|
|
627
|
+
transition: `opacity ${C.DURATION}s cubic-bezier(${C.EASE.join(",")})`
|
|
628
|
+
}), !E && b > 2 && !z) {
|
|
629
|
+
L ? D() : M(w[0]);
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
if (!E && b > 2 && z && w && e) {
|
|
633
|
+
M(w[e.length - 1]);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
const F = w?.reduce((N, K) => typeof N != "number" || typeof K != "number" ? N : Math.abs(K - $) < Math.abs(N - $) ? K : N), j = P(s) ? window.innerHeight : window.innerWidth;
|
|
637
|
+
if (b > Te && Math.abs(d) < j * 0.4) {
|
|
638
|
+
const N = z ? 1 : -1;
|
|
639
|
+
if (N > 0 && H && e) {
|
|
640
|
+
M(w[e.length - 1]);
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
if (u && N < 0 && L && D(), T === null) return;
|
|
644
|
+
M(w[T + N]);
|
|
645
|
+
return;
|
|
646
|
+
}
|
|
647
|
+
M(F);
|
|
648
|
+
}
|
|
649
|
+
function X({ draggedDistance: d }) {
|
|
650
|
+
if (I === null) return;
|
|
651
|
+
const D = s === "bottom" || s === "right" ? I - d : I + d;
|
|
652
|
+
(s === "bottom" || s === "right") && D < w[w.length - 1] || (s === "top" || s === "left") && D > w[w.length - 1] || _(a.current, {
|
|
653
|
+
transform: P(s) ? `translate3d(0, ${D}px, 0)` : `translate3d(${D}px, 0, 0)`
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
function tt(d, D) {
|
|
657
|
+
if (!e || typeof T != "number" || !w || r === void 0) return null;
|
|
658
|
+
const b = T === r - 1;
|
|
659
|
+
if (T >= r && D)
|
|
660
|
+
return 0;
|
|
661
|
+
if (b && !D) return 1;
|
|
662
|
+
if (!U && !b) return null;
|
|
663
|
+
const $ = b ? T + 1 : T - 1, V = b ? w[$] - w[$ - 1] : w[$ + 1] - w[$], u = d / Math.abs(V);
|
|
664
|
+
return b ? 1 - u : u;
|
|
665
|
+
}
|
|
666
|
+
return {
|
|
667
|
+
isLastSnapPoint: H,
|
|
668
|
+
activeSnapPoint: g,
|
|
669
|
+
shouldFade: U,
|
|
670
|
+
getPercentageDragged: tt,
|
|
671
|
+
setActiveSnapPoint: m,
|
|
672
|
+
activeSnapPointIndex: T,
|
|
673
|
+
onRelease: f,
|
|
674
|
+
onDrag: X,
|
|
675
|
+
snapPointsOffset: w
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
const Un = () => () => {
|
|
679
|
+
};
|
|
680
|
+
function zn() {
|
|
681
|
+
const { direction: t, isOpen: n, shouldScaleBackground: e, setBackgroundColorOnScale: a, noBodyStyles: o } = ht(), r = i.useRef(null), c = qe(() => document.body.style.backgroundColor, []);
|
|
682
|
+
function s() {
|
|
683
|
+
return (window.innerWidth - Nt) / window.innerWidth;
|
|
684
|
+
}
|
|
685
|
+
i.useEffect(() => {
|
|
686
|
+
if (n && e) {
|
|
687
|
+
r.current && clearTimeout(r.current);
|
|
688
|
+
const v = document.querySelector("[data-vaul-drawer-wrapper]") || document.querySelector("[vaul-drawer-wrapper]");
|
|
689
|
+
if (!v) return;
|
|
690
|
+
Fn(a && !o ? Mt(document.body, {
|
|
691
|
+
background: "black"
|
|
692
|
+
}) : Un, Mt(v, {
|
|
693
|
+
transformOrigin: P(t) ? "top" : "left",
|
|
694
|
+
transitionProperty: "transform, border-radius",
|
|
695
|
+
transitionDuration: `${C.DURATION}s`,
|
|
696
|
+
transitionTimingFunction: `cubic-bezier(${C.EASE.join(",")})`
|
|
697
|
+
}));
|
|
698
|
+
const E = Mt(v, {
|
|
699
|
+
borderRadius: `${Ce}px`,
|
|
700
|
+
overflow: "hidden",
|
|
701
|
+
...P(t) ? {
|
|
702
|
+
transform: `scale(${s()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`
|
|
703
|
+
} : {
|
|
704
|
+
transform: `scale(${s()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
return () => {
|
|
708
|
+
E(), r.current = window.setTimeout(() => {
|
|
709
|
+
c ? document.body.style.background = c : document.body.style.removeProperty("background");
|
|
710
|
+
}, C.DURATION * 1e3);
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
}, [
|
|
714
|
+
n,
|
|
715
|
+
e,
|
|
716
|
+
c
|
|
717
|
+
]);
|
|
718
|
+
}
|
|
719
|
+
let pt = null;
|
|
720
|
+
function Vn({ isOpen: t, modal: n, nested: e, hasBeenOpened: a, preventScrollRestoration: o, noBodyStyles: r }) {
|
|
721
|
+
const [c, s] = i.useState(() => typeof window < "u" ? window.location.href : ""), v = i.useRef(0), E = i.useCallback(() => {
|
|
722
|
+
if (te() && pt === null && t && !r) {
|
|
723
|
+
pt = {
|
|
724
|
+
position: document.body.style.position,
|
|
725
|
+
top: document.body.style.top,
|
|
726
|
+
left: document.body.style.left,
|
|
727
|
+
height: document.body.style.height,
|
|
728
|
+
right: "unset"
|
|
729
|
+
};
|
|
730
|
+
const { scrollX: m, innerHeight: h } = window;
|
|
731
|
+
document.body.style.setProperty("position", "fixed", "important"), Object.assign(document.body.style, {
|
|
732
|
+
top: `${-v.current}px`,
|
|
733
|
+
left: `${-m}px`,
|
|
734
|
+
right: "0px",
|
|
735
|
+
height: "auto"
|
|
736
|
+
}), window.setTimeout(() => window.requestAnimationFrame(() => {
|
|
737
|
+
const W = h - window.innerHeight;
|
|
738
|
+
W && v.current >= h && (document.body.style.top = `${-(v.current + W)}px`);
|
|
739
|
+
}), 300);
|
|
740
|
+
}
|
|
741
|
+
}, [
|
|
742
|
+
t
|
|
743
|
+
]), g = i.useCallback(() => {
|
|
744
|
+
if (te() && pt !== null && !r) {
|
|
745
|
+
const m = -parseInt(document.body.style.top, 10), h = -parseInt(document.body.style.left, 10);
|
|
746
|
+
Object.assign(document.body.style, pt), window.requestAnimationFrame(() => {
|
|
747
|
+
if (o && c !== window.location.href) {
|
|
748
|
+
s(window.location.href);
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
window.scrollTo(h, m);
|
|
752
|
+
}), pt = null;
|
|
753
|
+
}
|
|
754
|
+
}, [
|
|
755
|
+
c
|
|
756
|
+
]);
|
|
757
|
+
return i.useEffect(() => {
|
|
758
|
+
function m() {
|
|
759
|
+
v.current = window.scrollY;
|
|
760
|
+
}
|
|
761
|
+
return m(), window.addEventListener("scroll", m), () => {
|
|
762
|
+
window.removeEventListener("scroll", m);
|
|
763
|
+
};
|
|
764
|
+
}, []), i.useEffect(() => {
|
|
765
|
+
if (n)
|
|
766
|
+
return () => {
|
|
767
|
+
typeof document > "u" || document.querySelector("[data-vaul-drawer]") || g();
|
|
768
|
+
};
|
|
769
|
+
}, [
|
|
770
|
+
n,
|
|
771
|
+
g
|
|
772
|
+
]), i.useEffect(() => {
|
|
773
|
+
e || !a || (t ? (!window.matchMedia("(display-mode: standalone)").matches && E(), n || window.setTimeout(() => {
|
|
774
|
+
g();
|
|
775
|
+
}, 500)) : g());
|
|
776
|
+
}, [
|
|
777
|
+
t,
|
|
778
|
+
a,
|
|
779
|
+
c,
|
|
780
|
+
n,
|
|
781
|
+
e,
|
|
782
|
+
E,
|
|
783
|
+
g
|
|
784
|
+
]), {
|
|
785
|
+
restorePositionSetting: g
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function jn({ open: t, onOpenChange: n, children: e, onDrag: a, onRelease: o, snapPoints: r, shouldScaleBackground: c = !1, setBackgroundColorOnScale: s = !0, closeThreshold: v = kn, scrollLockTimeout: E = Hn, dismissible: g = !0, handleOnly: m = !1, fadeFromIndex: h = r && r.length - 1, activeSnapPoint: W, setActiveSnapPoint: H, fixed: T, modal: U = !0, onClose: w, nested: I, noBodyStyles: M = !1, direction: f = "bottom", defaultOpen: X = !1, disablePreventScroll: tt = !0, snapToSequentialPoint: d = !1, preventScrollRestoration: D = !1, repositionInputs: b = !0, onAnimationEnd: L, container: $, autoFocus: V = !1 }) {
|
|
789
|
+
var u, z;
|
|
790
|
+
const [F = !1, j] = xe({
|
|
791
|
+
defaultProp: X,
|
|
792
|
+
prop: t,
|
|
793
|
+
onChange: (l) => {
|
|
794
|
+
n?.(l), !l && !I && Fe(), setTimeout(() => {
|
|
795
|
+
L?.(l);
|
|
796
|
+
}, C.DURATION * 1e3), l && !U && typeof window < "u" && window.requestAnimationFrame(() => {
|
|
797
|
+
document.body.style.pointerEvents = "auto";
|
|
798
|
+
}), l || (document.body.style.pointerEvents = "auto");
|
|
799
|
+
}
|
|
800
|
+
}), [N, K] = i.useState(!1), [J, st] = i.useState(!1), [_e, Ut] = i.useState(!1), at = i.useRef(null), wt = i.useRef(null), St = i.useRef(null), Tt = i.useRef(null), lt = i.useRef(null), ut = i.useRef(!1), Ct = i.useRef(null), Ot = i.useRef(0), ot = i.useRef(!1), zt = i.useRef(!X), Vt = i.useRef(0), p = i.useRef(null), jt = i.useRef(((u = p.current) == null ? void 0 : u.getBoundingClientRect().height) || 0), Yt = i.useRef(((z = p.current) == null ? void 0 : z.getBoundingClientRect().width) || 0), xt = i.useRef(0), Me = i.useCallback((l) => {
|
|
801
|
+
r && l === ct.length - 1 && (wt.current = /* @__PURE__ */ new Date());
|
|
802
|
+
}, []), { activeSnapPoint: Ie, activeSnapPointIndex: it, setActiveSnapPoint: qt, onRelease: $e, snapPointsOffset: ct, onDrag: Ne, shouldFade: Xt, getPercentageDragged: Le } = Wn({
|
|
803
|
+
snapPoints: r,
|
|
804
|
+
activeSnapPointProp: W,
|
|
805
|
+
setActiveSnapPointProp: H,
|
|
806
|
+
drawerRef: p,
|
|
807
|
+
fadeFromIndex: h,
|
|
808
|
+
overlayRef: at,
|
|
809
|
+
onSnapPointChange: Me,
|
|
810
|
+
direction: f,
|
|
811
|
+
container: $,
|
|
812
|
+
snapToSequentialPoint: d
|
|
813
|
+
});
|
|
814
|
+
Pn({
|
|
815
|
+
isDisabled: !F || J || !U || _e || !N || !b || !tt
|
|
816
|
+
});
|
|
817
|
+
const { restorePositionSetting: Fe } = Vn({
|
|
818
|
+
isOpen: F,
|
|
819
|
+
modal: U,
|
|
820
|
+
nested: I ?? !1,
|
|
821
|
+
hasBeenOpened: N,
|
|
822
|
+
preventScrollRestoration: D,
|
|
823
|
+
noBodyStyles: M
|
|
824
|
+
});
|
|
825
|
+
function vt() {
|
|
826
|
+
return (window.innerWidth - Nt) / window.innerWidth;
|
|
827
|
+
}
|
|
828
|
+
function ke(l) {
|
|
829
|
+
var R, S;
|
|
830
|
+
!g && !r || p.current && !p.current.contains(l.target) || (jt.current = ((R = p.current) == null ? void 0 : R.getBoundingClientRect().height) || 0, Yt.current = ((S = p.current) == null ? void 0 : S.getBoundingClientRect().width) || 0, st(!0), St.current = /* @__PURE__ */ new Date(), De() && window.addEventListener("touchend", () => ut.current = !1, {
|
|
831
|
+
once: !0
|
|
832
|
+
}), l.target.setPointerCapture(l.pointerId), Ot.current = P(f) ? l.pageY : l.pageX);
|
|
833
|
+
}
|
|
834
|
+
function Gt(l, R) {
|
|
835
|
+
var S;
|
|
836
|
+
let y = l;
|
|
837
|
+
const x = (S = window.getSelection()) == null ? void 0 : S.toString(), B = p.current ? Dt(p.current, f) : null, k = /* @__PURE__ */ new Date();
|
|
838
|
+
if (y.tagName === "SELECT" || y.hasAttribute("data-vaul-no-drag") || y.closest("[data-vaul-no-drag]"))
|
|
839
|
+
return !1;
|
|
840
|
+
if (f === "right" || f === "left")
|
|
841
|
+
return !0;
|
|
842
|
+
if (wt.current && k.getTime() - wt.current.getTime() < 500)
|
|
843
|
+
return !1;
|
|
844
|
+
if (B !== null && (f === "bottom" ? B > 0 : B < 0))
|
|
845
|
+
return !0;
|
|
846
|
+
if (x && x.length > 0)
|
|
847
|
+
return !1;
|
|
848
|
+
if (lt.current && k.getTime() - lt.current.getTime() < E && B === 0 || R)
|
|
849
|
+
return lt.current = k, !1;
|
|
850
|
+
for (; y; ) {
|
|
851
|
+
if (y.scrollHeight > y.clientHeight) {
|
|
852
|
+
if (y.scrollTop !== 0)
|
|
853
|
+
return lt.current = /* @__PURE__ */ new Date(), !1;
|
|
854
|
+
if (y.getAttribute("role") === "dialog")
|
|
855
|
+
return !0;
|
|
856
|
+
}
|
|
857
|
+
y = y.parentNode;
|
|
858
|
+
}
|
|
859
|
+
return !0;
|
|
860
|
+
}
|
|
861
|
+
function He(l) {
|
|
862
|
+
if (p.current && J) {
|
|
863
|
+
const R = f === "bottom" || f === "right" ? 1 : -1, S = (Ot.current - (P(f) ? l.pageY : l.pageX)) * R, y = S > 0, x = r && !g && !y;
|
|
864
|
+
if (x && it === 0) return;
|
|
865
|
+
const B = Math.abs(S), k = document.querySelector("[data-vaul-drawer-wrapper]"), Z = f === "bottom" || f === "top" ? jt.current : Yt.current;
|
|
866
|
+
let Y = B / Z;
|
|
867
|
+
const et = Le(B, y);
|
|
868
|
+
if (et !== null && (Y = et), x && Y >= 1 || !ut.current && !Gt(l.target, y)) return;
|
|
869
|
+
if (p.current.classList.add(It), ut.current = !0, _(p.current, {
|
|
870
|
+
transition: "none"
|
|
871
|
+
}), _(at.current, {
|
|
872
|
+
transition: "none"
|
|
873
|
+
}), r && Ne({
|
|
874
|
+
draggedDistance: S
|
|
875
|
+
}), y && !r) {
|
|
876
|
+
const G = Ln(S), yt = Math.min(G * -1, 0) * R;
|
|
877
|
+
_(p.current, {
|
|
878
|
+
transform: P(f) ? `translate3d(0, ${yt}px, 0)` : `translate3d(${yt}px, 0, 0)`
|
|
879
|
+
});
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
const Q = 1 - Y;
|
|
883
|
+
if ((Xt || h && it === h - 1) && (a?.(l, Y), _(at.current, {
|
|
884
|
+
opacity: `${Q}`,
|
|
885
|
+
transition: "none"
|
|
886
|
+
}, !0)), k && at.current && c) {
|
|
887
|
+
const G = Math.min(vt() + Y * (1 - vt()), 1), yt = 8 - Y * 8, Jt = Math.max(0, 14 - Y * 14);
|
|
888
|
+
_(k, {
|
|
889
|
+
borderRadius: `${yt}px`,
|
|
890
|
+
transform: P(f) ? `scale(${G}) translate3d(0, ${Jt}px, 0)` : `scale(${G}) translate3d(${Jt}px, 0, 0)`,
|
|
891
|
+
transition: "none"
|
|
892
|
+
}, !0);
|
|
893
|
+
}
|
|
894
|
+
if (!r) {
|
|
895
|
+
const G = B * R;
|
|
896
|
+
_(p.current, {
|
|
897
|
+
transform: P(f) ? `translate3d(0, ${G}px, 0)` : `translate3d(${G}px, 0, 0)`
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
i.useEffect(() => {
|
|
903
|
+
window.requestAnimationFrame(() => {
|
|
904
|
+
zt.current = !0;
|
|
905
|
+
});
|
|
906
|
+
}, []), i.useEffect(() => {
|
|
907
|
+
var l;
|
|
908
|
+
function R() {
|
|
909
|
+
if (!p.current || !b) return;
|
|
910
|
+
const S = document.activeElement;
|
|
911
|
+
if ($t(S) || ot.current) {
|
|
912
|
+
var y;
|
|
913
|
+
const x = ((y = window.visualViewport) == null ? void 0 : y.height) || 0, B = window.innerHeight;
|
|
914
|
+
let k = B - x;
|
|
915
|
+
const Z = p.current.getBoundingClientRect().height || 0, Y = Z > B * 0.8;
|
|
916
|
+
xt.current || (xt.current = Z);
|
|
917
|
+
const et = p.current.getBoundingClientRect().top;
|
|
918
|
+
if (Math.abs(Vt.current - k) > 60 && (ot.current = !ot.current), r && r.length > 0 && ct && it) {
|
|
919
|
+
const Q = ct[it] || 0;
|
|
920
|
+
k += Q;
|
|
921
|
+
}
|
|
922
|
+
if (Vt.current = k, Z > x || ot.current) {
|
|
923
|
+
const Q = p.current.getBoundingClientRect().height;
|
|
924
|
+
let G = Q;
|
|
925
|
+
Q > x && (G = x - (Y ? et : Nt)), T ? p.current.style.height = `${Q - Math.max(k, 0)}px` : p.current.style.height = `${Math.max(G, x - et)}px`;
|
|
926
|
+
} else En() || (p.current.style.height = `${xt.current}px`);
|
|
927
|
+
r && r.length > 0 && !ot.current ? p.current.style.bottom = "0px" : p.current.style.bottom = `${Math.max(k, 0)}px`;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
return (l = window.visualViewport) == null || l.addEventListener("resize", R), () => {
|
|
931
|
+
var S;
|
|
932
|
+
return (S = window.visualViewport) == null ? void 0 : S.removeEventListener("resize", R);
|
|
933
|
+
};
|
|
934
|
+
}, [
|
|
935
|
+
it,
|
|
936
|
+
r,
|
|
937
|
+
ct
|
|
938
|
+
]);
|
|
939
|
+
function dt(l) {
|
|
940
|
+
Be(), w?.(), l || j(!1), setTimeout(() => {
|
|
941
|
+
r && qt(r[0]);
|
|
942
|
+
}, C.DURATION * 1e3);
|
|
943
|
+
}
|
|
944
|
+
function Kt() {
|
|
945
|
+
if (!p.current) return;
|
|
946
|
+
const l = document.querySelector("[data-vaul-drawer-wrapper]"), R = Dt(p.current, f);
|
|
947
|
+
_(p.current, {
|
|
948
|
+
transform: "translate3d(0, 0, 0)",
|
|
949
|
+
transition: `transform ${C.DURATION}s cubic-bezier(${C.EASE.join(",")})`
|
|
950
|
+
}), _(at.current, {
|
|
951
|
+
transition: `opacity ${C.DURATION}s cubic-bezier(${C.EASE.join(",")})`,
|
|
952
|
+
opacity: "1"
|
|
953
|
+
}), c && R && R > 0 && F && _(l, {
|
|
954
|
+
borderRadius: `${Ce}px`,
|
|
955
|
+
overflow: "hidden",
|
|
956
|
+
...P(f) ? {
|
|
957
|
+
transform: `scale(${vt()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
|
|
958
|
+
transformOrigin: "top"
|
|
959
|
+
} : {
|
|
960
|
+
transform: `scale(${vt()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
|
|
961
|
+
transformOrigin: "left"
|
|
962
|
+
},
|
|
963
|
+
transitionProperty: "transform, border-radius",
|
|
964
|
+
transitionDuration: `${C.DURATION}s`,
|
|
965
|
+
transitionTimingFunction: `cubic-bezier(${C.EASE.join(",")})`
|
|
966
|
+
}, !0);
|
|
967
|
+
}
|
|
968
|
+
function Be() {
|
|
969
|
+
!J || !p.current || (p.current.classList.remove(It), ut.current = !1, st(!1), Tt.current = /* @__PURE__ */ new Date());
|
|
970
|
+
}
|
|
971
|
+
function We(l) {
|
|
972
|
+
if (!J || !p.current) return;
|
|
973
|
+
p.current.classList.remove(It), ut.current = !1, st(!1), Tt.current = /* @__PURE__ */ new Date();
|
|
974
|
+
const R = Dt(p.current, f);
|
|
975
|
+
if (!l || !Gt(l.target, !1) || !R || Number.isNaN(R) || St.current === null) return;
|
|
976
|
+
const S = Tt.current.getTime() - St.current.getTime(), y = Ot.current - (P(f) ? l.pageY : l.pageX), x = Math.abs(y) / S;
|
|
977
|
+
if (x > 0.05 && (Ut(!0), setTimeout(() => {
|
|
978
|
+
Ut(!1);
|
|
979
|
+
}, 200)), r) {
|
|
980
|
+
$e({
|
|
981
|
+
draggedDistance: y * (f === "bottom" || f === "right" ? 1 : -1),
|
|
982
|
+
closeDrawer: dt,
|
|
983
|
+
velocity: x,
|
|
984
|
+
dismissible: g
|
|
985
|
+
}), o?.(l, !0);
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
if (f === "bottom" || f === "right" ? y > 0 : y < 0) {
|
|
989
|
+
Kt(), o?.(l, !0);
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
if (x > Te) {
|
|
993
|
+
dt(), o?.(l, !1);
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
var B;
|
|
997
|
+
const k = Math.min((B = p.current.getBoundingClientRect().height) != null ? B : 0, window.innerHeight);
|
|
998
|
+
var Z;
|
|
999
|
+
const Y = Math.min((Z = p.current.getBoundingClientRect().width) != null ? Z : 0, window.innerWidth), et = f === "left" || f === "right";
|
|
1000
|
+
if (Math.abs(R) >= (et ? Y : k) * v) {
|
|
1001
|
+
dt(), o?.(l, !1);
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
o?.(l, !0), Kt();
|
|
1005
|
+
}
|
|
1006
|
+
i.useEffect(() => (F && (_(document.documentElement, {
|
|
1007
|
+
scrollBehavior: "auto"
|
|
1008
|
+
}), wt.current = /* @__PURE__ */ new Date()), () => {
|
|
1009
|
+
Nn(document.documentElement, "scrollBehavior");
|
|
1010
|
+
}), [
|
|
1011
|
+
F
|
|
1012
|
+
]);
|
|
1013
|
+
function Ue(l) {
|
|
1014
|
+
const R = l ? (window.innerWidth - nt) / window.innerWidth : 1, S = l ? -nt : 0;
|
|
1015
|
+
Ct.current && window.clearTimeout(Ct.current), _(p.current, {
|
|
1016
|
+
transition: `transform ${C.DURATION}s cubic-bezier(${C.EASE.join(",")})`,
|
|
1017
|
+
transform: P(f) ? `scale(${R}) translate3d(0, ${S}px, 0)` : `scale(${R}) translate3d(${S}px, 0, 0)`
|
|
1018
|
+
}), !l && p.current && (Ct.current = setTimeout(() => {
|
|
1019
|
+
const y = Dt(p.current, f);
|
|
1020
|
+
_(p.current, {
|
|
1021
|
+
transition: "none",
|
|
1022
|
+
transform: P(f) ? `translate3d(0, ${y}px, 0)` : `translate3d(${y}px, 0, 0)`
|
|
1023
|
+
});
|
|
1024
|
+
}, 500));
|
|
1025
|
+
}
|
|
1026
|
+
function ze(l, R) {
|
|
1027
|
+
if (R < 0) return;
|
|
1028
|
+
const S = (window.innerWidth - nt) / window.innerWidth, y = S + R * (1 - S), x = -nt + R * nt;
|
|
1029
|
+
_(p.current, {
|
|
1030
|
+
transform: P(f) ? `scale(${y}) translate3d(0, ${x}px, 0)` : `scale(${y}) translate3d(${x}px, 0, 0)`,
|
|
1031
|
+
transition: "none"
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
function Ve(l, R) {
|
|
1035
|
+
const S = P(f) ? window.innerHeight : window.innerWidth, y = R ? (S - nt) / S : 1, x = R ? -nt : 0;
|
|
1036
|
+
R && _(p.current, {
|
|
1037
|
+
transition: `transform ${C.DURATION}s cubic-bezier(${C.EASE.join(",")})`,
|
|
1038
|
+
transform: P(f) ? `scale(${y}) translate3d(0, ${x}px, 0)` : `scale(${y}) translate3d(${x}px, 0, 0)`
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
return i.useEffect(() => {
|
|
1042
|
+
U || window.requestAnimationFrame(() => {
|
|
1043
|
+
document.body.style.pointerEvents = "auto";
|
|
1044
|
+
});
|
|
1045
|
+
}, [
|
|
1046
|
+
U
|
|
1047
|
+
]), /* @__PURE__ */ i.createElement(mn, {
|
|
1048
|
+
defaultOpen: X,
|
|
1049
|
+
onOpenChange: (l) => {
|
|
1050
|
+
!g && !l || (l ? K(!0) : dt(!0), j(l));
|
|
1051
|
+
},
|
|
1052
|
+
open: F
|
|
1053
|
+
}, /* @__PURE__ */ i.createElement(be.Provider, {
|
|
1054
|
+
value: {
|
|
1055
|
+
activeSnapPoint: Ie,
|
|
1056
|
+
snapPoints: r,
|
|
1057
|
+
setActiveSnapPoint: qt,
|
|
1058
|
+
drawerRef: p,
|
|
1059
|
+
overlayRef: at,
|
|
1060
|
+
onOpenChange: n,
|
|
1061
|
+
onPress: ke,
|
|
1062
|
+
onRelease: We,
|
|
1063
|
+
onDrag: He,
|
|
1064
|
+
dismissible: g,
|
|
1065
|
+
shouldAnimate: zt,
|
|
1066
|
+
handleOnly: m,
|
|
1067
|
+
isOpen: F,
|
|
1068
|
+
isDragging: J,
|
|
1069
|
+
shouldFade: Xt,
|
|
1070
|
+
closeDrawer: dt,
|
|
1071
|
+
onNestedDrag: ze,
|
|
1072
|
+
onNestedOpenChange: Ue,
|
|
1073
|
+
onNestedRelease: Ve,
|
|
1074
|
+
keyboardIsOpen: ot,
|
|
1075
|
+
modal: U,
|
|
1076
|
+
snapPointsOffset: ct,
|
|
1077
|
+
activeSnapPointIndex: it,
|
|
1078
|
+
direction: f,
|
|
1079
|
+
shouldScaleBackground: c,
|
|
1080
|
+
setBackgroundColorOnScale: s,
|
|
1081
|
+
noBodyStyles: M,
|
|
1082
|
+
container: $,
|
|
1083
|
+
autoFocus: V
|
|
1084
|
+
}
|
|
1085
|
+
}, e));
|
|
1086
|
+
}
|
|
1087
|
+
const Ae = /* @__PURE__ */ i.forwardRef(function({ ...t }, n) {
|
|
1088
|
+
const { overlayRef: e, snapPoints: a, onRelease: o, shouldFade: r, isOpen: c, modal: s, shouldAnimate: v } = ht(), E = Ee(n, e), g = a && a.length > 0;
|
|
1089
|
+
if (!s)
|
|
1090
|
+
return null;
|
|
1091
|
+
const m = i.useCallback((h) => o(h), [
|
|
1092
|
+
o
|
|
1093
|
+
]);
|
|
1094
|
+
return /* @__PURE__ */ i.createElement(wn, {
|
|
1095
|
+
onMouseUp: m,
|
|
1096
|
+
ref: E,
|
|
1097
|
+
"data-vaul-overlay": "",
|
|
1098
|
+
"data-vaul-snap-points": c && g ? "true" : "false",
|
|
1099
|
+
"data-vaul-snap-points-overlay": c && r ? "true" : "false",
|
|
1100
|
+
"data-vaul-animate": v?.current ? "true" : "false",
|
|
1101
|
+
...t
|
|
1102
|
+
});
|
|
1103
|
+
});
|
|
1104
|
+
Ae.displayName = "Drawer.Overlay";
|
|
1105
|
+
const Pe = /* @__PURE__ */ i.forwardRef(function({ onPointerDownOutside: t, style: n, onOpenAutoFocus: e, ...a }, o) {
|
|
1106
|
+
const { drawerRef: r, onPress: c, onRelease: s, onDrag: v, keyboardIsOpen: E, snapPointsOffset: g, activeSnapPointIndex: m, modal: h, isOpen: W, direction: H, snapPoints: T, container: U, handleOnly: w, shouldAnimate: I, autoFocus: M } = ht(), [f, X] = i.useState(!1), tt = Ee(o, r), d = i.useRef(null), D = i.useRef(null), b = i.useRef(!1), L = T && T.length > 0;
|
|
1107
|
+
zn();
|
|
1108
|
+
const $ = (u, z, F = 0) => {
|
|
1109
|
+
if (b.current) return !0;
|
|
1110
|
+
const j = Math.abs(u.y), N = Math.abs(u.x), K = N > j, J = [
|
|
1111
|
+
"bottom",
|
|
1112
|
+
"right"
|
|
1113
|
+
].includes(z) ? 1 : -1;
|
|
1114
|
+
if (z === "left" || z === "right") {
|
|
1115
|
+
if (!(u.x * J < 0) && N >= 0 && N <= F)
|
|
1116
|
+
return K;
|
|
1117
|
+
} else if (!(u.y * J < 0) && j >= 0 && j <= F)
|
|
1118
|
+
return !K;
|
|
1119
|
+
return b.current = !0, !0;
|
|
1120
|
+
};
|
|
1121
|
+
i.useEffect(() => {
|
|
1122
|
+
L && window.requestAnimationFrame(() => {
|
|
1123
|
+
X(!0);
|
|
1124
|
+
});
|
|
1125
|
+
}, []);
|
|
1126
|
+
function V(u) {
|
|
1127
|
+
d.current = null, b.current = !1, s(u);
|
|
1128
|
+
}
|
|
1129
|
+
return /* @__PURE__ */ i.createElement(vn, {
|
|
1130
|
+
"data-vaul-drawer-direction": H,
|
|
1131
|
+
"data-vaul-drawer": "",
|
|
1132
|
+
"data-vaul-delayed-snap-points": f ? "true" : "false",
|
|
1133
|
+
"data-vaul-snap-points": W && L ? "true" : "false",
|
|
1134
|
+
"data-vaul-custom-container": U ? "true" : "false",
|
|
1135
|
+
"data-vaul-animate": I?.current ? "true" : "false",
|
|
1136
|
+
...a,
|
|
1137
|
+
ref: tt,
|
|
1138
|
+
style: g && g.length > 0 ? {
|
|
1139
|
+
"--snap-point-height": `${g[m ?? 0]}px`,
|
|
1140
|
+
...n
|
|
1141
|
+
} : n,
|
|
1142
|
+
onPointerDown: (u) => {
|
|
1143
|
+
w || (a.onPointerDown == null || a.onPointerDown.call(a, u), d.current = {
|
|
1144
|
+
x: u.pageX,
|
|
1145
|
+
y: u.pageY
|
|
1146
|
+
}, c(u));
|
|
1147
|
+
},
|
|
1148
|
+
onOpenAutoFocus: (u) => {
|
|
1149
|
+
e?.(u), M || u.preventDefault();
|
|
1150
|
+
},
|
|
1151
|
+
onPointerDownOutside: (u) => {
|
|
1152
|
+
if (t?.(u), !h || u.defaultPrevented) {
|
|
1153
|
+
u.preventDefault();
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
E.current && (E.current = !1);
|
|
1157
|
+
},
|
|
1158
|
+
onFocusOutside: (u) => {
|
|
1159
|
+
if (!h) {
|
|
1160
|
+
u.preventDefault();
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
},
|
|
1164
|
+
onPointerMove: (u) => {
|
|
1165
|
+
if (D.current = u, w || (a.onPointerMove == null || a.onPointerMove.call(a, u), !d.current)) return;
|
|
1166
|
+
const z = u.pageY - d.current.y, F = u.pageX - d.current.x, j = u.pointerType === "touch" ? 10 : 2;
|
|
1167
|
+
$({
|
|
1168
|
+
x: F,
|
|
1169
|
+
y: z
|
|
1170
|
+
}, H, j) ? v(u) : (Math.abs(F) > j || Math.abs(z) > j) && (d.current = null);
|
|
1171
|
+
},
|
|
1172
|
+
onPointerUp: (u) => {
|
|
1173
|
+
a.onPointerUp == null || a.onPointerUp.call(a, u), d.current = null, b.current = !1, s(u);
|
|
1174
|
+
},
|
|
1175
|
+
onPointerOut: (u) => {
|
|
1176
|
+
a.onPointerOut == null || a.onPointerOut.call(a, u), V(D.current);
|
|
1177
|
+
},
|
|
1178
|
+
onContextMenu: (u) => {
|
|
1179
|
+
a.onContextMenu == null || a.onContextMenu.call(a, u), D.current && V(D.current);
|
|
1180
|
+
}
|
|
1181
|
+
});
|
|
1182
|
+
});
|
|
1183
|
+
Pe.displayName = "Drawer.Content";
|
|
1184
|
+
const Yn = 250, qn = 120, Xn = /* @__PURE__ */ i.forwardRef(function({ preventCycle: t = !1, children: n, ...e }, a) {
|
|
1185
|
+
const { closeDrawer: o, isDragging: r, snapPoints: c, activeSnapPoint: s, setActiveSnapPoint: v, dismissible: E, handleOnly: g, isOpen: m, onPress: h, onDrag: W } = ht(), H = i.useRef(null), T = i.useRef(!1);
|
|
1186
|
+
function U() {
|
|
1187
|
+
if (T.current) {
|
|
1188
|
+
M();
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
window.setTimeout(() => {
|
|
1192
|
+
w();
|
|
1193
|
+
}, qn);
|
|
1194
|
+
}
|
|
1195
|
+
function w() {
|
|
1196
|
+
if (r || t || T.current) {
|
|
1197
|
+
M();
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
if (M(), !c || c.length === 0) {
|
|
1201
|
+
E || o();
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
if (s === c[c.length - 1] && E) {
|
|
1205
|
+
o();
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
const X = c.findIndex((d) => d === s);
|
|
1209
|
+
if (X === -1) return;
|
|
1210
|
+
const tt = c[X + 1];
|
|
1211
|
+
v(tt);
|
|
1212
|
+
}
|
|
1213
|
+
function I() {
|
|
1214
|
+
H.current = window.setTimeout(() => {
|
|
1215
|
+
T.current = !0;
|
|
1216
|
+
}, Yn);
|
|
1217
|
+
}
|
|
1218
|
+
function M() {
|
|
1219
|
+
H.current && window.clearTimeout(H.current), T.current = !1;
|
|
1220
|
+
}
|
|
1221
|
+
return /* @__PURE__ */ i.createElement("div", {
|
|
1222
|
+
onClick: U,
|
|
1223
|
+
onPointerCancel: M,
|
|
1224
|
+
onPointerDown: (f) => {
|
|
1225
|
+
g && h(f), I();
|
|
1226
|
+
},
|
|
1227
|
+
onPointerMove: (f) => {
|
|
1228
|
+
g && W(f);
|
|
1229
|
+
},
|
|
1230
|
+
// onPointerUp is already handled by the content component
|
|
1231
|
+
ref: a,
|
|
1232
|
+
"data-vaul-drawer-visible": m ? "true" : "false",
|
|
1233
|
+
"data-vaul-handle": "",
|
|
1234
|
+
"aria-hidden": "true",
|
|
1235
|
+
...e
|
|
1236
|
+
}, /* @__PURE__ */ i.createElement("span", {
|
|
1237
|
+
"data-vaul-handle-hitarea": "",
|
|
1238
|
+
"aria-hidden": "true"
|
|
1239
|
+
}, n));
|
|
1240
|
+
});
|
|
1241
|
+
Xn.displayName = "Drawer.Handle";
|
|
1242
|
+
function Gn(t) {
|
|
1243
|
+
const n = ht(), { container: e = n.container, ...a } = t;
|
|
1244
|
+
return /* @__PURE__ */ i.createElement(hn, {
|
|
1245
|
+
container: e,
|
|
1246
|
+
...a
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
const er = {
|
|
1250
|
+
Root: jn,
|
|
1251
|
+
Content: Pe,
|
|
1252
|
+
Overlay: Ae,
|
|
1253
|
+
Trigger: gn,
|
|
1254
|
+
Portal: Gn,
|
|
1255
|
+
Close: Dn,
|
|
1256
|
+
Title: yn,
|
|
1257
|
+
Description: bn
|
|
1258
|
+
};
|
|
1259
|
+
export {
|
|
1260
|
+
er as D
|
|
1261
|
+
};
|