@neurodyn/react-ar 0.0.0-canary-20260817174540
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/146.js +6969 -0
- package/dist/191.js +4274 -0
- package/dist/191.js.LICENSE.txt +19 -0
- package/dist/index.d.ts +11823 -0
- package/dist/index.js +18586 -0
- package/package.json +74 -0
package/dist/191.js
ADDED
|
@@ -0,0 +1,4274 @@
|
|
|
1
|
+
/*! For license information please see 191.js.LICENSE.txt */
|
|
2
|
+
export const __rspack_esm_id = "191";
|
|
3
|
+
export const __rspack_esm_ids = [
|
|
4
|
+
"191"
|
|
5
|
+
];
|
|
6
|
+
export const __webpack_modules__ = {
|
|
7
|
+
"../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.3/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
8
|
+
/**
|
|
9
|
+
* @license React
|
|
10
|
+
* use-sync-external-store-shim.development.js
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/ "production" !== process.env.NODE_ENV && function() {
|
|
17
|
+
function is(x, y) {
|
|
18
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
19
|
+
}
|
|
20
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
21
|
+
didWarnOld18Alpha || void 0 === React.startTransition || (didWarnOld18Alpha = !0, console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
|
|
22
|
+
var value = getSnapshot();
|
|
23
|
+
if (!didWarnUncachedGetSnapshot) {
|
|
24
|
+
var cachedValue = getSnapshot();
|
|
25
|
+
objectIs(value, cachedValue) || (console.error("The result of getSnapshot should be cached to avoid an infinite loop"), didWarnUncachedGetSnapshot = !0);
|
|
26
|
+
}
|
|
27
|
+
cachedValue = useState({
|
|
28
|
+
inst: {
|
|
29
|
+
value: value,
|
|
30
|
+
getSnapshot: getSnapshot
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
|
|
34
|
+
useLayoutEffect(function() {
|
|
35
|
+
inst.value = value;
|
|
36
|
+
inst.getSnapshot = getSnapshot;
|
|
37
|
+
checkIfSnapshotChanged(inst) && forceUpdate({
|
|
38
|
+
inst: inst
|
|
39
|
+
});
|
|
40
|
+
}, [
|
|
41
|
+
subscribe,
|
|
42
|
+
value,
|
|
43
|
+
getSnapshot
|
|
44
|
+
]);
|
|
45
|
+
useEffect(function() {
|
|
46
|
+
checkIfSnapshotChanged(inst) && forceUpdate({
|
|
47
|
+
inst: inst
|
|
48
|
+
});
|
|
49
|
+
return subscribe(function() {
|
|
50
|
+
checkIfSnapshotChanged(inst) && forceUpdate({
|
|
51
|
+
inst: inst
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}, [
|
|
55
|
+
subscribe
|
|
56
|
+
]);
|
|
57
|
+
useDebugValue(value);
|
|
58
|
+
return value;
|
|
59
|
+
}
|
|
60
|
+
function checkIfSnapshotChanged(inst) {
|
|
61
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
62
|
+
inst = inst.value;
|
|
63
|
+
try {
|
|
64
|
+
var nextValue = latestGetSnapshot();
|
|
65
|
+
return !objectIs(inst, nextValue);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return !0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
71
|
+
return getSnapshot();
|
|
72
|
+
}
|
|
73
|
+
"u" > typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" == typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
74
|
+
var React = __webpack_require__("react"), objectIs = "function" == typeof Object.is ? Object.is : is, useState = React.useState, useEffect = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue, didWarnOld18Alpha = !1, didWarnUncachedGetSnapshot = !1, shim = "u" < typeof window || void 0 === window.document || void 0 === window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
75
|
+
exports.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
|
|
76
|
+
"u" > typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" == typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
77
|
+
}();
|
|
78
|
+
},
|
|
79
|
+
"../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.3/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
80
|
+
/**
|
|
81
|
+
* @license React
|
|
82
|
+
* use-sync-external-store-shim.production.js
|
|
83
|
+
*
|
|
84
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
85
|
+
*
|
|
86
|
+
* This source code is licensed under the MIT license found in the
|
|
87
|
+
* LICENSE file in the root directory of this source tree.
|
|
88
|
+
*/ var React = __webpack_require__("react");
|
|
89
|
+
function is(x, y) {
|
|
90
|
+
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
91
|
+
}
|
|
92
|
+
var objectIs = "function" == typeof Object.is ? Object.is : is, useState = React.useState, useEffect = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
|
|
93
|
+
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
94
|
+
var value = getSnapshot(), _useState = useState({
|
|
95
|
+
inst: {
|
|
96
|
+
value: value,
|
|
97
|
+
getSnapshot: getSnapshot
|
|
98
|
+
}
|
|
99
|
+
}), inst = _useState[0].inst, forceUpdate = _useState[1];
|
|
100
|
+
useLayoutEffect(function() {
|
|
101
|
+
inst.value = value;
|
|
102
|
+
inst.getSnapshot = getSnapshot;
|
|
103
|
+
checkIfSnapshotChanged(inst) && forceUpdate({
|
|
104
|
+
inst: inst
|
|
105
|
+
});
|
|
106
|
+
}, [
|
|
107
|
+
subscribe,
|
|
108
|
+
value,
|
|
109
|
+
getSnapshot
|
|
110
|
+
]);
|
|
111
|
+
useEffect(function() {
|
|
112
|
+
checkIfSnapshotChanged(inst) && forceUpdate({
|
|
113
|
+
inst: inst
|
|
114
|
+
});
|
|
115
|
+
return subscribe(function() {
|
|
116
|
+
checkIfSnapshotChanged(inst) && forceUpdate({
|
|
117
|
+
inst: inst
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}, [
|
|
121
|
+
subscribe
|
|
122
|
+
]);
|
|
123
|
+
useDebugValue(value);
|
|
124
|
+
return value;
|
|
125
|
+
}
|
|
126
|
+
function checkIfSnapshotChanged(inst) {
|
|
127
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
128
|
+
inst = inst.value;
|
|
129
|
+
try {
|
|
130
|
+
var nextValue = latestGetSnapshot();
|
|
131
|
+
return !objectIs(inst, nextValue);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
return !0;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function useSyncExternalStore$1(subscribe, getSnapshot) {
|
|
137
|
+
return getSnapshot();
|
|
138
|
+
}
|
|
139
|
+
var shim = "u" < typeof window || void 0 === window.document || void 0 === window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
|
|
140
|
+
exports.useSyncExternalStore = void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;
|
|
141
|
+
},
|
|
142
|
+
"../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.3/node_modules/use-sync-external-store/shim/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
143
|
+
if ('production' === process.env.NODE_ENV) module.exports = __webpack_require__("../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.3/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js");
|
|
144
|
+
else module.exports = __webpack_require__("../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.3/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js");
|
|
145
|
+
},
|
|
146
|
+
"../../node_modules/.pnpm/@radix-ui+react-avatar@1.1.10_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react_d8fd4e0f3e6dc8c66630acea8953961b/node_modules/@radix-ui/react-avatar/dist/index.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
147
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
148
|
+
bL: ()=>Root,
|
|
149
|
+
H4: ()=>Fallback,
|
|
150
|
+
_V: ()=>Image
|
|
151
|
+
});
|
|
152
|
+
var external_react_ = __webpack_require__("react");
|
|
153
|
+
var dist = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-context@1.1.2_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-context/dist/index.mjs");
|
|
154
|
+
var react_use_callback_ref_dist = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-use-callback-ref@1.1.1_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs");
|
|
155
|
+
var react_use_layout_effect_dist = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-use-layout-effect@1.1.1_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs");
|
|
156
|
+
var react_primitive_dist = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-primitive@2.1.3_@types+react-dom@19.2.3_@types+react@19.2.9__@types+rea_57eb89d0235dc4221ced9969d75eafcb/node_modules/@radix-ui/react-primitive/dist/index.mjs");
|
|
157
|
+
var shim = __webpack_require__("../../node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.3/node_modules/use-sync-external-store/shim/index.js");
|
|
158
|
+
function useIsHydrated() {
|
|
159
|
+
return (0, shim.useSyncExternalStore)(subscribe, ()=>true, ()=>false);
|
|
160
|
+
}
|
|
161
|
+
function subscribe() {
|
|
162
|
+
return ()=>{};
|
|
163
|
+
}
|
|
164
|
+
var jsx_runtime_ = __webpack_require__("react/jsx-runtime");
|
|
165
|
+
var AVATAR_NAME = "Avatar";
|
|
166
|
+
var [createAvatarContext, createAvatarScope] = (0, dist.A)(AVATAR_NAME);
|
|
167
|
+
var [AvatarProvider, useAvatarContext] = createAvatarContext(AVATAR_NAME);
|
|
168
|
+
var Avatar = external_react_.forwardRef((props, forwardedRef)=>{
|
|
169
|
+
const { __scopeAvatar, ...avatarProps } = props;
|
|
170
|
+
const [imageLoadingStatus, setImageLoadingStatus] = external_react_.useState("idle");
|
|
171
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(AvatarProvider, {
|
|
172
|
+
scope: __scopeAvatar,
|
|
173
|
+
imageLoadingStatus,
|
|
174
|
+
onImageLoadingStatusChange: setImageLoadingStatus,
|
|
175
|
+
children: /* @__PURE__ */ (0, jsx_runtime_.jsx)(react_primitive_dist.sG.span, {
|
|
176
|
+
...avatarProps,
|
|
177
|
+
ref: forwardedRef
|
|
178
|
+
})
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
Avatar.displayName = AVATAR_NAME;
|
|
182
|
+
var IMAGE_NAME = "AvatarImage";
|
|
183
|
+
var AvatarImage = external_react_.forwardRef((props, forwardedRef)=>{
|
|
184
|
+
const { __scopeAvatar, src, onLoadingStatusChange = ()=>{}, ...imageProps } = props;
|
|
185
|
+
const context = useAvatarContext(IMAGE_NAME, __scopeAvatar);
|
|
186
|
+
const imageLoadingStatus = useImageLoadingStatus(src, imageProps);
|
|
187
|
+
const handleLoadingStatusChange = (0, react_use_callback_ref_dist.c)((status)=>{
|
|
188
|
+
onLoadingStatusChange(status);
|
|
189
|
+
context.onImageLoadingStatusChange(status);
|
|
190
|
+
});
|
|
191
|
+
(0, react_use_layout_effect_dist.N)(()=>{
|
|
192
|
+
if ("idle" !== imageLoadingStatus) handleLoadingStatusChange(imageLoadingStatus);
|
|
193
|
+
}, [
|
|
194
|
+
imageLoadingStatus,
|
|
195
|
+
handleLoadingStatusChange
|
|
196
|
+
]);
|
|
197
|
+
return "loaded" === imageLoadingStatus ? /* @__PURE__ */ (0, jsx_runtime_.jsx)(react_primitive_dist.sG.img, {
|
|
198
|
+
...imageProps,
|
|
199
|
+
ref: forwardedRef,
|
|
200
|
+
src
|
|
201
|
+
}) : null;
|
|
202
|
+
});
|
|
203
|
+
AvatarImage.displayName = IMAGE_NAME;
|
|
204
|
+
var FALLBACK_NAME = "AvatarFallback";
|
|
205
|
+
var AvatarFallback = external_react_.forwardRef((props, forwardedRef)=>{
|
|
206
|
+
const { __scopeAvatar, delayMs, ...fallbackProps } = props;
|
|
207
|
+
const context = useAvatarContext(FALLBACK_NAME, __scopeAvatar);
|
|
208
|
+
const [canRender, setCanRender] = external_react_.useState(void 0 === delayMs);
|
|
209
|
+
external_react_.useEffect(()=>{
|
|
210
|
+
if (void 0 !== delayMs) {
|
|
211
|
+
const timerId = window.setTimeout(()=>setCanRender(true), delayMs);
|
|
212
|
+
return ()=>window.clearTimeout(timerId);
|
|
213
|
+
}
|
|
214
|
+
}, [
|
|
215
|
+
delayMs
|
|
216
|
+
]);
|
|
217
|
+
return canRender && "loaded" !== context.imageLoadingStatus ? /* @__PURE__ */ (0, jsx_runtime_.jsx)(react_primitive_dist.sG.span, {
|
|
218
|
+
...fallbackProps,
|
|
219
|
+
ref: forwardedRef
|
|
220
|
+
}) : null;
|
|
221
|
+
});
|
|
222
|
+
AvatarFallback.displayName = FALLBACK_NAME;
|
|
223
|
+
function resolveLoadingStatus(image, src) {
|
|
224
|
+
if (!image) return "idle";
|
|
225
|
+
if (!src) return "error";
|
|
226
|
+
if (image.src !== src) image.src = src;
|
|
227
|
+
return image.complete && image.naturalWidth > 0 ? "loaded" : "loading";
|
|
228
|
+
}
|
|
229
|
+
function useImageLoadingStatus(src, { referrerPolicy, crossOrigin }) {
|
|
230
|
+
const isHydrated = useIsHydrated();
|
|
231
|
+
const imageRef = external_react_.useRef(null);
|
|
232
|
+
const image = (()=>{
|
|
233
|
+
if (!isHydrated) return null;
|
|
234
|
+
if (!imageRef.current) imageRef.current = new window.Image();
|
|
235
|
+
return imageRef.current;
|
|
236
|
+
})();
|
|
237
|
+
const [loadingStatus, setLoadingStatus] = external_react_.useState(()=>resolveLoadingStatus(image, src));
|
|
238
|
+
(0, react_use_layout_effect_dist.N)(()=>{
|
|
239
|
+
setLoadingStatus(resolveLoadingStatus(image, src));
|
|
240
|
+
}, [
|
|
241
|
+
image,
|
|
242
|
+
src
|
|
243
|
+
]);
|
|
244
|
+
(0, react_use_layout_effect_dist.N)(()=>{
|
|
245
|
+
const updateStatus = (status)=>()=>{
|
|
246
|
+
setLoadingStatus(status);
|
|
247
|
+
};
|
|
248
|
+
if (!image) return;
|
|
249
|
+
const handleLoad = updateStatus("loaded");
|
|
250
|
+
const handleError = updateStatus("error");
|
|
251
|
+
image.addEventListener("load", handleLoad);
|
|
252
|
+
image.addEventListener("error", handleError);
|
|
253
|
+
if (referrerPolicy) image.referrerPolicy = referrerPolicy;
|
|
254
|
+
if ("string" == typeof crossOrigin) image.crossOrigin = crossOrigin;
|
|
255
|
+
return ()=>{
|
|
256
|
+
image.removeEventListener("load", handleLoad);
|
|
257
|
+
image.removeEventListener("error", handleError);
|
|
258
|
+
};
|
|
259
|
+
}, [
|
|
260
|
+
image,
|
|
261
|
+
crossOrigin,
|
|
262
|
+
referrerPolicy
|
|
263
|
+
]);
|
|
264
|
+
return loadingStatus;
|
|
265
|
+
}
|
|
266
|
+
var Root = Avatar;
|
|
267
|
+
var Image = AvatarImage;
|
|
268
|
+
var Fallback = AvatarFallback;
|
|
269
|
+
},
|
|
270
|
+
"../../node_modules/.pnpm/@radix-ui+react-context@1.1.2_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-context/dist/index.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
271
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
272
|
+
A: ()=>createContextScope
|
|
273
|
+
});
|
|
274
|
+
var react__rspack_import_0 = __webpack_require__("react");
|
|
275
|
+
var react_jsx_runtime__rspack_import_1 = __webpack_require__("react/jsx-runtime");
|
|
276
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
277
|
+
let defaultContexts = [];
|
|
278
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
279
|
+
const BaseContext = react__rspack_import_0.createContext(defaultContext);
|
|
280
|
+
const index = defaultContexts.length;
|
|
281
|
+
defaultContexts = [
|
|
282
|
+
...defaultContexts,
|
|
283
|
+
defaultContext
|
|
284
|
+
];
|
|
285
|
+
const Provider = (props)=>{
|
|
286
|
+
const { scope, children, ...context } = props;
|
|
287
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
288
|
+
const value = react__rspack_import_0.useMemo(()=>context, Object.values(context));
|
|
289
|
+
return /* @__PURE__ */ (0, react_jsx_runtime__rspack_import_1.jsx)(Context.Provider, {
|
|
290
|
+
value,
|
|
291
|
+
children
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
295
|
+
function useContext2(consumerName, scope) {
|
|
296
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
297
|
+
const context = react__rspack_import_0.useContext(Context);
|
|
298
|
+
if (context) return context;
|
|
299
|
+
if (void 0 !== defaultContext) return defaultContext;
|
|
300
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
301
|
+
}
|
|
302
|
+
return [
|
|
303
|
+
Provider,
|
|
304
|
+
useContext2
|
|
305
|
+
];
|
|
306
|
+
}
|
|
307
|
+
const createScope = ()=>{
|
|
308
|
+
const scopeContexts = defaultContexts.map((defaultContext)=>react__rspack_import_0.createContext(defaultContext));
|
|
309
|
+
return function(scope) {
|
|
310
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
311
|
+
return react__rspack_import_0.useMemo(()=>({
|
|
312
|
+
[`__scope${scopeName}`]: {
|
|
313
|
+
...scope,
|
|
314
|
+
[scopeName]: contexts
|
|
315
|
+
}
|
|
316
|
+
}), [
|
|
317
|
+
scope,
|
|
318
|
+
contexts
|
|
319
|
+
]);
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
createScope.scopeName = scopeName;
|
|
323
|
+
return [
|
|
324
|
+
createContext3,
|
|
325
|
+
composeContextScopes(createScope, ...createContextScopeDeps)
|
|
326
|
+
];
|
|
327
|
+
}
|
|
328
|
+
function composeContextScopes(...scopes) {
|
|
329
|
+
const baseScope = scopes[0];
|
|
330
|
+
if (1 === scopes.length) return baseScope;
|
|
331
|
+
const createScope = ()=>{
|
|
332
|
+
const scopeHooks = scopes.map((createScope2)=>({
|
|
333
|
+
useScope: createScope2(),
|
|
334
|
+
scopeName: createScope2.scopeName
|
|
335
|
+
}));
|
|
336
|
+
return function(overrideScopes) {
|
|
337
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName })=>{
|
|
338
|
+
const scopeProps = useScope(overrideScopes);
|
|
339
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
340
|
+
return {
|
|
341
|
+
...nextScopes2,
|
|
342
|
+
...currentScope
|
|
343
|
+
};
|
|
344
|
+
}, {});
|
|
345
|
+
return react__rspack_import_0.useMemo(()=>({
|
|
346
|
+
[`__scope${baseScope.scopeName}`]: nextScopes
|
|
347
|
+
}), [
|
|
348
|
+
nextScopes
|
|
349
|
+
]);
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
createScope.scopeName = baseScope.scopeName;
|
|
353
|
+
return createScope;
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
"../../node_modules/.pnpm/@radix-ui+react-primitive@2.1.3_@types+react-dom@19.2.3_@types+react@19.2.9__@types+rea_57eb89d0235dc4221ced9969d75eafcb/node_modules/@radix-ui/react-primitive/dist/index.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
357
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
358
|
+
sG: ()=>Primitive
|
|
359
|
+
});
|
|
360
|
+
var react__rspack_import_0 = __webpack_require__("react");
|
|
361
|
+
__webpack_require__("react-dom");
|
|
362
|
+
var _radix_ui_react_slot__rspack_import_3 = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-slot@1.2.3_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-slot/dist/index.mjs");
|
|
363
|
+
var react_jsx_runtime__rspack_import_2 = __webpack_require__("react/jsx-runtime");
|
|
364
|
+
var NODES = [
|
|
365
|
+
"a",
|
|
366
|
+
"button",
|
|
367
|
+
"div",
|
|
368
|
+
"form",
|
|
369
|
+
"h2",
|
|
370
|
+
"h3",
|
|
371
|
+
"img",
|
|
372
|
+
"input",
|
|
373
|
+
"label",
|
|
374
|
+
"li",
|
|
375
|
+
"nav",
|
|
376
|
+
"ol",
|
|
377
|
+
"p",
|
|
378
|
+
"select",
|
|
379
|
+
"span",
|
|
380
|
+
"svg",
|
|
381
|
+
"ul"
|
|
382
|
+
];
|
|
383
|
+
var Primitive = NODES.reduce((primitive, node)=>{
|
|
384
|
+
const Slot = (0, _radix_ui_react_slot__rspack_import_3.TL)(`Primitive.${node}`);
|
|
385
|
+
const Node = react__rspack_import_0.forwardRef((props, forwardedRef)=>{
|
|
386
|
+
const { asChild, ...primitiveProps } = props;
|
|
387
|
+
const Comp = asChild ? Slot : node;
|
|
388
|
+
if ("u" > typeof window) window[Symbol.for("radix-ui")] = true;
|
|
389
|
+
return /* @__PURE__ */ (0, react_jsx_runtime__rspack_import_2.jsx)(Comp, {
|
|
390
|
+
...primitiveProps,
|
|
391
|
+
ref: forwardedRef
|
|
392
|
+
});
|
|
393
|
+
});
|
|
394
|
+
Node.displayName = `Primitive.${node}`;
|
|
395
|
+
return {
|
|
396
|
+
...primitive,
|
|
397
|
+
[node]: Node
|
|
398
|
+
};
|
|
399
|
+
}, {});
|
|
400
|
+
},
|
|
401
|
+
"../../node_modules/.pnpm/@radix-ui+react-scroll-area@1.2.10_@types+react-dom@19.2.3_@types+react@19.2.9__@types+_72027b192e15199e0021686129280684/node_modules/@radix-ui/react-scroll-area/dist/index.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
402
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
403
|
+
LM: ()=>Viewport,
|
|
404
|
+
bL: ()=>dist_Root,
|
|
405
|
+
OK: ()=>Corner,
|
|
406
|
+
VM: ()=>ScrollAreaScrollbar,
|
|
407
|
+
lr: ()=>ScrollAreaThumb
|
|
408
|
+
});
|
|
409
|
+
var external_react_ = __webpack_require__("react");
|
|
410
|
+
var dist = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-primitive@2.1.3_@types+react-dom@19.2.3_@types+react@19.2.9__@types+rea_57eb89d0235dc4221ced9969d75eafcb/node_modules/@radix-ui/react-primitive/dist/index.mjs");
|
|
411
|
+
var react_compose_refs_dist = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-compose-refs@1.1.2_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-compose-refs/dist/index.mjs");
|
|
412
|
+
var react_use_layout_effect_dist = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-use-layout-effect@1.1.1_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs");
|
|
413
|
+
function useStateMachine(initialState, machine) {
|
|
414
|
+
return external_react_.useReducer((state, event)=>{
|
|
415
|
+
const nextState = machine[state][event];
|
|
416
|
+
return nextState ?? state;
|
|
417
|
+
}, initialState);
|
|
418
|
+
}
|
|
419
|
+
var Presence = (props)=>{
|
|
420
|
+
const { present, children } = props;
|
|
421
|
+
const presence = usePresence(present);
|
|
422
|
+
const child = "function" == typeof children ? children({
|
|
423
|
+
present: presence.isPresent
|
|
424
|
+
}) : external_react_.Children.only(children);
|
|
425
|
+
const ref = (0, react_compose_refs_dist.s)(presence.ref, getElementRef(child));
|
|
426
|
+
const forceMount = "function" == typeof children;
|
|
427
|
+
return forceMount || presence.isPresent ? external_react_.cloneElement(child, {
|
|
428
|
+
ref
|
|
429
|
+
}) : null;
|
|
430
|
+
};
|
|
431
|
+
Presence.displayName = "Presence";
|
|
432
|
+
function usePresence(present) {
|
|
433
|
+
const [node, setNode] = external_react_.useState();
|
|
434
|
+
const stylesRef = external_react_.useRef(null);
|
|
435
|
+
const prevPresentRef = external_react_.useRef(present);
|
|
436
|
+
const prevAnimationNameRef = external_react_.useRef("none");
|
|
437
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
438
|
+
const [state, send] = useStateMachine(initialState, {
|
|
439
|
+
mounted: {
|
|
440
|
+
UNMOUNT: "unmounted",
|
|
441
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
442
|
+
},
|
|
443
|
+
unmountSuspended: {
|
|
444
|
+
MOUNT: "mounted",
|
|
445
|
+
ANIMATION_END: "unmounted"
|
|
446
|
+
},
|
|
447
|
+
unmounted: {
|
|
448
|
+
MOUNT: "mounted"
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
external_react_.useEffect(()=>{
|
|
452
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
453
|
+
prevAnimationNameRef.current = "mounted" === state ? currentAnimationName : "none";
|
|
454
|
+
}, [
|
|
455
|
+
state
|
|
456
|
+
]);
|
|
457
|
+
(0, react_use_layout_effect_dist.N)(()=>{
|
|
458
|
+
const styles = stylesRef.current;
|
|
459
|
+
const wasPresent = prevPresentRef.current;
|
|
460
|
+
const hasPresentChanged = wasPresent !== present;
|
|
461
|
+
if (hasPresentChanged) {
|
|
462
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
463
|
+
const currentAnimationName = getAnimationName(styles);
|
|
464
|
+
if (present) send("MOUNT");
|
|
465
|
+
else if ("none" === currentAnimationName || styles?.display === "none") send("UNMOUNT");
|
|
466
|
+
else {
|
|
467
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
468
|
+
wasPresent && isAnimating ? send("ANIMATION_OUT") : send("UNMOUNT");
|
|
469
|
+
}
|
|
470
|
+
prevPresentRef.current = present;
|
|
471
|
+
}
|
|
472
|
+
}, [
|
|
473
|
+
present,
|
|
474
|
+
send
|
|
475
|
+
]);
|
|
476
|
+
(0, react_use_layout_effect_dist.N)(()=>{
|
|
477
|
+
if (node) {
|
|
478
|
+
let timeoutId;
|
|
479
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
480
|
+
const handleAnimationEnd = (event)=>{
|
|
481
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
482
|
+
const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
|
|
483
|
+
if (event.target === node && isCurrentAnimation) {
|
|
484
|
+
send("ANIMATION_END");
|
|
485
|
+
if (!prevPresentRef.current) {
|
|
486
|
+
const currentFillMode = node.style.animationFillMode;
|
|
487
|
+
node.style.animationFillMode = "forwards";
|
|
488
|
+
timeoutId = ownerWindow.setTimeout(()=>{
|
|
489
|
+
if ("forwards" === node.style.animationFillMode) node.style.animationFillMode = currentFillMode;
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
const handleAnimationStart = (event)=>{
|
|
495
|
+
if (event.target === node) prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
496
|
+
};
|
|
497
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
498
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
499
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
500
|
+
return ()=>{
|
|
501
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
502
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
503
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
504
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
send("ANIMATION_END");
|
|
508
|
+
}, [
|
|
509
|
+
node,
|
|
510
|
+
send
|
|
511
|
+
]);
|
|
512
|
+
return {
|
|
513
|
+
isPresent: [
|
|
514
|
+
"mounted",
|
|
515
|
+
"unmountSuspended"
|
|
516
|
+
].includes(state),
|
|
517
|
+
ref: external_react_.useCallback((node2)=>{
|
|
518
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
519
|
+
setNode(node2);
|
|
520
|
+
}, [])
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function getAnimationName(styles) {
|
|
524
|
+
return styles?.animationName || "none";
|
|
525
|
+
}
|
|
526
|
+
function getElementRef(element) {
|
|
527
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
528
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
529
|
+
if (mayWarn) return element.ref;
|
|
530
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
531
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
532
|
+
if (mayWarn) return element.props.ref;
|
|
533
|
+
return element.props.ref || element.ref;
|
|
534
|
+
}
|
|
535
|
+
var react_context_dist = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-context@1.1.2_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-context/dist/index.mjs");
|
|
536
|
+
var react_use_callback_ref_dist = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-use-callback-ref@1.1.1_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs");
|
|
537
|
+
var jsx_runtime_ = __webpack_require__("react/jsx-runtime");
|
|
538
|
+
var DirectionContext = external_react_.createContext(void 0);
|
|
539
|
+
function useDirection(localDir) {
|
|
540
|
+
const globalDir = external_react_.useContext(DirectionContext);
|
|
541
|
+
return localDir || globalDir || "ltr";
|
|
542
|
+
}
|
|
543
|
+
function clamp(value, [min, max]) {
|
|
544
|
+
return Math.min(max, Math.max(min, value));
|
|
545
|
+
}
|
|
546
|
+
"u" > typeof window && window.document && window.document.createElement;
|
|
547
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
548
|
+
return function(event) {
|
|
549
|
+
originalEventHandler?.(event);
|
|
550
|
+
if (false === checkForDefaultPrevented || !event.defaultPrevented) return ourEventHandler?.(event);
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function dist_useStateMachine(initialState, machine) {
|
|
554
|
+
return external_react_.useReducer((state, event)=>{
|
|
555
|
+
const nextState = machine[state][event];
|
|
556
|
+
return nextState ?? state;
|
|
557
|
+
}, initialState);
|
|
558
|
+
}
|
|
559
|
+
var SCROLL_AREA_NAME = "ScrollArea";
|
|
560
|
+
var [createScrollAreaContext, createScrollAreaScope] = (0, react_context_dist.A)(SCROLL_AREA_NAME);
|
|
561
|
+
var [ScrollAreaProvider, useScrollAreaContext] = createScrollAreaContext(SCROLL_AREA_NAME);
|
|
562
|
+
var ScrollArea = external_react_.forwardRef((props, forwardedRef)=>{
|
|
563
|
+
const { __scopeScrollArea, type = "hover", dir, scrollHideDelay = 600, ...scrollAreaProps } = props;
|
|
564
|
+
const [scrollArea, setScrollArea] = external_react_.useState(null);
|
|
565
|
+
const [viewport, setViewport] = external_react_.useState(null);
|
|
566
|
+
const [content, setContent] = external_react_.useState(null);
|
|
567
|
+
const [scrollbarX, setScrollbarX] = external_react_.useState(null);
|
|
568
|
+
const [scrollbarY, setScrollbarY] = external_react_.useState(null);
|
|
569
|
+
const [cornerWidth, setCornerWidth] = external_react_.useState(0);
|
|
570
|
+
const [cornerHeight, setCornerHeight] = external_react_.useState(0);
|
|
571
|
+
const [scrollbarXEnabled, setScrollbarXEnabled] = external_react_.useState(false);
|
|
572
|
+
const [scrollbarYEnabled, setScrollbarYEnabled] = external_react_.useState(false);
|
|
573
|
+
const composedRefs = (0, react_compose_refs_dist.s)(forwardedRef, (node)=>setScrollArea(node));
|
|
574
|
+
const direction = useDirection(dir);
|
|
575
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaProvider, {
|
|
576
|
+
scope: __scopeScrollArea,
|
|
577
|
+
type,
|
|
578
|
+
dir: direction,
|
|
579
|
+
scrollHideDelay,
|
|
580
|
+
scrollArea,
|
|
581
|
+
viewport,
|
|
582
|
+
onViewportChange: setViewport,
|
|
583
|
+
content,
|
|
584
|
+
onContentChange: setContent,
|
|
585
|
+
scrollbarX,
|
|
586
|
+
onScrollbarXChange: setScrollbarX,
|
|
587
|
+
scrollbarXEnabled,
|
|
588
|
+
onScrollbarXEnabledChange: setScrollbarXEnabled,
|
|
589
|
+
scrollbarY,
|
|
590
|
+
onScrollbarYChange: setScrollbarY,
|
|
591
|
+
scrollbarYEnabled,
|
|
592
|
+
onScrollbarYEnabledChange: setScrollbarYEnabled,
|
|
593
|
+
onCornerWidthChange: setCornerWidth,
|
|
594
|
+
onCornerHeightChange: setCornerHeight,
|
|
595
|
+
children: /* @__PURE__ */ (0, jsx_runtime_.jsx)(dist.sG.div, {
|
|
596
|
+
dir: direction,
|
|
597
|
+
...scrollAreaProps,
|
|
598
|
+
ref: composedRefs,
|
|
599
|
+
style: {
|
|
600
|
+
position: "relative",
|
|
601
|
+
["--radix-scroll-area-corner-width"]: cornerWidth + "px",
|
|
602
|
+
["--radix-scroll-area-corner-height"]: cornerHeight + "px",
|
|
603
|
+
...props.style
|
|
604
|
+
}
|
|
605
|
+
})
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
ScrollArea.displayName = SCROLL_AREA_NAME;
|
|
609
|
+
var VIEWPORT_NAME = "ScrollAreaViewport";
|
|
610
|
+
var ScrollAreaViewport = external_react_.forwardRef((props, forwardedRef)=>{
|
|
611
|
+
const { __scopeScrollArea, children, nonce, ...viewportProps } = props;
|
|
612
|
+
const context = useScrollAreaContext(VIEWPORT_NAME, __scopeScrollArea);
|
|
613
|
+
const ref = external_react_.useRef(null);
|
|
614
|
+
const composedRefs = (0, react_compose_refs_dist.s)(forwardedRef, ref, context.onViewportChange);
|
|
615
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsxs)(jsx_runtime_.Fragment, {
|
|
616
|
+
children: [
|
|
617
|
+
/* @__PURE__ */ (0, jsx_runtime_.jsx)("style", {
|
|
618
|
+
dangerouslySetInnerHTML: {
|
|
619
|
+
__html: "[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"
|
|
620
|
+
},
|
|
621
|
+
nonce
|
|
622
|
+
}),
|
|
623
|
+
/* @__PURE__ */ (0, jsx_runtime_.jsx)(dist.sG.div, {
|
|
624
|
+
"data-radix-scroll-area-viewport": "",
|
|
625
|
+
...viewportProps,
|
|
626
|
+
ref: composedRefs,
|
|
627
|
+
style: {
|
|
628
|
+
overflowX: context.scrollbarXEnabled ? "scroll" : "hidden",
|
|
629
|
+
overflowY: context.scrollbarYEnabled ? "scroll" : "hidden",
|
|
630
|
+
...props.style
|
|
631
|
+
},
|
|
632
|
+
children: /* @__PURE__ */ (0, jsx_runtime_.jsx)("div", {
|
|
633
|
+
ref: context.onContentChange,
|
|
634
|
+
style: {
|
|
635
|
+
minWidth: "100%",
|
|
636
|
+
display: "table"
|
|
637
|
+
},
|
|
638
|
+
children
|
|
639
|
+
})
|
|
640
|
+
})
|
|
641
|
+
]
|
|
642
|
+
});
|
|
643
|
+
});
|
|
644
|
+
ScrollAreaViewport.displayName = VIEWPORT_NAME;
|
|
645
|
+
var SCROLLBAR_NAME = "ScrollAreaScrollbar";
|
|
646
|
+
var ScrollAreaScrollbar = external_react_.forwardRef((props, forwardedRef)=>{
|
|
647
|
+
const { forceMount, ...scrollbarProps } = props;
|
|
648
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
649
|
+
const { onScrollbarXEnabledChange, onScrollbarYEnabledChange } = context;
|
|
650
|
+
const isHorizontal = "horizontal" === props.orientation;
|
|
651
|
+
external_react_.useEffect(()=>{
|
|
652
|
+
isHorizontal ? onScrollbarXEnabledChange(true) : onScrollbarYEnabledChange(true);
|
|
653
|
+
return ()=>{
|
|
654
|
+
isHorizontal ? onScrollbarXEnabledChange(false) : onScrollbarYEnabledChange(false);
|
|
655
|
+
};
|
|
656
|
+
}, [
|
|
657
|
+
isHorizontal,
|
|
658
|
+
onScrollbarXEnabledChange,
|
|
659
|
+
onScrollbarYEnabledChange
|
|
660
|
+
]);
|
|
661
|
+
return "hover" === context.type ? /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarHover, {
|
|
662
|
+
...scrollbarProps,
|
|
663
|
+
ref: forwardedRef,
|
|
664
|
+
forceMount
|
|
665
|
+
}) : "scroll" === context.type ? /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarScroll, {
|
|
666
|
+
...scrollbarProps,
|
|
667
|
+
ref: forwardedRef,
|
|
668
|
+
forceMount
|
|
669
|
+
}) : "auto" === context.type ? /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarAuto, {
|
|
670
|
+
...scrollbarProps,
|
|
671
|
+
ref: forwardedRef,
|
|
672
|
+
forceMount
|
|
673
|
+
}) : "always" === context.type ? /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarVisible, {
|
|
674
|
+
...scrollbarProps,
|
|
675
|
+
ref: forwardedRef
|
|
676
|
+
}) : null;
|
|
677
|
+
});
|
|
678
|
+
ScrollAreaScrollbar.displayName = SCROLLBAR_NAME;
|
|
679
|
+
var ScrollAreaScrollbarHover = external_react_.forwardRef((props, forwardedRef)=>{
|
|
680
|
+
const { forceMount, ...scrollbarProps } = props;
|
|
681
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
682
|
+
const [visible, setVisible] = external_react_.useState(false);
|
|
683
|
+
external_react_.useEffect(()=>{
|
|
684
|
+
const scrollArea = context.scrollArea;
|
|
685
|
+
let hideTimer = 0;
|
|
686
|
+
if (scrollArea) {
|
|
687
|
+
const handlePointerEnter = ()=>{
|
|
688
|
+
window.clearTimeout(hideTimer);
|
|
689
|
+
setVisible(true);
|
|
690
|
+
};
|
|
691
|
+
const handlePointerLeave = ()=>{
|
|
692
|
+
hideTimer = window.setTimeout(()=>setVisible(false), context.scrollHideDelay);
|
|
693
|
+
};
|
|
694
|
+
scrollArea.addEventListener("pointerenter", handlePointerEnter);
|
|
695
|
+
scrollArea.addEventListener("pointerleave", handlePointerLeave);
|
|
696
|
+
return ()=>{
|
|
697
|
+
window.clearTimeout(hideTimer);
|
|
698
|
+
scrollArea.removeEventListener("pointerenter", handlePointerEnter);
|
|
699
|
+
scrollArea.removeEventListener("pointerleave", handlePointerLeave);
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
}, [
|
|
703
|
+
context.scrollArea,
|
|
704
|
+
context.scrollHideDelay
|
|
705
|
+
]);
|
|
706
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(Presence, {
|
|
707
|
+
present: forceMount || visible,
|
|
708
|
+
children: /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarAuto, {
|
|
709
|
+
"data-state": visible ? "visible" : "hidden",
|
|
710
|
+
...scrollbarProps,
|
|
711
|
+
ref: forwardedRef
|
|
712
|
+
})
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
var ScrollAreaScrollbarScroll = external_react_.forwardRef((props, forwardedRef)=>{
|
|
716
|
+
const { forceMount, ...scrollbarProps } = props;
|
|
717
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
718
|
+
const isHorizontal = "horizontal" === props.orientation;
|
|
719
|
+
const debounceScrollEnd = useDebounceCallback(()=>send("SCROLL_END"), 100);
|
|
720
|
+
const [state, send] = dist_useStateMachine("hidden", {
|
|
721
|
+
hidden: {
|
|
722
|
+
SCROLL: "scrolling"
|
|
723
|
+
},
|
|
724
|
+
scrolling: {
|
|
725
|
+
SCROLL_END: "idle",
|
|
726
|
+
POINTER_ENTER: "interacting"
|
|
727
|
+
},
|
|
728
|
+
interacting: {
|
|
729
|
+
SCROLL: "interacting",
|
|
730
|
+
POINTER_LEAVE: "idle"
|
|
731
|
+
},
|
|
732
|
+
idle: {
|
|
733
|
+
HIDE: "hidden",
|
|
734
|
+
SCROLL: "scrolling",
|
|
735
|
+
POINTER_ENTER: "interacting"
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
external_react_.useEffect(()=>{
|
|
739
|
+
if ("idle" === state) {
|
|
740
|
+
const hideTimer = window.setTimeout(()=>send("HIDE"), context.scrollHideDelay);
|
|
741
|
+
return ()=>window.clearTimeout(hideTimer);
|
|
742
|
+
}
|
|
743
|
+
}, [
|
|
744
|
+
state,
|
|
745
|
+
context.scrollHideDelay,
|
|
746
|
+
send
|
|
747
|
+
]);
|
|
748
|
+
external_react_.useEffect(()=>{
|
|
749
|
+
const viewport = context.viewport;
|
|
750
|
+
const scrollDirection = isHorizontal ? "scrollLeft" : "scrollTop";
|
|
751
|
+
if (viewport) {
|
|
752
|
+
let prevScrollPos = viewport[scrollDirection];
|
|
753
|
+
const handleScroll = ()=>{
|
|
754
|
+
const scrollPos = viewport[scrollDirection];
|
|
755
|
+
const hasScrollInDirectionChanged = prevScrollPos !== scrollPos;
|
|
756
|
+
if (hasScrollInDirectionChanged) {
|
|
757
|
+
send("SCROLL");
|
|
758
|
+
debounceScrollEnd();
|
|
759
|
+
}
|
|
760
|
+
prevScrollPos = scrollPos;
|
|
761
|
+
};
|
|
762
|
+
viewport.addEventListener("scroll", handleScroll);
|
|
763
|
+
return ()=>viewport.removeEventListener("scroll", handleScroll);
|
|
764
|
+
}
|
|
765
|
+
}, [
|
|
766
|
+
context.viewport,
|
|
767
|
+
isHorizontal,
|
|
768
|
+
send,
|
|
769
|
+
debounceScrollEnd
|
|
770
|
+
]);
|
|
771
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(Presence, {
|
|
772
|
+
present: forceMount || "hidden" !== state,
|
|
773
|
+
children: /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarVisible, {
|
|
774
|
+
"data-state": "hidden" === state ? "hidden" : "visible",
|
|
775
|
+
...scrollbarProps,
|
|
776
|
+
ref: forwardedRef,
|
|
777
|
+
onPointerEnter: composeEventHandlers(props.onPointerEnter, ()=>send("POINTER_ENTER")),
|
|
778
|
+
onPointerLeave: composeEventHandlers(props.onPointerLeave, ()=>send("POINTER_LEAVE"))
|
|
779
|
+
})
|
|
780
|
+
});
|
|
781
|
+
});
|
|
782
|
+
var ScrollAreaScrollbarAuto = external_react_.forwardRef((props, forwardedRef)=>{
|
|
783
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
784
|
+
const { forceMount, ...scrollbarProps } = props;
|
|
785
|
+
const [visible, setVisible] = external_react_.useState(false);
|
|
786
|
+
const isHorizontal = "horizontal" === props.orientation;
|
|
787
|
+
const handleResize = useDebounceCallback(()=>{
|
|
788
|
+
if (context.viewport) {
|
|
789
|
+
const isOverflowX = context.viewport.offsetWidth < context.viewport.scrollWidth;
|
|
790
|
+
const isOverflowY = context.viewport.offsetHeight < context.viewport.scrollHeight;
|
|
791
|
+
setVisible(isHorizontal ? isOverflowX : isOverflowY);
|
|
792
|
+
}
|
|
793
|
+
}, 10);
|
|
794
|
+
useResizeObserver(context.viewport, handleResize);
|
|
795
|
+
useResizeObserver(context.content, handleResize);
|
|
796
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(Presence, {
|
|
797
|
+
present: forceMount || visible,
|
|
798
|
+
children: /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarVisible, {
|
|
799
|
+
"data-state": visible ? "visible" : "hidden",
|
|
800
|
+
...scrollbarProps,
|
|
801
|
+
ref: forwardedRef
|
|
802
|
+
})
|
|
803
|
+
});
|
|
804
|
+
});
|
|
805
|
+
var ScrollAreaScrollbarVisible = external_react_.forwardRef((props, forwardedRef)=>{
|
|
806
|
+
const { orientation = "vertical", ...scrollbarProps } = props;
|
|
807
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
808
|
+
const thumbRef = external_react_.useRef(null);
|
|
809
|
+
const pointerOffsetRef = external_react_.useRef(0);
|
|
810
|
+
const [sizes, setSizes] = external_react_.useState({
|
|
811
|
+
content: 0,
|
|
812
|
+
viewport: 0,
|
|
813
|
+
scrollbar: {
|
|
814
|
+
size: 0,
|
|
815
|
+
paddingStart: 0,
|
|
816
|
+
paddingEnd: 0
|
|
817
|
+
}
|
|
818
|
+
});
|
|
819
|
+
const thumbRatio = getThumbRatio(sizes.viewport, sizes.content);
|
|
820
|
+
const commonProps = {
|
|
821
|
+
...scrollbarProps,
|
|
822
|
+
sizes,
|
|
823
|
+
onSizesChange: setSizes,
|
|
824
|
+
hasThumb: Boolean(thumbRatio > 0 && thumbRatio < 1),
|
|
825
|
+
onThumbChange: (thumb)=>thumbRef.current = thumb,
|
|
826
|
+
onThumbPointerUp: ()=>pointerOffsetRef.current = 0,
|
|
827
|
+
onThumbPointerDown: (pointerPos)=>pointerOffsetRef.current = pointerPos
|
|
828
|
+
};
|
|
829
|
+
function getScrollPosition(pointerPos, dir) {
|
|
830
|
+
return getScrollPositionFromPointer(pointerPos, pointerOffsetRef.current, sizes, dir);
|
|
831
|
+
}
|
|
832
|
+
if ("horizontal" === orientation) return /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarX, {
|
|
833
|
+
...commonProps,
|
|
834
|
+
ref: forwardedRef,
|
|
835
|
+
onThumbPositionChange: ()=>{
|
|
836
|
+
if (context.viewport && thumbRef.current) {
|
|
837
|
+
const scrollPos = context.viewport.scrollLeft;
|
|
838
|
+
const offset = getThumbOffsetFromScroll(scrollPos, sizes, context.dir);
|
|
839
|
+
thumbRef.current.style.transform = `translate3d(${offset}px, 0, 0)`;
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
onWheelScroll: (scrollPos)=>{
|
|
843
|
+
if (context.viewport) context.viewport.scrollLeft = scrollPos;
|
|
844
|
+
},
|
|
845
|
+
onDragScroll: (pointerPos)=>{
|
|
846
|
+
if (context.viewport) context.viewport.scrollLeft = getScrollPosition(pointerPos, context.dir);
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
if ("vertical" === orientation) return /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarY, {
|
|
850
|
+
...commonProps,
|
|
851
|
+
ref: forwardedRef,
|
|
852
|
+
onThumbPositionChange: ()=>{
|
|
853
|
+
if (context.viewport && thumbRef.current) {
|
|
854
|
+
const scrollPos = context.viewport.scrollTop;
|
|
855
|
+
const offset = getThumbOffsetFromScroll(scrollPos, sizes);
|
|
856
|
+
thumbRef.current.style.transform = `translate3d(0, ${offset}px, 0)`;
|
|
857
|
+
}
|
|
858
|
+
},
|
|
859
|
+
onWheelScroll: (scrollPos)=>{
|
|
860
|
+
if (context.viewport) context.viewport.scrollTop = scrollPos;
|
|
861
|
+
},
|
|
862
|
+
onDragScroll: (pointerPos)=>{
|
|
863
|
+
if (context.viewport) context.viewport.scrollTop = getScrollPosition(pointerPos);
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
return null;
|
|
867
|
+
});
|
|
868
|
+
var ScrollAreaScrollbarX = external_react_.forwardRef((props, forwardedRef)=>{
|
|
869
|
+
const { sizes, onSizesChange, ...scrollbarProps } = props;
|
|
870
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
871
|
+
const [computedStyle, setComputedStyle] = external_react_.useState();
|
|
872
|
+
const ref = external_react_.useRef(null);
|
|
873
|
+
const composeRefs = (0, react_compose_refs_dist.s)(forwardedRef, ref, context.onScrollbarXChange);
|
|
874
|
+
external_react_.useEffect(()=>{
|
|
875
|
+
if (ref.current) setComputedStyle(getComputedStyle(ref.current));
|
|
876
|
+
}, [
|
|
877
|
+
ref
|
|
878
|
+
]);
|
|
879
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarImpl, {
|
|
880
|
+
"data-orientation": "horizontal",
|
|
881
|
+
...scrollbarProps,
|
|
882
|
+
ref: composeRefs,
|
|
883
|
+
sizes,
|
|
884
|
+
style: {
|
|
885
|
+
bottom: 0,
|
|
886
|
+
left: "rtl" === context.dir ? "var(--radix-scroll-area-corner-width)" : 0,
|
|
887
|
+
right: "ltr" === context.dir ? "var(--radix-scroll-area-corner-width)" : 0,
|
|
888
|
+
["--radix-scroll-area-thumb-width"]: getThumbSize(sizes) + "px",
|
|
889
|
+
...props.style
|
|
890
|
+
},
|
|
891
|
+
onThumbPointerDown: (pointerPos)=>props.onThumbPointerDown(pointerPos.x),
|
|
892
|
+
onDragScroll: (pointerPos)=>props.onDragScroll(pointerPos.x),
|
|
893
|
+
onWheelScroll: (event, maxScrollPos)=>{
|
|
894
|
+
if (context.viewport) {
|
|
895
|
+
const scrollPos = context.viewport.scrollLeft + event.deltaX;
|
|
896
|
+
props.onWheelScroll(scrollPos);
|
|
897
|
+
if (isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos)) event.preventDefault();
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
onResize: ()=>{
|
|
901
|
+
if (ref.current && context.viewport && computedStyle) onSizesChange({
|
|
902
|
+
content: context.viewport.scrollWidth,
|
|
903
|
+
viewport: context.viewport.offsetWidth,
|
|
904
|
+
scrollbar: {
|
|
905
|
+
size: ref.current.clientWidth,
|
|
906
|
+
paddingStart: toInt(computedStyle.paddingLeft),
|
|
907
|
+
paddingEnd: toInt(computedStyle.paddingRight)
|
|
908
|
+
}
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
});
|
|
913
|
+
var ScrollAreaScrollbarY = external_react_.forwardRef((props, forwardedRef)=>{
|
|
914
|
+
const { sizes, onSizesChange, ...scrollbarProps } = props;
|
|
915
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, props.__scopeScrollArea);
|
|
916
|
+
const [computedStyle, setComputedStyle] = external_react_.useState();
|
|
917
|
+
const ref = external_react_.useRef(null);
|
|
918
|
+
const composeRefs = (0, react_compose_refs_dist.s)(forwardedRef, ref, context.onScrollbarYChange);
|
|
919
|
+
external_react_.useEffect(()=>{
|
|
920
|
+
if (ref.current) setComputedStyle(getComputedStyle(ref.current));
|
|
921
|
+
}, [
|
|
922
|
+
ref
|
|
923
|
+
]);
|
|
924
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaScrollbarImpl, {
|
|
925
|
+
"data-orientation": "vertical",
|
|
926
|
+
...scrollbarProps,
|
|
927
|
+
ref: composeRefs,
|
|
928
|
+
sizes,
|
|
929
|
+
style: {
|
|
930
|
+
top: 0,
|
|
931
|
+
right: "ltr" === context.dir ? 0 : void 0,
|
|
932
|
+
left: "rtl" === context.dir ? 0 : void 0,
|
|
933
|
+
bottom: "var(--radix-scroll-area-corner-height)",
|
|
934
|
+
["--radix-scroll-area-thumb-height"]: getThumbSize(sizes) + "px",
|
|
935
|
+
...props.style
|
|
936
|
+
},
|
|
937
|
+
onThumbPointerDown: (pointerPos)=>props.onThumbPointerDown(pointerPos.y),
|
|
938
|
+
onDragScroll: (pointerPos)=>props.onDragScroll(pointerPos.y),
|
|
939
|
+
onWheelScroll: (event, maxScrollPos)=>{
|
|
940
|
+
if (context.viewport) {
|
|
941
|
+
const scrollPos = context.viewport.scrollTop + event.deltaY;
|
|
942
|
+
props.onWheelScroll(scrollPos);
|
|
943
|
+
if (isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos)) event.preventDefault();
|
|
944
|
+
}
|
|
945
|
+
},
|
|
946
|
+
onResize: ()=>{
|
|
947
|
+
if (ref.current && context.viewport && computedStyle) onSizesChange({
|
|
948
|
+
content: context.viewport.scrollHeight,
|
|
949
|
+
viewport: context.viewport.offsetHeight,
|
|
950
|
+
scrollbar: {
|
|
951
|
+
size: ref.current.clientHeight,
|
|
952
|
+
paddingStart: toInt(computedStyle.paddingTop),
|
|
953
|
+
paddingEnd: toInt(computedStyle.paddingBottom)
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
});
|
|
959
|
+
var [ScrollbarProvider, useScrollbarContext] = createScrollAreaContext(SCROLLBAR_NAME);
|
|
960
|
+
var ScrollAreaScrollbarImpl = external_react_.forwardRef((props, forwardedRef)=>{
|
|
961
|
+
const { __scopeScrollArea, sizes, hasThumb, onThumbChange, onThumbPointerUp, onThumbPointerDown, onThumbPositionChange, onDragScroll, onWheelScroll, onResize, ...scrollbarProps } = props;
|
|
962
|
+
const context = useScrollAreaContext(SCROLLBAR_NAME, __scopeScrollArea);
|
|
963
|
+
const [scrollbar, setScrollbar] = external_react_.useState(null);
|
|
964
|
+
const composeRefs = (0, react_compose_refs_dist.s)(forwardedRef, (node)=>setScrollbar(node));
|
|
965
|
+
const rectRef = external_react_.useRef(null);
|
|
966
|
+
const prevWebkitUserSelectRef = external_react_.useRef("");
|
|
967
|
+
const viewport = context.viewport;
|
|
968
|
+
const maxScrollPos = sizes.content - sizes.viewport;
|
|
969
|
+
const handleWheelScroll = (0, react_use_callback_ref_dist.c)(onWheelScroll);
|
|
970
|
+
const handleThumbPositionChange = (0, react_use_callback_ref_dist.c)(onThumbPositionChange);
|
|
971
|
+
const handleResize = useDebounceCallback(onResize, 10);
|
|
972
|
+
function handleDragScroll(event) {
|
|
973
|
+
if (rectRef.current) {
|
|
974
|
+
const x = event.clientX - rectRef.current.left;
|
|
975
|
+
const y = event.clientY - rectRef.current.top;
|
|
976
|
+
onDragScroll({
|
|
977
|
+
x,
|
|
978
|
+
y
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
external_react_.useEffect(()=>{
|
|
983
|
+
const handleWheel = (event)=>{
|
|
984
|
+
const element = event.target;
|
|
985
|
+
const isScrollbarWheel = scrollbar?.contains(element);
|
|
986
|
+
if (isScrollbarWheel) handleWheelScroll(event, maxScrollPos);
|
|
987
|
+
};
|
|
988
|
+
document.addEventListener("wheel", handleWheel, {
|
|
989
|
+
passive: false
|
|
990
|
+
});
|
|
991
|
+
return ()=>document.removeEventListener("wheel", handleWheel, {
|
|
992
|
+
passive: false
|
|
993
|
+
});
|
|
994
|
+
}, [
|
|
995
|
+
viewport,
|
|
996
|
+
scrollbar,
|
|
997
|
+
maxScrollPos,
|
|
998
|
+
handleWheelScroll
|
|
999
|
+
]);
|
|
1000
|
+
external_react_.useEffect(handleThumbPositionChange, [
|
|
1001
|
+
sizes,
|
|
1002
|
+
handleThumbPositionChange
|
|
1003
|
+
]);
|
|
1004
|
+
useResizeObserver(scrollbar, handleResize);
|
|
1005
|
+
useResizeObserver(context.content, handleResize);
|
|
1006
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollbarProvider, {
|
|
1007
|
+
scope: __scopeScrollArea,
|
|
1008
|
+
scrollbar,
|
|
1009
|
+
hasThumb,
|
|
1010
|
+
onThumbChange: (0, react_use_callback_ref_dist.c)(onThumbChange),
|
|
1011
|
+
onThumbPointerUp: (0, react_use_callback_ref_dist.c)(onThumbPointerUp),
|
|
1012
|
+
onThumbPositionChange: handleThumbPositionChange,
|
|
1013
|
+
onThumbPointerDown: (0, react_use_callback_ref_dist.c)(onThumbPointerDown),
|
|
1014
|
+
children: /* @__PURE__ */ (0, jsx_runtime_.jsx)(dist.sG.div, {
|
|
1015
|
+
...scrollbarProps,
|
|
1016
|
+
ref: composeRefs,
|
|
1017
|
+
style: {
|
|
1018
|
+
position: "absolute",
|
|
1019
|
+
...scrollbarProps.style
|
|
1020
|
+
},
|
|
1021
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, (event)=>{
|
|
1022
|
+
const mainPointer = 0;
|
|
1023
|
+
if (event.button === mainPointer) {
|
|
1024
|
+
const element = event.target;
|
|
1025
|
+
element.setPointerCapture(event.pointerId);
|
|
1026
|
+
rectRef.current = scrollbar.getBoundingClientRect();
|
|
1027
|
+
prevWebkitUserSelectRef.current = document.body.style.webkitUserSelect;
|
|
1028
|
+
document.body.style.webkitUserSelect = "none";
|
|
1029
|
+
if (context.viewport) context.viewport.style.scrollBehavior = "auto";
|
|
1030
|
+
handleDragScroll(event);
|
|
1031
|
+
}
|
|
1032
|
+
}),
|
|
1033
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, handleDragScroll),
|
|
1034
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, (event)=>{
|
|
1035
|
+
const element = event.target;
|
|
1036
|
+
if (element.hasPointerCapture(event.pointerId)) element.releasePointerCapture(event.pointerId);
|
|
1037
|
+
document.body.style.webkitUserSelect = prevWebkitUserSelectRef.current;
|
|
1038
|
+
if (context.viewport) context.viewport.style.scrollBehavior = "";
|
|
1039
|
+
rectRef.current = null;
|
|
1040
|
+
})
|
|
1041
|
+
})
|
|
1042
|
+
});
|
|
1043
|
+
});
|
|
1044
|
+
var THUMB_NAME = "ScrollAreaThumb";
|
|
1045
|
+
var ScrollAreaThumb = external_react_.forwardRef((props, forwardedRef)=>{
|
|
1046
|
+
const { forceMount, ...thumbProps } = props;
|
|
1047
|
+
const scrollbarContext = useScrollbarContext(THUMB_NAME, props.__scopeScrollArea);
|
|
1048
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(Presence, {
|
|
1049
|
+
present: forceMount || scrollbarContext.hasThumb,
|
|
1050
|
+
children: /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaThumbImpl, {
|
|
1051
|
+
ref: forwardedRef,
|
|
1052
|
+
...thumbProps
|
|
1053
|
+
})
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1056
|
+
var ScrollAreaThumbImpl = external_react_.forwardRef((props, forwardedRef)=>{
|
|
1057
|
+
const { __scopeScrollArea, style, ...thumbProps } = props;
|
|
1058
|
+
const scrollAreaContext = useScrollAreaContext(THUMB_NAME, __scopeScrollArea);
|
|
1059
|
+
const scrollbarContext = useScrollbarContext(THUMB_NAME, __scopeScrollArea);
|
|
1060
|
+
const { onThumbPositionChange } = scrollbarContext;
|
|
1061
|
+
const composedRef = (0, react_compose_refs_dist.s)(forwardedRef, (node)=>scrollbarContext.onThumbChange(node));
|
|
1062
|
+
const removeUnlinkedScrollListenerRef = external_react_.useRef(void 0);
|
|
1063
|
+
const debounceScrollEnd = useDebounceCallback(()=>{
|
|
1064
|
+
if (removeUnlinkedScrollListenerRef.current) {
|
|
1065
|
+
removeUnlinkedScrollListenerRef.current();
|
|
1066
|
+
removeUnlinkedScrollListenerRef.current = void 0;
|
|
1067
|
+
}
|
|
1068
|
+
}, 100);
|
|
1069
|
+
external_react_.useEffect(()=>{
|
|
1070
|
+
const viewport = scrollAreaContext.viewport;
|
|
1071
|
+
if (viewport) {
|
|
1072
|
+
const handleScroll = ()=>{
|
|
1073
|
+
debounceScrollEnd();
|
|
1074
|
+
if (!removeUnlinkedScrollListenerRef.current) {
|
|
1075
|
+
const listener = addUnlinkedScrollListener(viewport, onThumbPositionChange);
|
|
1076
|
+
removeUnlinkedScrollListenerRef.current = listener;
|
|
1077
|
+
onThumbPositionChange();
|
|
1078
|
+
}
|
|
1079
|
+
};
|
|
1080
|
+
onThumbPositionChange();
|
|
1081
|
+
viewport.addEventListener("scroll", handleScroll);
|
|
1082
|
+
return ()=>viewport.removeEventListener("scroll", handleScroll);
|
|
1083
|
+
}
|
|
1084
|
+
}, [
|
|
1085
|
+
scrollAreaContext.viewport,
|
|
1086
|
+
debounceScrollEnd,
|
|
1087
|
+
onThumbPositionChange
|
|
1088
|
+
]);
|
|
1089
|
+
return /* @__PURE__ */ (0, jsx_runtime_.jsx)(dist.sG.div, {
|
|
1090
|
+
"data-state": scrollbarContext.hasThumb ? "visible" : "hidden",
|
|
1091
|
+
...thumbProps,
|
|
1092
|
+
ref: composedRef,
|
|
1093
|
+
style: {
|
|
1094
|
+
width: "var(--radix-scroll-area-thumb-width)",
|
|
1095
|
+
height: "var(--radix-scroll-area-thumb-height)",
|
|
1096
|
+
...style
|
|
1097
|
+
},
|
|
1098
|
+
onPointerDownCapture: composeEventHandlers(props.onPointerDownCapture, (event)=>{
|
|
1099
|
+
const thumb = event.target;
|
|
1100
|
+
const thumbRect = thumb.getBoundingClientRect();
|
|
1101
|
+
const x = event.clientX - thumbRect.left;
|
|
1102
|
+
const y = event.clientY - thumbRect.top;
|
|
1103
|
+
scrollbarContext.onThumbPointerDown({
|
|
1104
|
+
x,
|
|
1105
|
+
y
|
|
1106
|
+
});
|
|
1107
|
+
}),
|
|
1108
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, scrollbarContext.onThumbPointerUp)
|
|
1109
|
+
});
|
|
1110
|
+
});
|
|
1111
|
+
ScrollAreaThumb.displayName = THUMB_NAME;
|
|
1112
|
+
var CORNER_NAME = "ScrollAreaCorner";
|
|
1113
|
+
var ScrollAreaCorner = external_react_.forwardRef((props, forwardedRef)=>{
|
|
1114
|
+
const context = useScrollAreaContext(CORNER_NAME, props.__scopeScrollArea);
|
|
1115
|
+
const hasBothScrollbarsVisible = Boolean(context.scrollbarX && context.scrollbarY);
|
|
1116
|
+
const hasCorner = "scroll" !== context.type && hasBothScrollbarsVisible;
|
|
1117
|
+
return hasCorner ? /* @__PURE__ */ (0, jsx_runtime_.jsx)(ScrollAreaCornerImpl, {
|
|
1118
|
+
...props,
|
|
1119
|
+
ref: forwardedRef
|
|
1120
|
+
}) : null;
|
|
1121
|
+
});
|
|
1122
|
+
ScrollAreaCorner.displayName = CORNER_NAME;
|
|
1123
|
+
var ScrollAreaCornerImpl = external_react_.forwardRef((props, forwardedRef)=>{
|
|
1124
|
+
const { __scopeScrollArea, ...cornerProps } = props;
|
|
1125
|
+
const context = useScrollAreaContext(CORNER_NAME, __scopeScrollArea);
|
|
1126
|
+
const [width, setWidth] = external_react_.useState(0);
|
|
1127
|
+
const [height, setHeight] = external_react_.useState(0);
|
|
1128
|
+
const hasSize = Boolean(width && height);
|
|
1129
|
+
useResizeObserver(context.scrollbarX, ()=>{
|
|
1130
|
+
const height2 = context.scrollbarX?.offsetHeight || 0;
|
|
1131
|
+
context.onCornerHeightChange(height2);
|
|
1132
|
+
setHeight(height2);
|
|
1133
|
+
});
|
|
1134
|
+
useResizeObserver(context.scrollbarY, ()=>{
|
|
1135
|
+
const width2 = context.scrollbarY?.offsetWidth || 0;
|
|
1136
|
+
context.onCornerWidthChange(width2);
|
|
1137
|
+
setWidth(width2);
|
|
1138
|
+
});
|
|
1139
|
+
return hasSize ? /* @__PURE__ */ (0, jsx_runtime_.jsx)(dist.sG.div, {
|
|
1140
|
+
...cornerProps,
|
|
1141
|
+
ref: forwardedRef,
|
|
1142
|
+
style: {
|
|
1143
|
+
width,
|
|
1144
|
+
height,
|
|
1145
|
+
position: "absolute",
|
|
1146
|
+
right: "ltr" === context.dir ? 0 : void 0,
|
|
1147
|
+
left: "rtl" === context.dir ? 0 : void 0,
|
|
1148
|
+
bottom: 0,
|
|
1149
|
+
...props.style
|
|
1150
|
+
}
|
|
1151
|
+
}) : null;
|
|
1152
|
+
});
|
|
1153
|
+
function toInt(value) {
|
|
1154
|
+
return value ? parseInt(value, 10) : 0;
|
|
1155
|
+
}
|
|
1156
|
+
function getThumbRatio(viewportSize, contentSize) {
|
|
1157
|
+
const ratio = viewportSize / contentSize;
|
|
1158
|
+
return isNaN(ratio) ? 0 : ratio;
|
|
1159
|
+
}
|
|
1160
|
+
function getThumbSize(sizes) {
|
|
1161
|
+
const ratio = getThumbRatio(sizes.viewport, sizes.content);
|
|
1162
|
+
const scrollbarPadding = sizes.scrollbar.paddingStart + sizes.scrollbar.paddingEnd;
|
|
1163
|
+
const thumbSize = (sizes.scrollbar.size - scrollbarPadding) * ratio;
|
|
1164
|
+
return Math.max(thumbSize, 18);
|
|
1165
|
+
}
|
|
1166
|
+
function getScrollPositionFromPointer(pointerPos, pointerOffset, sizes, dir = "ltr") {
|
|
1167
|
+
const thumbSizePx = getThumbSize(sizes);
|
|
1168
|
+
const thumbCenter = thumbSizePx / 2;
|
|
1169
|
+
const offset = pointerOffset || thumbCenter;
|
|
1170
|
+
const thumbOffsetFromEnd = thumbSizePx - offset;
|
|
1171
|
+
const minPointerPos = sizes.scrollbar.paddingStart + offset;
|
|
1172
|
+
const maxPointerPos = sizes.scrollbar.size - sizes.scrollbar.paddingEnd - thumbOffsetFromEnd;
|
|
1173
|
+
const maxScrollPos = sizes.content - sizes.viewport;
|
|
1174
|
+
const scrollRange = "ltr" === dir ? [
|
|
1175
|
+
0,
|
|
1176
|
+
maxScrollPos
|
|
1177
|
+
] : [
|
|
1178
|
+
-1 * maxScrollPos,
|
|
1179
|
+
0
|
|
1180
|
+
];
|
|
1181
|
+
const interpolate = linearScale([
|
|
1182
|
+
minPointerPos,
|
|
1183
|
+
maxPointerPos
|
|
1184
|
+
], scrollRange);
|
|
1185
|
+
return interpolate(pointerPos);
|
|
1186
|
+
}
|
|
1187
|
+
function getThumbOffsetFromScroll(scrollPos, sizes, dir = "ltr") {
|
|
1188
|
+
const thumbSizePx = getThumbSize(sizes);
|
|
1189
|
+
const scrollbarPadding = sizes.scrollbar.paddingStart + sizes.scrollbar.paddingEnd;
|
|
1190
|
+
const scrollbar = sizes.scrollbar.size - scrollbarPadding;
|
|
1191
|
+
const maxScrollPos = sizes.content - sizes.viewport;
|
|
1192
|
+
const maxThumbPos = scrollbar - thumbSizePx;
|
|
1193
|
+
const scrollClampRange = "ltr" === dir ? [
|
|
1194
|
+
0,
|
|
1195
|
+
maxScrollPos
|
|
1196
|
+
] : [
|
|
1197
|
+
-1 * maxScrollPos,
|
|
1198
|
+
0
|
|
1199
|
+
];
|
|
1200
|
+
const scrollWithoutMomentum = clamp(scrollPos, scrollClampRange);
|
|
1201
|
+
const interpolate = linearScale([
|
|
1202
|
+
0,
|
|
1203
|
+
maxScrollPos
|
|
1204
|
+
], [
|
|
1205
|
+
0,
|
|
1206
|
+
maxThumbPos
|
|
1207
|
+
]);
|
|
1208
|
+
return interpolate(scrollWithoutMomentum);
|
|
1209
|
+
}
|
|
1210
|
+
function linearScale(input, output) {
|
|
1211
|
+
return (value)=>{
|
|
1212
|
+
if (input[0] === input[1] || output[0] === output[1]) return output[0];
|
|
1213
|
+
const ratio = (output[1] - output[0]) / (input[1] - input[0]);
|
|
1214
|
+
return output[0] + ratio * (value - input[0]);
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
function isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos) {
|
|
1218
|
+
return scrollPos > 0 && scrollPos < maxScrollPos;
|
|
1219
|
+
}
|
|
1220
|
+
var addUnlinkedScrollListener = (node, handler = ()=>{})=>{
|
|
1221
|
+
let prevPosition = {
|
|
1222
|
+
left: node.scrollLeft,
|
|
1223
|
+
top: node.scrollTop
|
|
1224
|
+
};
|
|
1225
|
+
let rAF = 0;
|
|
1226
|
+
(function loop() {
|
|
1227
|
+
const position = {
|
|
1228
|
+
left: node.scrollLeft,
|
|
1229
|
+
top: node.scrollTop
|
|
1230
|
+
};
|
|
1231
|
+
const isHorizontalScroll = prevPosition.left !== position.left;
|
|
1232
|
+
const isVerticalScroll = prevPosition.top !== position.top;
|
|
1233
|
+
if (isHorizontalScroll || isVerticalScroll) handler();
|
|
1234
|
+
prevPosition = position;
|
|
1235
|
+
rAF = window.requestAnimationFrame(loop);
|
|
1236
|
+
})();
|
|
1237
|
+
return ()=>window.cancelAnimationFrame(rAF);
|
|
1238
|
+
};
|
|
1239
|
+
function useDebounceCallback(callback, delay) {
|
|
1240
|
+
const handleCallback = (0, react_use_callback_ref_dist.c)(callback);
|
|
1241
|
+
const debounceTimerRef = external_react_.useRef(0);
|
|
1242
|
+
external_react_.useEffect(()=>()=>window.clearTimeout(debounceTimerRef.current), []);
|
|
1243
|
+
return external_react_.useCallback(()=>{
|
|
1244
|
+
window.clearTimeout(debounceTimerRef.current);
|
|
1245
|
+
debounceTimerRef.current = window.setTimeout(handleCallback, delay);
|
|
1246
|
+
}, [
|
|
1247
|
+
handleCallback,
|
|
1248
|
+
delay
|
|
1249
|
+
]);
|
|
1250
|
+
}
|
|
1251
|
+
function useResizeObserver(element, onResize) {
|
|
1252
|
+
const handleResize = (0, react_use_callback_ref_dist.c)(onResize);
|
|
1253
|
+
(0, react_use_layout_effect_dist.N)(()=>{
|
|
1254
|
+
let rAF = 0;
|
|
1255
|
+
if (element) {
|
|
1256
|
+
const resizeObserver = new ResizeObserver(()=>{
|
|
1257
|
+
cancelAnimationFrame(rAF);
|
|
1258
|
+
rAF = window.requestAnimationFrame(handleResize);
|
|
1259
|
+
});
|
|
1260
|
+
resizeObserver.observe(element);
|
|
1261
|
+
return ()=>{
|
|
1262
|
+
window.cancelAnimationFrame(rAF);
|
|
1263
|
+
resizeObserver.unobserve(element);
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
}, [
|
|
1267
|
+
element,
|
|
1268
|
+
handleResize
|
|
1269
|
+
]);
|
|
1270
|
+
}
|
|
1271
|
+
var dist_Root = ScrollArea;
|
|
1272
|
+
var Viewport = ScrollAreaViewport;
|
|
1273
|
+
var Corner = ScrollAreaCorner;
|
|
1274
|
+
},
|
|
1275
|
+
"../../node_modules/.pnpm/@radix-ui+react-slot@1.2.3_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-slot/dist/index.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1276
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1277
|
+
TL: ()=>createSlot,
|
|
1278
|
+
bL: ()=>Slot
|
|
1279
|
+
});
|
|
1280
|
+
var react__rspack_import_0 = __webpack_require__("react");
|
|
1281
|
+
var _radix_ui_react_compose_refs__rspack_import_2 = __webpack_require__("../../node_modules/.pnpm/@radix-ui+react-compose-refs@1.1.2_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-compose-refs/dist/index.mjs");
|
|
1282
|
+
var react_jsx_runtime__rspack_import_1 = __webpack_require__("react/jsx-runtime");
|
|
1283
|
+
function createSlot(ownerName) {
|
|
1284
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
1285
|
+
const Slot2 = react__rspack_import_0.forwardRef((props, forwardedRef)=>{
|
|
1286
|
+
const { children, ...slotProps } = props;
|
|
1287
|
+
const childrenArray = react__rspack_import_0.Children.toArray(children);
|
|
1288
|
+
const slottable = childrenArray.find(isSlottable);
|
|
1289
|
+
if (slottable) {
|
|
1290
|
+
const newElement = slottable.props.children;
|
|
1291
|
+
const newChildren = childrenArray.map((child)=>{
|
|
1292
|
+
if (child !== slottable) return child;
|
|
1293
|
+
if (react__rspack_import_0.Children.count(newElement) > 1) return react__rspack_import_0.Children.only(null);
|
|
1294
|
+
return react__rspack_import_0.isValidElement(newElement) ? newElement.props.children : null;
|
|
1295
|
+
});
|
|
1296
|
+
return /* @__PURE__ */ (0, react_jsx_runtime__rspack_import_1.jsx)(SlotClone, {
|
|
1297
|
+
...slotProps,
|
|
1298
|
+
ref: forwardedRef,
|
|
1299
|
+
children: react__rspack_import_0.isValidElement(newElement) ? react__rspack_import_0.cloneElement(newElement, void 0, newChildren) : null
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
return /* @__PURE__ */ (0, react_jsx_runtime__rspack_import_1.jsx)(SlotClone, {
|
|
1303
|
+
...slotProps,
|
|
1304
|
+
ref: forwardedRef,
|
|
1305
|
+
children
|
|
1306
|
+
});
|
|
1307
|
+
});
|
|
1308
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
1309
|
+
return Slot2;
|
|
1310
|
+
}
|
|
1311
|
+
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
1312
|
+
function createSlotClone(ownerName) {
|
|
1313
|
+
const SlotClone = react__rspack_import_0.forwardRef((props, forwardedRef)=>{
|
|
1314
|
+
const { children, ...slotProps } = props;
|
|
1315
|
+
if (react__rspack_import_0.isValidElement(children)) {
|
|
1316
|
+
const childrenRef = getElementRef(children);
|
|
1317
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
1318
|
+
if (children.type !== react__rspack_import_0.Fragment) props2.ref = forwardedRef ? (0, _radix_ui_react_compose_refs__rspack_import_2.t)(forwardedRef, childrenRef) : childrenRef;
|
|
1319
|
+
return react__rspack_import_0.cloneElement(children, props2);
|
|
1320
|
+
}
|
|
1321
|
+
return react__rspack_import_0.Children.count(children) > 1 ? react__rspack_import_0.Children.only(null) : null;
|
|
1322
|
+
});
|
|
1323
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
1324
|
+
return SlotClone;
|
|
1325
|
+
}
|
|
1326
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
1327
|
+
function isSlottable(child) {
|
|
1328
|
+
return react__rspack_import_0.isValidElement(child) && "function" == typeof child.type && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
1329
|
+
}
|
|
1330
|
+
function mergeProps(slotProps, childProps) {
|
|
1331
|
+
const overrideProps = {
|
|
1332
|
+
...childProps
|
|
1333
|
+
};
|
|
1334
|
+
for(const propName in childProps){
|
|
1335
|
+
const slotPropValue = slotProps[propName];
|
|
1336
|
+
const childPropValue = childProps[propName];
|
|
1337
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
1338
|
+
if (isHandler) {
|
|
1339
|
+
if (slotPropValue && childPropValue) overrideProps[propName] = (...args)=>{
|
|
1340
|
+
const result = childPropValue(...args);
|
|
1341
|
+
slotPropValue(...args);
|
|
1342
|
+
return result;
|
|
1343
|
+
};
|
|
1344
|
+
else if (slotPropValue) overrideProps[propName] = slotPropValue;
|
|
1345
|
+
} else if ("style" === propName) overrideProps[propName] = {
|
|
1346
|
+
...slotPropValue,
|
|
1347
|
+
...childPropValue
|
|
1348
|
+
};
|
|
1349
|
+
else if ("className" === propName) overrideProps[propName] = [
|
|
1350
|
+
slotPropValue,
|
|
1351
|
+
childPropValue
|
|
1352
|
+
].filter(Boolean).join(" ");
|
|
1353
|
+
}
|
|
1354
|
+
return {
|
|
1355
|
+
...slotProps,
|
|
1356
|
+
...overrideProps
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
function getElementRef(element) {
|
|
1360
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
1361
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1362
|
+
if (mayWarn) return element.ref;
|
|
1363
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
1364
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1365
|
+
if (mayWarn) return element.props.ref;
|
|
1366
|
+
return element.props.ref || element.ref;
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
"../../node_modules/.pnpm/@radix-ui+react-use-callback-ref@1.1.1_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-use-callback-ref/dist/index.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1370
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1371
|
+
c: ()=>useCallbackRef
|
|
1372
|
+
});
|
|
1373
|
+
var react__rspack_import_0 = __webpack_require__("react");
|
|
1374
|
+
function useCallbackRef(callback) {
|
|
1375
|
+
const callbackRef = react__rspack_import_0.useRef(callback);
|
|
1376
|
+
react__rspack_import_0.useEffect(()=>{
|
|
1377
|
+
callbackRef.current = callback;
|
|
1378
|
+
});
|
|
1379
|
+
return react__rspack_import_0.useMemo(()=>(...args)=>callbackRef.current?.(...args), []);
|
|
1380
|
+
}
|
|
1381
|
+
},
|
|
1382
|
+
"../../node_modules/.pnpm/@radix-ui+react-use-layout-effect@1.1.1_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1383
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1384
|
+
N: ()=>useLayoutEffect2
|
|
1385
|
+
});
|
|
1386
|
+
var react__rspack_import_0 = __webpack_require__("react");
|
|
1387
|
+
var useLayoutEffect2 = globalThis?.document ? react__rspack_import_0.useLayoutEffect : ()=>{};
|
|
1388
|
+
},
|
|
1389
|
+
"../../node_modules/.pnpm/embla-carousel-react@8.6.0_react@19.2.3/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
1390
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
1391
|
+
A: ()=>useEmblaCarousel
|
|
1392
|
+
});
|
|
1393
|
+
var external_react_ = __webpack_require__("react");
|
|
1394
|
+
function isObject(subject) {
|
|
1395
|
+
return '[object Object]' === Object.prototype.toString.call(subject);
|
|
1396
|
+
}
|
|
1397
|
+
function isRecord(subject) {
|
|
1398
|
+
return isObject(subject) || Array.isArray(subject);
|
|
1399
|
+
}
|
|
1400
|
+
function canUseDOM() {
|
|
1401
|
+
return !!("u" > typeof window && window.document && window.document.createElement);
|
|
1402
|
+
}
|
|
1403
|
+
function areOptionsEqual(optionsA, optionsB) {
|
|
1404
|
+
const optionsAKeys = Object.keys(optionsA);
|
|
1405
|
+
const optionsBKeys = Object.keys(optionsB);
|
|
1406
|
+
if (optionsAKeys.length !== optionsBKeys.length) return false;
|
|
1407
|
+
const breakpointsA = JSON.stringify(Object.keys(optionsA.breakpoints || {}));
|
|
1408
|
+
const breakpointsB = JSON.stringify(Object.keys(optionsB.breakpoints || {}));
|
|
1409
|
+
if (breakpointsA !== breakpointsB) return false;
|
|
1410
|
+
return optionsAKeys.every((key)=>{
|
|
1411
|
+
const valueA = optionsA[key];
|
|
1412
|
+
const valueB = optionsB[key];
|
|
1413
|
+
if ('function' == typeof valueA) return `${valueA}` === `${valueB}`;
|
|
1414
|
+
if (!isRecord(valueA) || !isRecord(valueB)) return valueA === valueB;
|
|
1415
|
+
return areOptionsEqual(valueA, valueB);
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
function sortAndMapPluginToOptions(plugins) {
|
|
1419
|
+
return plugins.concat().sort((a, b)=>a.name > b.name ? 1 : -1).map((plugin)=>plugin.options);
|
|
1420
|
+
}
|
|
1421
|
+
function arePluginsEqual(pluginsA, pluginsB) {
|
|
1422
|
+
if (pluginsA.length !== pluginsB.length) return false;
|
|
1423
|
+
const optionsA = sortAndMapPluginToOptions(pluginsA);
|
|
1424
|
+
const optionsB = sortAndMapPluginToOptions(pluginsB);
|
|
1425
|
+
return optionsA.every((optionA, index)=>{
|
|
1426
|
+
const optionB = optionsB[index];
|
|
1427
|
+
return areOptionsEqual(optionA, optionB);
|
|
1428
|
+
});
|
|
1429
|
+
}
|
|
1430
|
+
function isNumber(subject) {
|
|
1431
|
+
return 'number' == typeof subject;
|
|
1432
|
+
}
|
|
1433
|
+
function isString(subject) {
|
|
1434
|
+
return 'string' == typeof subject;
|
|
1435
|
+
}
|
|
1436
|
+
function isBoolean(subject) {
|
|
1437
|
+
return 'boolean' == typeof subject;
|
|
1438
|
+
}
|
|
1439
|
+
function embla_carousel_esm_isObject(subject) {
|
|
1440
|
+
return '[object Object]' === Object.prototype.toString.call(subject);
|
|
1441
|
+
}
|
|
1442
|
+
function mathAbs(n) {
|
|
1443
|
+
return Math.abs(n);
|
|
1444
|
+
}
|
|
1445
|
+
function mathSign(n) {
|
|
1446
|
+
return Math.sign(n);
|
|
1447
|
+
}
|
|
1448
|
+
function deltaAbs(valueB, valueA) {
|
|
1449
|
+
return mathAbs(valueB - valueA);
|
|
1450
|
+
}
|
|
1451
|
+
function factorAbs(valueB, valueA) {
|
|
1452
|
+
if (0 === valueB || 0 === valueA) return 0;
|
|
1453
|
+
if (mathAbs(valueB) <= mathAbs(valueA)) return 0;
|
|
1454
|
+
const diff = deltaAbs(mathAbs(valueB), mathAbs(valueA));
|
|
1455
|
+
return mathAbs(diff / valueB);
|
|
1456
|
+
}
|
|
1457
|
+
function roundToTwoDecimals(num) {
|
|
1458
|
+
return Math.round(100 * num) / 100;
|
|
1459
|
+
}
|
|
1460
|
+
function arrayKeys(array) {
|
|
1461
|
+
return objectKeys(array).map(Number);
|
|
1462
|
+
}
|
|
1463
|
+
function arrayLast(array) {
|
|
1464
|
+
return array[arrayLastIndex(array)];
|
|
1465
|
+
}
|
|
1466
|
+
function arrayLastIndex(array) {
|
|
1467
|
+
return Math.max(0, array.length - 1);
|
|
1468
|
+
}
|
|
1469
|
+
function arrayIsLastIndex(array, index) {
|
|
1470
|
+
return index === arrayLastIndex(array);
|
|
1471
|
+
}
|
|
1472
|
+
function arrayFromNumber(n, startAt = 0) {
|
|
1473
|
+
return Array.from(Array(n), (_, i)=>startAt + i);
|
|
1474
|
+
}
|
|
1475
|
+
function objectKeys(object) {
|
|
1476
|
+
return Object.keys(object);
|
|
1477
|
+
}
|
|
1478
|
+
function objectsMergeDeep(objectA, objectB) {
|
|
1479
|
+
return [
|
|
1480
|
+
objectA,
|
|
1481
|
+
objectB
|
|
1482
|
+
].reduce((mergedObjects, currentObject)=>{
|
|
1483
|
+
objectKeys(currentObject).forEach((key)=>{
|
|
1484
|
+
const valueA = mergedObjects[key];
|
|
1485
|
+
const valueB = currentObject[key];
|
|
1486
|
+
const areObjects = embla_carousel_esm_isObject(valueA) && embla_carousel_esm_isObject(valueB);
|
|
1487
|
+
mergedObjects[key] = areObjects ? objectsMergeDeep(valueA, valueB) : valueB;
|
|
1488
|
+
});
|
|
1489
|
+
return mergedObjects;
|
|
1490
|
+
}, {});
|
|
1491
|
+
}
|
|
1492
|
+
function isMouseEvent(evt, ownerWindow) {
|
|
1493
|
+
return void 0 !== ownerWindow.MouseEvent && evt instanceof ownerWindow.MouseEvent;
|
|
1494
|
+
}
|
|
1495
|
+
function Alignment(align, viewSize) {
|
|
1496
|
+
const predefined = {
|
|
1497
|
+
start,
|
|
1498
|
+
center,
|
|
1499
|
+
end
|
|
1500
|
+
};
|
|
1501
|
+
function start() {
|
|
1502
|
+
return 0;
|
|
1503
|
+
}
|
|
1504
|
+
function center(n) {
|
|
1505
|
+
return end(n) / 2;
|
|
1506
|
+
}
|
|
1507
|
+
function end(n) {
|
|
1508
|
+
return viewSize - n;
|
|
1509
|
+
}
|
|
1510
|
+
function measure(n, index) {
|
|
1511
|
+
if (isString(align)) return predefined[align](n);
|
|
1512
|
+
return align(viewSize, n, index);
|
|
1513
|
+
}
|
|
1514
|
+
const self = {
|
|
1515
|
+
measure
|
|
1516
|
+
};
|
|
1517
|
+
return self;
|
|
1518
|
+
}
|
|
1519
|
+
function EventStore() {
|
|
1520
|
+
let listeners = [];
|
|
1521
|
+
function add(node, type, handler, options = {
|
|
1522
|
+
passive: true
|
|
1523
|
+
}) {
|
|
1524
|
+
let removeListener;
|
|
1525
|
+
if ('addEventListener' in node) {
|
|
1526
|
+
node.addEventListener(type, handler, options);
|
|
1527
|
+
removeListener = ()=>node.removeEventListener(type, handler, options);
|
|
1528
|
+
} else {
|
|
1529
|
+
const legacyMediaQueryList = node;
|
|
1530
|
+
legacyMediaQueryList.addListener(handler);
|
|
1531
|
+
removeListener = ()=>legacyMediaQueryList.removeListener(handler);
|
|
1532
|
+
}
|
|
1533
|
+
listeners.push(removeListener);
|
|
1534
|
+
return self;
|
|
1535
|
+
}
|
|
1536
|
+
function clear() {
|
|
1537
|
+
listeners = listeners.filter((remove)=>remove());
|
|
1538
|
+
}
|
|
1539
|
+
const self = {
|
|
1540
|
+
add,
|
|
1541
|
+
clear
|
|
1542
|
+
};
|
|
1543
|
+
return self;
|
|
1544
|
+
}
|
|
1545
|
+
function Animations(ownerDocument, ownerWindow, update, render) {
|
|
1546
|
+
const documentVisibleHandler = EventStore();
|
|
1547
|
+
const fixedTimeStep = 1000 / 60;
|
|
1548
|
+
let lastTimeStamp = null;
|
|
1549
|
+
let accumulatedTime = 0;
|
|
1550
|
+
let animationId = 0;
|
|
1551
|
+
function init() {
|
|
1552
|
+
documentVisibleHandler.add(ownerDocument, 'visibilitychange', ()=>{
|
|
1553
|
+
if (ownerDocument.hidden) reset();
|
|
1554
|
+
});
|
|
1555
|
+
}
|
|
1556
|
+
function destroy() {
|
|
1557
|
+
stop();
|
|
1558
|
+
documentVisibleHandler.clear();
|
|
1559
|
+
}
|
|
1560
|
+
function animate(timeStamp) {
|
|
1561
|
+
if (!animationId) return;
|
|
1562
|
+
if (!lastTimeStamp) {
|
|
1563
|
+
lastTimeStamp = timeStamp;
|
|
1564
|
+
update();
|
|
1565
|
+
update();
|
|
1566
|
+
}
|
|
1567
|
+
const timeElapsed = timeStamp - lastTimeStamp;
|
|
1568
|
+
lastTimeStamp = timeStamp;
|
|
1569
|
+
accumulatedTime += timeElapsed;
|
|
1570
|
+
while(accumulatedTime >= fixedTimeStep){
|
|
1571
|
+
update();
|
|
1572
|
+
accumulatedTime -= fixedTimeStep;
|
|
1573
|
+
}
|
|
1574
|
+
const alpha = accumulatedTime / fixedTimeStep;
|
|
1575
|
+
render(alpha);
|
|
1576
|
+
if (animationId) animationId = ownerWindow.requestAnimationFrame(animate);
|
|
1577
|
+
}
|
|
1578
|
+
function start() {
|
|
1579
|
+
if (animationId) return;
|
|
1580
|
+
animationId = ownerWindow.requestAnimationFrame(animate);
|
|
1581
|
+
}
|
|
1582
|
+
function stop() {
|
|
1583
|
+
ownerWindow.cancelAnimationFrame(animationId);
|
|
1584
|
+
lastTimeStamp = null;
|
|
1585
|
+
accumulatedTime = 0;
|
|
1586
|
+
animationId = 0;
|
|
1587
|
+
}
|
|
1588
|
+
function reset() {
|
|
1589
|
+
lastTimeStamp = null;
|
|
1590
|
+
accumulatedTime = 0;
|
|
1591
|
+
}
|
|
1592
|
+
const self = {
|
|
1593
|
+
init,
|
|
1594
|
+
destroy,
|
|
1595
|
+
start,
|
|
1596
|
+
stop,
|
|
1597
|
+
update,
|
|
1598
|
+
render
|
|
1599
|
+
};
|
|
1600
|
+
return self;
|
|
1601
|
+
}
|
|
1602
|
+
function Axis(axis, contentDirection) {
|
|
1603
|
+
const isRightToLeft = 'rtl' === contentDirection;
|
|
1604
|
+
const isVertical = 'y' === axis;
|
|
1605
|
+
const scroll = isVertical ? 'y' : 'x';
|
|
1606
|
+
const cross = isVertical ? 'x' : 'y';
|
|
1607
|
+
const sign = !isVertical && isRightToLeft ? -1 : 1;
|
|
1608
|
+
const startEdge = getStartEdge();
|
|
1609
|
+
const endEdge = getEndEdge();
|
|
1610
|
+
function measureSize(nodeRect) {
|
|
1611
|
+
const { height, width } = nodeRect;
|
|
1612
|
+
return isVertical ? height : width;
|
|
1613
|
+
}
|
|
1614
|
+
function getStartEdge() {
|
|
1615
|
+
if (isVertical) return 'top';
|
|
1616
|
+
return isRightToLeft ? 'right' : 'left';
|
|
1617
|
+
}
|
|
1618
|
+
function getEndEdge() {
|
|
1619
|
+
if (isVertical) return 'bottom';
|
|
1620
|
+
return isRightToLeft ? 'left' : 'right';
|
|
1621
|
+
}
|
|
1622
|
+
function direction(n) {
|
|
1623
|
+
return n * sign;
|
|
1624
|
+
}
|
|
1625
|
+
const self = {
|
|
1626
|
+
scroll,
|
|
1627
|
+
cross,
|
|
1628
|
+
startEdge,
|
|
1629
|
+
endEdge,
|
|
1630
|
+
measureSize,
|
|
1631
|
+
direction
|
|
1632
|
+
};
|
|
1633
|
+
return self;
|
|
1634
|
+
}
|
|
1635
|
+
function Limit(min = 0, max = 0) {
|
|
1636
|
+
const length = mathAbs(min - max);
|
|
1637
|
+
function reachedMin(n) {
|
|
1638
|
+
return n < min;
|
|
1639
|
+
}
|
|
1640
|
+
function reachedMax(n) {
|
|
1641
|
+
return n > max;
|
|
1642
|
+
}
|
|
1643
|
+
function reachedAny(n) {
|
|
1644
|
+
return reachedMin(n) || reachedMax(n);
|
|
1645
|
+
}
|
|
1646
|
+
function constrain(n) {
|
|
1647
|
+
if (!reachedAny(n)) return n;
|
|
1648
|
+
return reachedMin(n) ? min : max;
|
|
1649
|
+
}
|
|
1650
|
+
function removeOffset(n) {
|
|
1651
|
+
if (!length) return n;
|
|
1652
|
+
return n - length * Math.ceil((n - max) / length);
|
|
1653
|
+
}
|
|
1654
|
+
const self = {
|
|
1655
|
+
length,
|
|
1656
|
+
max,
|
|
1657
|
+
min,
|
|
1658
|
+
constrain,
|
|
1659
|
+
reachedAny,
|
|
1660
|
+
reachedMax,
|
|
1661
|
+
reachedMin,
|
|
1662
|
+
removeOffset
|
|
1663
|
+
};
|
|
1664
|
+
return self;
|
|
1665
|
+
}
|
|
1666
|
+
function Counter(max, start, loop) {
|
|
1667
|
+
const { constrain } = Limit(0, max);
|
|
1668
|
+
const loopEnd = max + 1;
|
|
1669
|
+
let counter = withinLimit(start);
|
|
1670
|
+
function withinLimit(n) {
|
|
1671
|
+
return loop ? mathAbs((loopEnd + n) % loopEnd) : constrain(n);
|
|
1672
|
+
}
|
|
1673
|
+
function get() {
|
|
1674
|
+
return counter;
|
|
1675
|
+
}
|
|
1676
|
+
function set(n) {
|
|
1677
|
+
counter = withinLimit(n);
|
|
1678
|
+
return self;
|
|
1679
|
+
}
|
|
1680
|
+
function add(n) {
|
|
1681
|
+
return clone().set(get() + n);
|
|
1682
|
+
}
|
|
1683
|
+
function clone() {
|
|
1684
|
+
return Counter(max, get(), loop);
|
|
1685
|
+
}
|
|
1686
|
+
const self = {
|
|
1687
|
+
get,
|
|
1688
|
+
set,
|
|
1689
|
+
add,
|
|
1690
|
+
clone
|
|
1691
|
+
};
|
|
1692
|
+
return self;
|
|
1693
|
+
}
|
|
1694
|
+
function DragHandler(axis, rootNode, ownerDocument, ownerWindow, target, dragTracker, location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, baseFriction, watchDrag) {
|
|
1695
|
+
const { cross: crossAxis, direction } = axis;
|
|
1696
|
+
const focusNodes = [
|
|
1697
|
+
'INPUT',
|
|
1698
|
+
'SELECT',
|
|
1699
|
+
'TEXTAREA'
|
|
1700
|
+
];
|
|
1701
|
+
const nonPassiveEvent = {
|
|
1702
|
+
passive: false
|
|
1703
|
+
};
|
|
1704
|
+
const initEvents = EventStore();
|
|
1705
|
+
const dragEvents = EventStore();
|
|
1706
|
+
const goToNextThreshold = Limit(50, 225).constrain(percentOfView.measure(20));
|
|
1707
|
+
const snapForceBoost = {
|
|
1708
|
+
mouse: 300,
|
|
1709
|
+
touch: 400
|
|
1710
|
+
};
|
|
1711
|
+
const freeForceBoost = {
|
|
1712
|
+
mouse: 500,
|
|
1713
|
+
touch: 600
|
|
1714
|
+
};
|
|
1715
|
+
const baseSpeed = dragFree ? 43 : 25;
|
|
1716
|
+
let isMoving = false;
|
|
1717
|
+
let startScroll = 0;
|
|
1718
|
+
let startCross = 0;
|
|
1719
|
+
let pointerIsDown = false;
|
|
1720
|
+
let preventScroll = false;
|
|
1721
|
+
let preventClick = false;
|
|
1722
|
+
let isMouse = false;
|
|
1723
|
+
function init(emblaApi) {
|
|
1724
|
+
if (!watchDrag) return;
|
|
1725
|
+
function downIfAllowed(evt) {
|
|
1726
|
+
if (isBoolean(watchDrag) || watchDrag(emblaApi, evt)) down(evt);
|
|
1727
|
+
}
|
|
1728
|
+
const node = rootNode;
|
|
1729
|
+
initEvents.add(node, 'dragstart', (evt)=>evt.preventDefault(), nonPassiveEvent).add(node, 'touchmove', ()=>void 0, nonPassiveEvent).add(node, 'touchend', ()=>void 0).add(node, 'touchstart', downIfAllowed).add(node, 'mousedown', downIfAllowed).add(node, 'touchcancel', up).add(node, 'contextmenu', up).add(node, 'click', click, true);
|
|
1730
|
+
}
|
|
1731
|
+
function destroy() {
|
|
1732
|
+
initEvents.clear();
|
|
1733
|
+
dragEvents.clear();
|
|
1734
|
+
}
|
|
1735
|
+
function addDragEvents() {
|
|
1736
|
+
const node = isMouse ? ownerDocument : rootNode;
|
|
1737
|
+
dragEvents.add(node, 'touchmove', move, nonPassiveEvent).add(node, 'touchend', up).add(node, 'mousemove', move, nonPassiveEvent).add(node, 'mouseup', up);
|
|
1738
|
+
}
|
|
1739
|
+
function isFocusNode(node) {
|
|
1740
|
+
const nodeName = node.nodeName || '';
|
|
1741
|
+
return focusNodes.includes(nodeName);
|
|
1742
|
+
}
|
|
1743
|
+
function forceBoost() {
|
|
1744
|
+
const boost = dragFree ? freeForceBoost : snapForceBoost;
|
|
1745
|
+
const type = isMouse ? 'mouse' : 'touch';
|
|
1746
|
+
return boost[type];
|
|
1747
|
+
}
|
|
1748
|
+
function allowedForce(force, targetChanged) {
|
|
1749
|
+
const next = index.add(-1 * mathSign(force));
|
|
1750
|
+
const baseForce = scrollTarget.byDistance(force, !dragFree).distance;
|
|
1751
|
+
if (dragFree || mathAbs(force) < goToNextThreshold) return baseForce;
|
|
1752
|
+
if (skipSnaps && targetChanged) return 0.5 * baseForce;
|
|
1753
|
+
return scrollTarget.byIndex(next.get(), 0).distance;
|
|
1754
|
+
}
|
|
1755
|
+
function down(evt) {
|
|
1756
|
+
const isMouseEvt = isMouseEvent(evt, ownerWindow);
|
|
1757
|
+
isMouse = isMouseEvt;
|
|
1758
|
+
preventClick = dragFree && isMouseEvt && !evt.buttons && isMoving;
|
|
1759
|
+
isMoving = deltaAbs(target.get(), location.get()) >= 2;
|
|
1760
|
+
if (isMouseEvt && 0 !== evt.button) return;
|
|
1761
|
+
if (isFocusNode(evt.target)) return;
|
|
1762
|
+
pointerIsDown = true;
|
|
1763
|
+
dragTracker.pointerDown(evt);
|
|
1764
|
+
scrollBody.useFriction(0).useDuration(0);
|
|
1765
|
+
target.set(location);
|
|
1766
|
+
addDragEvents();
|
|
1767
|
+
startScroll = dragTracker.readPoint(evt);
|
|
1768
|
+
startCross = dragTracker.readPoint(evt, crossAxis);
|
|
1769
|
+
eventHandler.emit('pointerDown');
|
|
1770
|
+
}
|
|
1771
|
+
function move(evt) {
|
|
1772
|
+
const isTouchEvt = !isMouseEvent(evt, ownerWindow);
|
|
1773
|
+
if (isTouchEvt && evt.touches.length >= 2) return up(evt);
|
|
1774
|
+
const lastScroll = dragTracker.readPoint(evt);
|
|
1775
|
+
const lastCross = dragTracker.readPoint(evt, crossAxis);
|
|
1776
|
+
const diffScroll = deltaAbs(lastScroll, startScroll);
|
|
1777
|
+
const diffCross = deltaAbs(lastCross, startCross);
|
|
1778
|
+
if (!preventScroll && !isMouse) {
|
|
1779
|
+
if (!evt.cancelable) return up(evt);
|
|
1780
|
+
preventScroll = diffScroll > diffCross;
|
|
1781
|
+
if (!preventScroll) return up(evt);
|
|
1782
|
+
}
|
|
1783
|
+
const diff = dragTracker.pointerMove(evt);
|
|
1784
|
+
if (diffScroll > dragThreshold) preventClick = true;
|
|
1785
|
+
scrollBody.useFriction(0.3).useDuration(0.75);
|
|
1786
|
+
animation.start();
|
|
1787
|
+
target.add(direction(diff));
|
|
1788
|
+
evt.preventDefault();
|
|
1789
|
+
}
|
|
1790
|
+
function up(evt) {
|
|
1791
|
+
const currentLocation = scrollTarget.byDistance(0, false);
|
|
1792
|
+
const targetChanged = currentLocation.index !== index.get();
|
|
1793
|
+
const rawForce = dragTracker.pointerUp(evt) * forceBoost();
|
|
1794
|
+
const force = allowedForce(direction(rawForce), targetChanged);
|
|
1795
|
+
const forceFactor = factorAbs(rawForce, force);
|
|
1796
|
+
const speed = baseSpeed - 10 * forceFactor;
|
|
1797
|
+
const friction = baseFriction + forceFactor / 50;
|
|
1798
|
+
preventScroll = false;
|
|
1799
|
+
pointerIsDown = false;
|
|
1800
|
+
dragEvents.clear();
|
|
1801
|
+
scrollBody.useDuration(speed).useFriction(friction);
|
|
1802
|
+
scrollTo.distance(force, !dragFree);
|
|
1803
|
+
isMouse = false;
|
|
1804
|
+
eventHandler.emit('pointerUp');
|
|
1805
|
+
}
|
|
1806
|
+
function click(evt) {
|
|
1807
|
+
if (preventClick) {
|
|
1808
|
+
evt.stopPropagation();
|
|
1809
|
+
evt.preventDefault();
|
|
1810
|
+
preventClick = false;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
function pointerDown() {
|
|
1814
|
+
return pointerIsDown;
|
|
1815
|
+
}
|
|
1816
|
+
const self = {
|
|
1817
|
+
init,
|
|
1818
|
+
destroy,
|
|
1819
|
+
pointerDown
|
|
1820
|
+
};
|
|
1821
|
+
return self;
|
|
1822
|
+
}
|
|
1823
|
+
function DragTracker(axis, ownerWindow) {
|
|
1824
|
+
const logInterval = 170;
|
|
1825
|
+
let startEvent;
|
|
1826
|
+
let lastEvent;
|
|
1827
|
+
function readTime(evt) {
|
|
1828
|
+
return evt.timeStamp;
|
|
1829
|
+
}
|
|
1830
|
+
function readPoint(evt, evtAxis) {
|
|
1831
|
+
const property = evtAxis || axis.scroll;
|
|
1832
|
+
const coord = `client${'x' === property ? 'X' : 'Y'}`;
|
|
1833
|
+
return (isMouseEvent(evt, ownerWindow) ? evt : evt.touches[0])[coord];
|
|
1834
|
+
}
|
|
1835
|
+
function pointerDown(evt) {
|
|
1836
|
+
startEvent = evt;
|
|
1837
|
+
lastEvent = evt;
|
|
1838
|
+
return readPoint(evt);
|
|
1839
|
+
}
|
|
1840
|
+
function pointerMove(evt) {
|
|
1841
|
+
const diff = readPoint(evt) - readPoint(lastEvent);
|
|
1842
|
+
const expired = readTime(evt) - readTime(startEvent) > logInterval;
|
|
1843
|
+
lastEvent = evt;
|
|
1844
|
+
if (expired) startEvent = evt;
|
|
1845
|
+
return diff;
|
|
1846
|
+
}
|
|
1847
|
+
function pointerUp(evt) {
|
|
1848
|
+
if (!startEvent || !lastEvent) return 0;
|
|
1849
|
+
const diffDrag = readPoint(lastEvent) - readPoint(startEvent);
|
|
1850
|
+
const diffTime = readTime(evt) - readTime(startEvent);
|
|
1851
|
+
const expired = readTime(evt) - readTime(lastEvent) > logInterval;
|
|
1852
|
+
const force = diffDrag / diffTime;
|
|
1853
|
+
const isFlick = diffTime && !expired && mathAbs(force) > 0.1;
|
|
1854
|
+
return isFlick ? force : 0;
|
|
1855
|
+
}
|
|
1856
|
+
const self = {
|
|
1857
|
+
pointerDown,
|
|
1858
|
+
pointerMove,
|
|
1859
|
+
pointerUp,
|
|
1860
|
+
readPoint
|
|
1861
|
+
};
|
|
1862
|
+
return self;
|
|
1863
|
+
}
|
|
1864
|
+
function NodeRects() {
|
|
1865
|
+
function measure(node) {
|
|
1866
|
+
const { offsetTop, offsetLeft, offsetWidth, offsetHeight } = node;
|
|
1867
|
+
const offset = {
|
|
1868
|
+
top: offsetTop,
|
|
1869
|
+
right: offsetLeft + offsetWidth,
|
|
1870
|
+
bottom: offsetTop + offsetHeight,
|
|
1871
|
+
left: offsetLeft,
|
|
1872
|
+
width: offsetWidth,
|
|
1873
|
+
height: offsetHeight
|
|
1874
|
+
};
|
|
1875
|
+
return offset;
|
|
1876
|
+
}
|
|
1877
|
+
const self = {
|
|
1878
|
+
measure
|
|
1879
|
+
};
|
|
1880
|
+
return self;
|
|
1881
|
+
}
|
|
1882
|
+
function PercentOfView(viewSize) {
|
|
1883
|
+
function measure(n) {
|
|
1884
|
+
return n / 100 * viewSize;
|
|
1885
|
+
}
|
|
1886
|
+
const self = {
|
|
1887
|
+
measure
|
|
1888
|
+
};
|
|
1889
|
+
return self;
|
|
1890
|
+
}
|
|
1891
|
+
function ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects) {
|
|
1892
|
+
const observeNodes = [
|
|
1893
|
+
container
|
|
1894
|
+
].concat(slides);
|
|
1895
|
+
let resizeObserver;
|
|
1896
|
+
let containerSize;
|
|
1897
|
+
let slideSizes = [];
|
|
1898
|
+
let destroyed = false;
|
|
1899
|
+
function readSize(node) {
|
|
1900
|
+
return axis.measureSize(nodeRects.measure(node));
|
|
1901
|
+
}
|
|
1902
|
+
function init(emblaApi) {
|
|
1903
|
+
if (!watchResize) return;
|
|
1904
|
+
containerSize = readSize(container);
|
|
1905
|
+
slideSizes = slides.map(readSize);
|
|
1906
|
+
function defaultCallback(entries) {
|
|
1907
|
+
for (const entry of entries){
|
|
1908
|
+
if (destroyed) return;
|
|
1909
|
+
const isContainer = entry.target === container;
|
|
1910
|
+
const slideIndex = slides.indexOf(entry.target);
|
|
1911
|
+
const lastSize = isContainer ? containerSize : slideSizes[slideIndex];
|
|
1912
|
+
const newSize = readSize(isContainer ? container : slides[slideIndex]);
|
|
1913
|
+
const diffSize = mathAbs(newSize - lastSize);
|
|
1914
|
+
if (diffSize >= 0.5) {
|
|
1915
|
+
emblaApi.reInit();
|
|
1916
|
+
eventHandler.emit('resize');
|
|
1917
|
+
break;
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
resizeObserver = new ResizeObserver((entries)=>{
|
|
1922
|
+
if (isBoolean(watchResize) || watchResize(emblaApi, entries)) defaultCallback(entries);
|
|
1923
|
+
});
|
|
1924
|
+
ownerWindow.requestAnimationFrame(()=>{
|
|
1925
|
+
observeNodes.forEach((node)=>resizeObserver.observe(node));
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
function destroy() {
|
|
1929
|
+
destroyed = true;
|
|
1930
|
+
if (resizeObserver) resizeObserver.disconnect();
|
|
1931
|
+
}
|
|
1932
|
+
const self = {
|
|
1933
|
+
init,
|
|
1934
|
+
destroy
|
|
1935
|
+
};
|
|
1936
|
+
return self;
|
|
1937
|
+
}
|
|
1938
|
+
function ScrollBody(location, offsetLocation, previousLocation, target, baseDuration, baseFriction) {
|
|
1939
|
+
let scrollVelocity = 0;
|
|
1940
|
+
let scrollDirection = 0;
|
|
1941
|
+
let scrollDuration = baseDuration;
|
|
1942
|
+
let scrollFriction = baseFriction;
|
|
1943
|
+
let rawLocation = location.get();
|
|
1944
|
+
let rawLocationPrevious = 0;
|
|
1945
|
+
function seek() {
|
|
1946
|
+
const displacement = target.get() - location.get();
|
|
1947
|
+
const isInstant = !scrollDuration;
|
|
1948
|
+
let scrollDistance = 0;
|
|
1949
|
+
if (isInstant) {
|
|
1950
|
+
scrollVelocity = 0;
|
|
1951
|
+
previousLocation.set(target);
|
|
1952
|
+
location.set(target);
|
|
1953
|
+
scrollDistance = displacement;
|
|
1954
|
+
} else {
|
|
1955
|
+
previousLocation.set(location);
|
|
1956
|
+
scrollVelocity += displacement / scrollDuration;
|
|
1957
|
+
scrollVelocity *= scrollFriction;
|
|
1958
|
+
rawLocation += scrollVelocity;
|
|
1959
|
+
location.add(scrollVelocity);
|
|
1960
|
+
scrollDistance = rawLocation - rawLocationPrevious;
|
|
1961
|
+
}
|
|
1962
|
+
scrollDirection = mathSign(scrollDistance);
|
|
1963
|
+
rawLocationPrevious = rawLocation;
|
|
1964
|
+
return self;
|
|
1965
|
+
}
|
|
1966
|
+
function settled() {
|
|
1967
|
+
const diff = target.get() - offsetLocation.get();
|
|
1968
|
+
return mathAbs(diff) < 0.001;
|
|
1969
|
+
}
|
|
1970
|
+
function duration() {
|
|
1971
|
+
return scrollDuration;
|
|
1972
|
+
}
|
|
1973
|
+
function direction() {
|
|
1974
|
+
return scrollDirection;
|
|
1975
|
+
}
|
|
1976
|
+
function velocity() {
|
|
1977
|
+
return scrollVelocity;
|
|
1978
|
+
}
|
|
1979
|
+
function useBaseDuration() {
|
|
1980
|
+
return useDuration(baseDuration);
|
|
1981
|
+
}
|
|
1982
|
+
function useBaseFriction() {
|
|
1983
|
+
return useFriction(baseFriction);
|
|
1984
|
+
}
|
|
1985
|
+
function useDuration(n) {
|
|
1986
|
+
scrollDuration = n;
|
|
1987
|
+
return self;
|
|
1988
|
+
}
|
|
1989
|
+
function useFriction(n) {
|
|
1990
|
+
scrollFriction = n;
|
|
1991
|
+
return self;
|
|
1992
|
+
}
|
|
1993
|
+
const self = {
|
|
1994
|
+
direction,
|
|
1995
|
+
duration,
|
|
1996
|
+
velocity,
|
|
1997
|
+
seek,
|
|
1998
|
+
settled,
|
|
1999
|
+
useBaseFriction,
|
|
2000
|
+
useBaseDuration,
|
|
2001
|
+
useFriction,
|
|
2002
|
+
useDuration
|
|
2003
|
+
};
|
|
2004
|
+
return self;
|
|
2005
|
+
}
|
|
2006
|
+
function ScrollBounds(limit, location, target, scrollBody, percentOfView) {
|
|
2007
|
+
const pullBackThreshold = percentOfView.measure(10);
|
|
2008
|
+
const edgeOffsetTolerance = percentOfView.measure(50);
|
|
2009
|
+
const frictionLimit = Limit(0.1, 0.99);
|
|
2010
|
+
let disabled = false;
|
|
2011
|
+
function shouldConstrain() {
|
|
2012
|
+
if (disabled) return false;
|
|
2013
|
+
if (!limit.reachedAny(target.get())) return false;
|
|
2014
|
+
if (!limit.reachedAny(location.get())) return false;
|
|
2015
|
+
return true;
|
|
2016
|
+
}
|
|
2017
|
+
function constrain(pointerDown) {
|
|
2018
|
+
if (!shouldConstrain()) return;
|
|
2019
|
+
const edge = limit.reachedMin(location.get()) ? 'min' : 'max';
|
|
2020
|
+
const diffToEdge = mathAbs(limit[edge] - location.get());
|
|
2021
|
+
const diffToTarget = target.get() - location.get();
|
|
2022
|
+
const friction = frictionLimit.constrain(diffToEdge / edgeOffsetTolerance);
|
|
2023
|
+
target.subtract(diffToTarget * friction);
|
|
2024
|
+
if (!pointerDown && mathAbs(diffToTarget) < pullBackThreshold) {
|
|
2025
|
+
target.set(limit.constrain(target.get()));
|
|
2026
|
+
scrollBody.useDuration(25).useBaseFriction();
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
function toggleActive(active) {
|
|
2030
|
+
disabled = !active;
|
|
2031
|
+
}
|
|
2032
|
+
const self = {
|
|
2033
|
+
shouldConstrain,
|
|
2034
|
+
constrain,
|
|
2035
|
+
toggleActive
|
|
2036
|
+
};
|
|
2037
|
+
return self;
|
|
2038
|
+
}
|
|
2039
|
+
function ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance) {
|
|
2040
|
+
const scrollBounds = Limit(-contentSize + viewSize, 0);
|
|
2041
|
+
const snapsBounded = measureBounded();
|
|
2042
|
+
const scrollContainLimit = findScrollContainLimit();
|
|
2043
|
+
const snapsContained = measureContained();
|
|
2044
|
+
function usePixelTolerance(bound, snap) {
|
|
2045
|
+
return deltaAbs(bound, snap) <= 1;
|
|
2046
|
+
}
|
|
2047
|
+
function findScrollContainLimit() {
|
|
2048
|
+
const startSnap = snapsBounded[0];
|
|
2049
|
+
const endSnap = arrayLast(snapsBounded);
|
|
2050
|
+
const min = snapsBounded.lastIndexOf(startSnap);
|
|
2051
|
+
const max = snapsBounded.indexOf(endSnap) + 1;
|
|
2052
|
+
return Limit(min, max);
|
|
2053
|
+
}
|
|
2054
|
+
function measureBounded() {
|
|
2055
|
+
return snapsAligned.map((snapAligned, index)=>{
|
|
2056
|
+
const { min, max } = scrollBounds;
|
|
2057
|
+
const snap = scrollBounds.constrain(snapAligned);
|
|
2058
|
+
const isFirst = !index;
|
|
2059
|
+
const isLast = arrayIsLastIndex(snapsAligned, index);
|
|
2060
|
+
if (isFirst) return max;
|
|
2061
|
+
if (isLast) return min;
|
|
2062
|
+
if (usePixelTolerance(min, snap)) return min;
|
|
2063
|
+
if (usePixelTolerance(max, snap)) return max;
|
|
2064
|
+
return snap;
|
|
2065
|
+
}).map((scrollBound)=>parseFloat(scrollBound.toFixed(3)));
|
|
2066
|
+
}
|
|
2067
|
+
function measureContained() {
|
|
2068
|
+
if (contentSize <= viewSize + pixelTolerance) return [
|
|
2069
|
+
scrollBounds.max
|
|
2070
|
+
];
|
|
2071
|
+
if ('keepSnaps' === containScroll) return snapsBounded;
|
|
2072
|
+
const { min, max } = scrollContainLimit;
|
|
2073
|
+
return snapsBounded.slice(min, max);
|
|
2074
|
+
}
|
|
2075
|
+
const self = {
|
|
2076
|
+
snapsContained,
|
|
2077
|
+
scrollContainLimit
|
|
2078
|
+
};
|
|
2079
|
+
return self;
|
|
2080
|
+
}
|
|
2081
|
+
function ScrollLimit(contentSize, scrollSnaps, loop) {
|
|
2082
|
+
const max = scrollSnaps[0];
|
|
2083
|
+
const min = loop ? max - contentSize : arrayLast(scrollSnaps);
|
|
2084
|
+
const limit = Limit(min, max);
|
|
2085
|
+
const self = {
|
|
2086
|
+
limit
|
|
2087
|
+
};
|
|
2088
|
+
return self;
|
|
2089
|
+
}
|
|
2090
|
+
function ScrollLooper(contentSize, limit, location, vectors) {
|
|
2091
|
+
const jointSafety = 0.1;
|
|
2092
|
+
const min = limit.min + jointSafety;
|
|
2093
|
+
const max = limit.max + jointSafety;
|
|
2094
|
+
const { reachedMin, reachedMax } = Limit(min, max);
|
|
2095
|
+
function shouldLoop(direction) {
|
|
2096
|
+
if (1 === direction) return reachedMax(location.get());
|
|
2097
|
+
if (-1 === direction) return reachedMin(location.get());
|
|
2098
|
+
return false;
|
|
2099
|
+
}
|
|
2100
|
+
function loop(direction) {
|
|
2101
|
+
if (!shouldLoop(direction)) return;
|
|
2102
|
+
const loopDistance = -1 * direction * contentSize;
|
|
2103
|
+
vectors.forEach((v)=>v.add(loopDistance));
|
|
2104
|
+
}
|
|
2105
|
+
const self = {
|
|
2106
|
+
loop
|
|
2107
|
+
};
|
|
2108
|
+
return self;
|
|
2109
|
+
}
|
|
2110
|
+
function ScrollProgress(limit) {
|
|
2111
|
+
const { max, length } = limit;
|
|
2112
|
+
function get(n) {
|
|
2113
|
+
const currentLocation = n - max;
|
|
2114
|
+
return length ? currentLocation / -length : 0;
|
|
2115
|
+
}
|
|
2116
|
+
const self = {
|
|
2117
|
+
get
|
|
2118
|
+
};
|
|
2119
|
+
return self;
|
|
2120
|
+
}
|
|
2121
|
+
function ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll) {
|
|
2122
|
+
const { startEdge, endEdge } = axis;
|
|
2123
|
+
const { groupSlides } = slidesToScroll;
|
|
2124
|
+
const alignments = measureSizes().map(alignment.measure);
|
|
2125
|
+
const snaps = measureUnaligned();
|
|
2126
|
+
const snapsAligned = measureAligned();
|
|
2127
|
+
function measureSizes() {
|
|
2128
|
+
return groupSlides(slideRects).map((rects)=>arrayLast(rects)[endEdge] - rects[0][startEdge]).map(mathAbs);
|
|
2129
|
+
}
|
|
2130
|
+
function measureUnaligned() {
|
|
2131
|
+
return slideRects.map((rect)=>containerRect[startEdge] - rect[startEdge]).map((snap)=>-mathAbs(snap));
|
|
2132
|
+
}
|
|
2133
|
+
function measureAligned() {
|
|
2134
|
+
return groupSlides(snaps).map((g)=>g[0]).map((snap, index)=>snap + alignments[index]);
|
|
2135
|
+
}
|
|
2136
|
+
const self = {
|
|
2137
|
+
snaps,
|
|
2138
|
+
snapsAligned
|
|
2139
|
+
};
|
|
2140
|
+
return self;
|
|
2141
|
+
}
|
|
2142
|
+
function SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes) {
|
|
2143
|
+
const { groupSlides } = slidesToScroll;
|
|
2144
|
+
const { min, max } = scrollContainLimit;
|
|
2145
|
+
const slideRegistry = createSlideRegistry();
|
|
2146
|
+
function createSlideRegistry() {
|
|
2147
|
+
const groupedSlideIndexes = groupSlides(slideIndexes);
|
|
2148
|
+
const doNotContain = !containSnaps || 'keepSnaps' === containScroll;
|
|
2149
|
+
if (1 === scrollSnaps.length) return [
|
|
2150
|
+
slideIndexes
|
|
2151
|
+
];
|
|
2152
|
+
if (doNotContain) return groupedSlideIndexes;
|
|
2153
|
+
return groupedSlideIndexes.slice(min, max).map((group, index, groups)=>{
|
|
2154
|
+
const isFirst = !index;
|
|
2155
|
+
const isLast = arrayIsLastIndex(groups, index);
|
|
2156
|
+
if (isFirst) {
|
|
2157
|
+
const range = arrayLast(groups[0]) + 1;
|
|
2158
|
+
return arrayFromNumber(range);
|
|
2159
|
+
}
|
|
2160
|
+
if (isLast) {
|
|
2161
|
+
const range = arrayLastIndex(slideIndexes) - arrayLast(groups)[0] + 1;
|
|
2162
|
+
return arrayFromNumber(range, arrayLast(groups)[0]);
|
|
2163
|
+
}
|
|
2164
|
+
return group;
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
const self = {
|
|
2168
|
+
slideRegistry
|
|
2169
|
+
};
|
|
2170
|
+
return self;
|
|
2171
|
+
}
|
|
2172
|
+
function ScrollTarget(loop, scrollSnaps, contentSize, limit, targetVector) {
|
|
2173
|
+
const { reachedAny, removeOffset, constrain } = limit;
|
|
2174
|
+
function minDistance(distances) {
|
|
2175
|
+
return distances.concat().sort((a, b)=>mathAbs(a) - mathAbs(b))[0];
|
|
2176
|
+
}
|
|
2177
|
+
function findTargetSnap(target) {
|
|
2178
|
+
const distance = loop ? removeOffset(target) : constrain(target);
|
|
2179
|
+
const ascDiffsToSnaps = scrollSnaps.map((snap, index)=>({
|
|
2180
|
+
diff: shortcut(snap - distance, 0),
|
|
2181
|
+
index
|
|
2182
|
+
})).sort((d1, d2)=>mathAbs(d1.diff) - mathAbs(d2.diff));
|
|
2183
|
+
const { index } = ascDiffsToSnaps[0];
|
|
2184
|
+
return {
|
|
2185
|
+
index,
|
|
2186
|
+
distance
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
function shortcut(target, direction) {
|
|
2190
|
+
const targets = [
|
|
2191
|
+
target,
|
|
2192
|
+
target + contentSize,
|
|
2193
|
+
target - contentSize
|
|
2194
|
+
];
|
|
2195
|
+
if (!loop) return target;
|
|
2196
|
+
if (!direction) return minDistance(targets);
|
|
2197
|
+
const matchingTargets = targets.filter((t)=>mathSign(t) === direction);
|
|
2198
|
+
if (matchingTargets.length) return minDistance(matchingTargets);
|
|
2199
|
+
return arrayLast(targets) - contentSize;
|
|
2200
|
+
}
|
|
2201
|
+
function byIndex(index, direction) {
|
|
2202
|
+
const diffToSnap = scrollSnaps[index] - targetVector.get();
|
|
2203
|
+
const distance = shortcut(diffToSnap, direction);
|
|
2204
|
+
return {
|
|
2205
|
+
index,
|
|
2206
|
+
distance
|
|
2207
|
+
};
|
|
2208
|
+
}
|
|
2209
|
+
function byDistance(distance, snap) {
|
|
2210
|
+
const target = targetVector.get() + distance;
|
|
2211
|
+
const { index, distance: targetSnapDistance } = findTargetSnap(target);
|
|
2212
|
+
const reachedBound = !loop && reachedAny(target);
|
|
2213
|
+
if (!snap || reachedBound) return {
|
|
2214
|
+
index,
|
|
2215
|
+
distance
|
|
2216
|
+
};
|
|
2217
|
+
const diffToSnap = scrollSnaps[index] - targetSnapDistance;
|
|
2218
|
+
const snapDistance = distance + shortcut(diffToSnap, 0);
|
|
2219
|
+
return {
|
|
2220
|
+
index,
|
|
2221
|
+
distance: snapDistance
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
const self = {
|
|
2225
|
+
byDistance,
|
|
2226
|
+
byIndex,
|
|
2227
|
+
shortcut
|
|
2228
|
+
};
|
|
2229
|
+
return self;
|
|
2230
|
+
}
|
|
2231
|
+
function ScrollTo(animation, indexCurrent, indexPrevious, scrollBody, scrollTarget, targetVector, eventHandler) {
|
|
2232
|
+
function scrollTo(target) {
|
|
2233
|
+
const distanceDiff = target.distance;
|
|
2234
|
+
const indexDiff = target.index !== indexCurrent.get();
|
|
2235
|
+
targetVector.add(distanceDiff);
|
|
2236
|
+
if (distanceDiff) if (scrollBody.duration()) animation.start();
|
|
2237
|
+
else {
|
|
2238
|
+
animation.update();
|
|
2239
|
+
animation.render(1);
|
|
2240
|
+
animation.update();
|
|
2241
|
+
}
|
|
2242
|
+
if (indexDiff) {
|
|
2243
|
+
indexPrevious.set(indexCurrent.get());
|
|
2244
|
+
indexCurrent.set(target.index);
|
|
2245
|
+
eventHandler.emit('select');
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
function distance(n, snap) {
|
|
2249
|
+
const target = scrollTarget.byDistance(n, snap);
|
|
2250
|
+
scrollTo(target);
|
|
2251
|
+
}
|
|
2252
|
+
function index(n, direction) {
|
|
2253
|
+
const targetIndex = indexCurrent.clone().set(n);
|
|
2254
|
+
const target = scrollTarget.byIndex(targetIndex.get(), direction);
|
|
2255
|
+
scrollTo(target);
|
|
2256
|
+
}
|
|
2257
|
+
const self = {
|
|
2258
|
+
distance,
|
|
2259
|
+
index
|
|
2260
|
+
};
|
|
2261
|
+
return self;
|
|
2262
|
+
}
|
|
2263
|
+
function SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus) {
|
|
2264
|
+
const focusListenerOptions = {
|
|
2265
|
+
passive: true,
|
|
2266
|
+
capture: true
|
|
2267
|
+
};
|
|
2268
|
+
let lastTabPressTime = 0;
|
|
2269
|
+
function init(emblaApi) {
|
|
2270
|
+
if (!watchFocus) return;
|
|
2271
|
+
function defaultCallback(index) {
|
|
2272
|
+
const nowTime = new Date().getTime();
|
|
2273
|
+
const diffTime = nowTime - lastTabPressTime;
|
|
2274
|
+
if (diffTime > 10) return;
|
|
2275
|
+
eventHandler.emit('slideFocusStart');
|
|
2276
|
+
root.scrollLeft = 0;
|
|
2277
|
+
const group = slideRegistry.findIndex((group)=>group.includes(index));
|
|
2278
|
+
if (!isNumber(group)) return;
|
|
2279
|
+
scrollBody.useDuration(0);
|
|
2280
|
+
scrollTo.index(group, 0);
|
|
2281
|
+
eventHandler.emit('slideFocus');
|
|
2282
|
+
}
|
|
2283
|
+
eventStore.add(document, 'keydown', registerTabPress, false);
|
|
2284
|
+
slides.forEach((slide, slideIndex)=>{
|
|
2285
|
+
eventStore.add(slide, 'focus', (evt)=>{
|
|
2286
|
+
if (isBoolean(watchFocus) || watchFocus(emblaApi, evt)) defaultCallback(slideIndex);
|
|
2287
|
+
}, focusListenerOptions);
|
|
2288
|
+
});
|
|
2289
|
+
}
|
|
2290
|
+
function registerTabPress(event) {
|
|
2291
|
+
if ('Tab' === event.code) lastTabPressTime = new Date().getTime();
|
|
2292
|
+
}
|
|
2293
|
+
const self = {
|
|
2294
|
+
init
|
|
2295
|
+
};
|
|
2296
|
+
return self;
|
|
2297
|
+
}
|
|
2298
|
+
function Vector1D(initialValue) {
|
|
2299
|
+
let value = initialValue;
|
|
2300
|
+
function get() {
|
|
2301
|
+
return value;
|
|
2302
|
+
}
|
|
2303
|
+
function set(n) {
|
|
2304
|
+
value = normalizeInput(n);
|
|
2305
|
+
}
|
|
2306
|
+
function add(n) {
|
|
2307
|
+
value += normalizeInput(n);
|
|
2308
|
+
}
|
|
2309
|
+
function subtract(n) {
|
|
2310
|
+
value -= normalizeInput(n);
|
|
2311
|
+
}
|
|
2312
|
+
function normalizeInput(n) {
|
|
2313
|
+
return isNumber(n) ? n : n.get();
|
|
2314
|
+
}
|
|
2315
|
+
const self = {
|
|
2316
|
+
get,
|
|
2317
|
+
set,
|
|
2318
|
+
add,
|
|
2319
|
+
subtract
|
|
2320
|
+
};
|
|
2321
|
+
return self;
|
|
2322
|
+
}
|
|
2323
|
+
function Translate(axis, container) {
|
|
2324
|
+
const translate = 'x' === axis.scroll ? x : y;
|
|
2325
|
+
const containerStyle = container.style;
|
|
2326
|
+
let previousTarget = null;
|
|
2327
|
+
let disabled = false;
|
|
2328
|
+
function x(n) {
|
|
2329
|
+
return `translate3d(${n}px,0px,0px)`;
|
|
2330
|
+
}
|
|
2331
|
+
function y(n) {
|
|
2332
|
+
return `translate3d(0px,${n}px,0px)`;
|
|
2333
|
+
}
|
|
2334
|
+
function to(target) {
|
|
2335
|
+
if (disabled) return;
|
|
2336
|
+
const newTarget = roundToTwoDecimals(axis.direction(target));
|
|
2337
|
+
if (newTarget === previousTarget) return;
|
|
2338
|
+
containerStyle.transform = translate(newTarget);
|
|
2339
|
+
previousTarget = newTarget;
|
|
2340
|
+
}
|
|
2341
|
+
function toggleActive(active) {
|
|
2342
|
+
disabled = !active;
|
|
2343
|
+
}
|
|
2344
|
+
function clear() {
|
|
2345
|
+
if (disabled) return;
|
|
2346
|
+
containerStyle.transform = '';
|
|
2347
|
+
if (!container.getAttribute('style')) container.removeAttribute('style');
|
|
2348
|
+
}
|
|
2349
|
+
const self = {
|
|
2350
|
+
clear,
|
|
2351
|
+
to,
|
|
2352
|
+
toggleActive
|
|
2353
|
+
};
|
|
2354
|
+
return self;
|
|
2355
|
+
}
|
|
2356
|
+
function SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, location, slides) {
|
|
2357
|
+
const roundingSafety = 0.5;
|
|
2358
|
+
const ascItems = arrayKeys(slideSizesWithGaps);
|
|
2359
|
+
const descItems = arrayKeys(slideSizesWithGaps).reverse();
|
|
2360
|
+
const loopPoints = startPoints().concat(endPoints());
|
|
2361
|
+
function removeSlideSizes(indexes, from) {
|
|
2362
|
+
return indexes.reduce((a, i)=>a - slideSizesWithGaps[i], from);
|
|
2363
|
+
}
|
|
2364
|
+
function slidesInGap(indexes, gap) {
|
|
2365
|
+
return indexes.reduce((a, i)=>{
|
|
2366
|
+
const remainingGap = removeSlideSizes(a, gap);
|
|
2367
|
+
return remainingGap > 0 ? a.concat([
|
|
2368
|
+
i
|
|
2369
|
+
]) : a;
|
|
2370
|
+
}, []);
|
|
2371
|
+
}
|
|
2372
|
+
function findSlideBounds(offset) {
|
|
2373
|
+
return snaps.map((snap, index)=>({
|
|
2374
|
+
start: snap - slideSizes[index] + roundingSafety + offset,
|
|
2375
|
+
end: snap + viewSize - roundingSafety + offset
|
|
2376
|
+
}));
|
|
2377
|
+
}
|
|
2378
|
+
function findLoopPoints(indexes, offset, isEndEdge) {
|
|
2379
|
+
const slideBounds = findSlideBounds(offset);
|
|
2380
|
+
return indexes.map((index)=>{
|
|
2381
|
+
const initial = isEndEdge ? 0 : -contentSize;
|
|
2382
|
+
const altered = isEndEdge ? contentSize : 0;
|
|
2383
|
+
const boundEdge = isEndEdge ? 'end' : 'start';
|
|
2384
|
+
const loopPoint = slideBounds[index][boundEdge];
|
|
2385
|
+
return {
|
|
2386
|
+
index,
|
|
2387
|
+
loopPoint,
|
|
2388
|
+
slideLocation: Vector1D(-1),
|
|
2389
|
+
translate: Translate(axis, slides[index]),
|
|
2390
|
+
target: ()=>location.get() > loopPoint ? initial : altered
|
|
2391
|
+
};
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
function startPoints() {
|
|
2395
|
+
const gap = scrollSnaps[0];
|
|
2396
|
+
const indexes = slidesInGap(descItems, gap);
|
|
2397
|
+
return findLoopPoints(indexes, contentSize, false);
|
|
2398
|
+
}
|
|
2399
|
+
function endPoints() {
|
|
2400
|
+
const gap = viewSize - scrollSnaps[0] - 1;
|
|
2401
|
+
const indexes = slidesInGap(ascItems, gap);
|
|
2402
|
+
return findLoopPoints(indexes, -contentSize, true);
|
|
2403
|
+
}
|
|
2404
|
+
function canLoop() {
|
|
2405
|
+
return loopPoints.every(({ index })=>{
|
|
2406
|
+
const otherIndexes = ascItems.filter((i)=>i !== index);
|
|
2407
|
+
return removeSlideSizes(otherIndexes, viewSize) <= 0.1;
|
|
2408
|
+
});
|
|
2409
|
+
}
|
|
2410
|
+
function loop() {
|
|
2411
|
+
loopPoints.forEach((loopPoint)=>{
|
|
2412
|
+
const { target, translate, slideLocation } = loopPoint;
|
|
2413
|
+
const shiftLocation = target();
|
|
2414
|
+
if (shiftLocation === slideLocation.get()) return;
|
|
2415
|
+
translate.to(shiftLocation);
|
|
2416
|
+
slideLocation.set(shiftLocation);
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2419
|
+
function clear() {
|
|
2420
|
+
loopPoints.forEach((loopPoint)=>loopPoint.translate.clear());
|
|
2421
|
+
}
|
|
2422
|
+
const self = {
|
|
2423
|
+
canLoop,
|
|
2424
|
+
clear,
|
|
2425
|
+
loop,
|
|
2426
|
+
loopPoints
|
|
2427
|
+
};
|
|
2428
|
+
return self;
|
|
2429
|
+
}
|
|
2430
|
+
function SlidesHandler(container, eventHandler, watchSlides) {
|
|
2431
|
+
let mutationObserver;
|
|
2432
|
+
let destroyed = false;
|
|
2433
|
+
function init(emblaApi) {
|
|
2434
|
+
if (!watchSlides) return;
|
|
2435
|
+
function defaultCallback(mutations) {
|
|
2436
|
+
for (const mutation of mutations)if ('childList' === mutation.type) {
|
|
2437
|
+
emblaApi.reInit();
|
|
2438
|
+
eventHandler.emit('slidesChanged');
|
|
2439
|
+
break;
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
mutationObserver = new MutationObserver((mutations)=>{
|
|
2443
|
+
if (destroyed) return;
|
|
2444
|
+
if (isBoolean(watchSlides) || watchSlides(emblaApi, mutations)) defaultCallback(mutations);
|
|
2445
|
+
});
|
|
2446
|
+
mutationObserver.observe(container, {
|
|
2447
|
+
childList: true
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
function destroy() {
|
|
2451
|
+
if (mutationObserver) mutationObserver.disconnect();
|
|
2452
|
+
destroyed = true;
|
|
2453
|
+
}
|
|
2454
|
+
const self = {
|
|
2455
|
+
init,
|
|
2456
|
+
destroy
|
|
2457
|
+
};
|
|
2458
|
+
return self;
|
|
2459
|
+
}
|
|
2460
|
+
function SlidesInView(container, slides, eventHandler, threshold) {
|
|
2461
|
+
const intersectionEntryMap = {};
|
|
2462
|
+
let inViewCache = null;
|
|
2463
|
+
let notInViewCache = null;
|
|
2464
|
+
let intersectionObserver;
|
|
2465
|
+
let destroyed = false;
|
|
2466
|
+
function init() {
|
|
2467
|
+
intersectionObserver = new IntersectionObserver((entries)=>{
|
|
2468
|
+
if (destroyed) return;
|
|
2469
|
+
entries.forEach((entry)=>{
|
|
2470
|
+
const index = slides.indexOf(entry.target);
|
|
2471
|
+
intersectionEntryMap[index] = entry;
|
|
2472
|
+
});
|
|
2473
|
+
inViewCache = null;
|
|
2474
|
+
notInViewCache = null;
|
|
2475
|
+
eventHandler.emit('slidesInView');
|
|
2476
|
+
}, {
|
|
2477
|
+
root: container.parentElement,
|
|
2478
|
+
threshold
|
|
2479
|
+
});
|
|
2480
|
+
slides.forEach((slide)=>intersectionObserver.observe(slide));
|
|
2481
|
+
}
|
|
2482
|
+
function destroy() {
|
|
2483
|
+
if (intersectionObserver) intersectionObserver.disconnect();
|
|
2484
|
+
destroyed = true;
|
|
2485
|
+
}
|
|
2486
|
+
function createInViewList(inView) {
|
|
2487
|
+
return objectKeys(intersectionEntryMap).reduce((list, slideIndex)=>{
|
|
2488
|
+
const index = parseInt(slideIndex);
|
|
2489
|
+
const { isIntersecting } = intersectionEntryMap[index];
|
|
2490
|
+
const inViewMatch = inView && isIntersecting;
|
|
2491
|
+
const notInViewMatch = !inView && !isIntersecting;
|
|
2492
|
+
if (inViewMatch || notInViewMatch) list.push(index);
|
|
2493
|
+
return list;
|
|
2494
|
+
}, []);
|
|
2495
|
+
}
|
|
2496
|
+
function get(inView = true) {
|
|
2497
|
+
if (inView && inViewCache) return inViewCache;
|
|
2498
|
+
if (!inView && notInViewCache) return notInViewCache;
|
|
2499
|
+
const slideIndexes = createInViewList(inView);
|
|
2500
|
+
if (inView) inViewCache = slideIndexes;
|
|
2501
|
+
if (!inView) notInViewCache = slideIndexes;
|
|
2502
|
+
return slideIndexes;
|
|
2503
|
+
}
|
|
2504
|
+
const self = {
|
|
2505
|
+
init,
|
|
2506
|
+
destroy,
|
|
2507
|
+
get
|
|
2508
|
+
};
|
|
2509
|
+
return self;
|
|
2510
|
+
}
|
|
2511
|
+
function SlideSizes(axis, containerRect, slideRects, slides, readEdgeGap, ownerWindow) {
|
|
2512
|
+
const { measureSize, startEdge, endEdge } = axis;
|
|
2513
|
+
const withEdgeGap = slideRects[0] && readEdgeGap;
|
|
2514
|
+
const startGap = measureStartGap();
|
|
2515
|
+
const endGap = measureEndGap();
|
|
2516
|
+
const slideSizes = slideRects.map(measureSize);
|
|
2517
|
+
const slideSizesWithGaps = measureWithGaps();
|
|
2518
|
+
function measureStartGap() {
|
|
2519
|
+
if (!withEdgeGap) return 0;
|
|
2520
|
+
const slideRect = slideRects[0];
|
|
2521
|
+
return mathAbs(containerRect[startEdge] - slideRect[startEdge]);
|
|
2522
|
+
}
|
|
2523
|
+
function measureEndGap() {
|
|
2524
|
+
if (!withEdgeGap) return 0;
|
|
2525
|
+
const style = ownerWindow.getComputedStyle(arrayLast(slides));
|
|
2526
|
+
return parseFloat(style.getPropertyValue(`margin-${endEdge}`));
|
|
2527
|
+
}
|
|
2528
|
+
function measureWithGaps() {
|
|
2529
|
+
return slideRects.map((rect, index, rects)=>{
|
|
2530
|
+
const isFirst = !index;
|
|
2531
|
+
const isLast = arrayIsLastIndex(rects, index);
|
|
2532
|
+
if (isFirst) return slideSizes[index] + startGap;
|
|
2533
|
+
if (isLast) return slideSizes[index] + endGap;
|
|
2534
|
+
return rects[index + 1][startEdge] - rect[startEdge];
|
|
2535
|
+
}).map(mathAbs);
|
|
2536
|
+
}
|
|
2537
|
+
const self = {
|
|
2538
|
+
slideSizes,
|
|
2539
|
+
slideSizesWithGaps,
|
|
2540
|
+
startGap,
|
|
2541
|
+
endGap
|
|
2542
|
+
};
|
|
2543
|
+
return self;
|
|
2544
|
+
}
|
|
2545
|
+
function SlidesToScroll(axis, viewSize, slidesToScroll, loop, containerRect, slideRects, startGap, endGap, pixelTolerance) {
|
|
2546
|
+
const { startEdge, endEdge, direction } = axis;
|
|
2547
|
+
const groupByNumber = isNumber(slidesToScroll);
|
|
2548
|
+
function byNumber(array, groupSize) {
|
|
2549
|
+
return arrayKeys(array).filter((i)=>i % groupSize === 0).map((i)=>array.slice(i, i + groupSize));
|
|
2550
|
+
}
|
|
2551
|
+
function bySize(array) {
|
|
2552
|
+
if (!array.length) return [];
|
|
2553
|
+
return arrayKeys(array).reduce((groups, rectB, index)=>{
|
|
2554
|
+
const rectA = arrayLast(groups) || 0;
|
|
2555
|
+
const isFirst = 0 === rectA;
|
|
2556
|
+
const isLast = rectB === arrayLastIndex(array);
|
|
2557
|
+
const edgeA = containerRect[startEdge] - slideRects[rectA][startEdge];
|
|
2558
|
+
const edgeB = containerRect[startEdge] - slideRects[rectB][endEdge];
|
|
2559
|
+
const gapA = !loop && isFirst ? direction(startGap) : 0;
|
|
2560
|
+
const gapB = !loop && isLast ? direction(endGap) : 0;
|
|
2561
|
+
const chunkSize = mathAbs(edgeB - gapB - (edgeA + gapA));
|
|
2562
|
+
if (index && chunkSize > viewSize + pixelTolerance) groups.push(rectB);
|
|
2563
|
+
if (isLast) groups.push(array.length);
|
|
2564
|
+
return groups;
|
|
2565
|
+
}, []).map((currentSize, index, groups)=>{
|
|
2566
|
+
const previousSize = Math.max(groups[index - 1] || 0);
|
|
2567
|
+
return array.slice(previousSize, currentSize);
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2570
|
+
function groupSlides(array) {
|
|
2571
|
+
return groupByNumber ? byNumber(array, slidesToScroll) : bySize(array);
|
|
2572
|
+
}
|
|
2573
|
+
const self = {
|
|
2574
|
+
groupSlides
|
|
2575
|
+
};
|
|
2576
|
+
return self;
|
|
2577
|
+
}
|
|
2578
|
+
function Engine(root, container, slides, ownerDocument, ownerWindow, options, eventHandler) {
|
|
2579
|
+
const { align, axis: scrollAxis, direction, startIndex, loop, duration, dragFree, dragThreshold, inViewThreshold, slidesToScroll: groupSlides, skipSnaps, containScroll, watchResize, watchSlides, watchDrag, watchFocus } = options;
|
|
2580
|
+
const pixelTolerance = 2;
|
|
2581
|
+
const nodeRects = NodeRects();
|
|
2582
|
+
const containerRect = nodeRects.measure(container);
|
|
2583
|
+
const slideRects = slides.map(nodeRects.measure);
|
|
2584
|
+
const axis = Axis(scrollAxis, direction);
|
|
2585
|
+
const viewSize = axis.measureSize(containerRect);
|
|
2586
|
+
const percentOfView = PercentOfView(viewSize);
|
|
2587
|
+
const alignment = Alignment(align, viewSize);
|
|
2588
|
+
const containSnaps = !loop && !!containScroll;
|
|
2589
|
+
const readEdgeGap = loop || !!containScroll;
|
|
2590
|
+
const { slideSizes, slideSizesWithGaps, startGap, endGap } = SlideSizes(axis, containerRect, slideRects, slides, readEdgeGap, ownerWindow);
|
|
2591
|
+
const slidesToScroll = SlidesToScroll(axis, viewSize, groupSlides, loop, containerRect, slideRects, startGap, endGap, pixelTolerance);
|
|
2592
|
+
const { snaps, snapsAligned } = ScrollSnaps(axis, alignment, containerRect, slideRects, slidesToScroll);
|
|
2593
|
+
const contentSize = -arrayLast(snaps) + arrayLast(slideSizesWithGaps);
|
|
2594
|
+
const { snapsContained, scrollContainLimit } = ScrollContain(viewSize, contentSize, snapsAligned, containScroll, pixelTolerance);
|
|
2595
|
+
const scrollSnaps = containSnaps ? snapsContained : snapsAligned;
|
|
2596
|
+
const { limit } = ScrollLimit(contentSize, scrollSnaps, loop);
|
|
2597
|
+
const index = Counter(arrayLastIndex(scrollSnaps), startIndex, loop);
|
|
2598
|
+
const indexPrevious = index.clone();
|
|
2599
|
+
const slideIndexes = arrayKeys(slides);
|
|
2600
|
+
const update = ({ dragHandler, scrollBody, scrollBounds, options: { loop } })=>{
|
|
2601
|
+
if (!loop) scrollBounds.constrain(dragHandler.pointerDown());
|
|
2602
|
+
scrollBody.seek();
|
|
2603
|
+
};
|
|
2604
|
+
const render = ({ scrollBody, translate, location, offsetLocation, previousLocation, scrollLooper, slideLooper, dragHandler, animation, eventHandler, scrollBounds, options: { loop } }, alpha)=>{
|
|
2605
|
+
const shouldSettle = scrollBody.settled();
|
|
2606
|
+
const withinBounds = !scrollBounds.shouldConstrain();
|
|
2607
|
+
const hasSettled = loop ? shouldSettle : shouldSettle && withinBounds;
|
|
2608
|
+
const hasSettledAndIdle = hasSettled && !dragHandler.pointerDown();
|
|
2609
|
+
if (hasSettledAndIdle) animation.stop();
|
|
2610
|
+
const interpolatedLocation = location.get() * alpha + previousLocation.get() * (1 - alpha);
|
|
2611
|
+
offsetLocation.set(interpolatedLocation);
|
|
2612
|
+
if (loop) {
|
|
2613
|
+
scrollLooper.loop(scrollBody.direction());
|
|
2614
|
+
slideLooper.loop();
|
|
2615
|
+
}
|
|
2616
|
+
translate.to(offsetLocation.get());
|
|
2617
|
+
if (hasSettledAndIdle) eventHandler.emit('settle');
|
|
2618
|
+
if (!hasSettled) eventHandler.emit('scroll');
|
|
2619
|
+
};
|
|
2620
|
+
const animation = Animations(ownerDocument, ownerWindow, ()=>update(engine), (alpha)=>render(engine, alpha));
|
|
2621
|
+
const friction = 0.68;
|
|
2622
|
+
const startLocation = scrollSnaps[index.get()];
|
|
2623
|
+
const location = Vector1D(startLocation);
|
|
2624
|
+
const previousLocation = Vector1D(startLocation);
|
|
2625
|
+
const offsetLocation = Vector1D(startLocation);
|
|
2626
|
+
const target = Vector1D(startLocation);
|
|
2627
|
+
const scrollBody = ScrollBody(location, offsetLocation, previousLocation, target, duration, friction);
|
|
2628
|
+
const scrollTarget = ScrollTarget(loop, scrollSnaps, contentSize, limit, target);
|
|
2629
|
+
const scrollTo = ScrollTo(animation, index, indexPrevious, scrollBody, scrollTarget, target, eventHandler);
|
|
2630
|
+
const scrollProgress = ScrollProgress(limit);
|
|
2631
|
+
const eventStore = EventStore();
|
|
2632
|
+
const slidesInView = SlidesInView(container, slides, eventHandler, inViewThreshold);
|
|
2633
|
+
const { slideRegistry } = SlideRegistry(containSnaps, containScroll, scrollSnaps, scrollContainLimit, slidesToScroll, slideIndexes);
|
|
2634
|
+
const slideFocus = SlideFocus(root, slides, slideRegistry, scrollTo, scrollBody, eventStore, eventHandler, watchFocus);
|
|
2635
|
+
const engine = {
|
|
2636
|
+
ownerDocument,
|
|
2637
|
+
ownerWindow,
|
|
2638
|
+
eventHandler,
|
|
2639
|
+
containerRect,
|
|
2640
|
+
slideRects,
|
|
2641
|
+
animation,
|
|
2642
|
+
axis,
|
|
2643
|
+
dragHandler: DragHandler(axis, root, ownerDocument, ownerWindow, target, DragTracker(axis, ownerWindow), location, animation, scrollTo, scrollBody, scrollTarget, index, eventHandler, percentOfView, dragFree, dragThreshold, skipSnaps, friction, watchDrag),
|
|
2644
|
+
eventStore,
|
|
2645
|
+
percentOfView,
|
|
2646
|
+
index,
|
|
2647
|
+
indexPrevious,
|
|
2648
|
+
limit,
|
|
2649
|
+
location,
|
|
2650
|
+
offsetLocation,
|
|
2651
|
+
previousLocation,
|
|
2652
|
+
options,
|
|
2653
|
+
resizeHandler: ResizeHandler(container, eventHandler, ownerWindow, slides, axis, watchResize, nodeRects),
|
|
2654
|
+
scrollBody,
|
|
2655
|
+
scrollBounds: ScrollBounds(limit, offsetLocation, target, scrollBody, percentOfView),
|
|
2656
|
+
scrollLooper: ScrollLooper(contentSize, limit, offsetLocation, [
|
|
2657
|
+
location,
|
|
2658
|
+
offsetLocation,
|
|
2659
|
+
previousLocation,
|
|
2660
|
+
target
|
|
2661
|
+
]),
|
|
2662
|
+
scrollProgress,
|
|
2663
|
+
scrollSnapList: scrollSnaps.map(scrollProgress.get),
|
|
2664
|
+
scrollSnaps,
|
|
2665
|
+
scrollTarget,
|
|
2666
|
+
scrollTo,
|
|
2667
|
+
slideLooper: SlideLooper(axis, viewSize, contentSize, slideSizes, slideSizesWithGaps, snaps, scrollSnaps, offsetLocation, slides),
|
|
2668
|
+
slideFocus,
|
|
2669
|
+
slidesHandler: SlidesHandler(container, eventHandler, watchSlides),
|
|
2670
|
+
slidesInView,
|
|
2671
|
+
slideIndexes,
|
|
2672
|
+
slideRegistry,
|
|
2673
|
+
slidesToScroll,
|
|
2674
|
+
target,
|
|
2675
|
+
translate: Translate(axis, container)
|
|
2676
|
+
};
|
|
2677
|
+
return engine;
|
|
2678
|
+
}
|
|
2679
|
+
function EventHandler() {
|
|
2680
|
+
let listeners = {};
|
|
2681
|
+
let api;
|
|
2682
|
+
function init(emblaApi) {
|
|
2683
|
+
api = emblaApi;
|
|
2684
|
+
}
|
|
2685
|
+
function getListeners(evt) {
|
|
2686
|
+
return listeners[evt] || [];
|
|
2687
|
+
}
|
|
2688
|
+
function emit(evt) {
|
|
2689
|
+
getListeners(evt).forEach((e)=>e(api, evt));
|
|
2690
|
+
return self;
|
|
2691
|
+
}
|
|
2692
|
+
function on(evt, cb) {
|
|
2693
|
+
listeners[evt] = getListeners(evt).concat([
|
|
2694
|
+
cb
|
|
2695
|
+
]);
|
|
2696
|
+
return self;
|
|
2697
|
+
}
|
|
2698
|
+
function off(evt, cb) {
|
|
2699
|
+
listeners[evt] = getListeners(evt).filter((e)=>e !== cb);
|
|
2700
|
+
return self;
|
|
2701
|
+
}
|
|
2702
|
+
function clear() {
|
|
2703
|
+
listeners = {};
|
|
2704
|
+
}
|
|
2705
|
+
const self = {
|
|
2706
|
+
init,
|
|
2707
|
+
emit,
|
|
2708
|
+
off,
|
|
2709
|
+
on,
|
|
2710
|
+
clear
|
|
2711
|
+
};
|
|
2712
|
+
return self;
|
|
2713
|
+
}
|
|
2714
|
+
const defaultOptions = {
|
|
2715
|
+
align: 'center',
|
|
2716
|
+
axis: 'x',
|
|
2717
|
+
container: null,
|
|
2718
|
+
slides: null,
|
|
2719
|
+
containScroll: 'trimSnaps',
|
|
2720
|
+
direction: 'ltr',
|
|
2721
|
+
slidesToScroll: 1,
|
|
2722
|
+
inViewThreshold: 0,
|
|
2723
|
+
breakpoints: {},
|
|
2724
|
+
dragFree: false,
|
|
2725
|
+
dragThreshold: 10,
|
|
2726
|
+
loop: false,
|
|
2727
|
+
skipSnaps: false,
|
|
2728
|
+
duration: 25,
|
|
2729
|
+
startIndex: 0,
|
|
2730
|
+
active: true,
|
|
2731
|
+
watchDrag: true,
|
|
2732
|
+
watchResize: true,
|
|
2733
|
+
watchSlides: true,
|
|
2734
|
+
watchFocus: true
|
|
2735
|
+
};
|
|
2736
|
+
function OptionsHandler(ownerWindow) {
|
|
2737
|
+
function mergeOptions(optionsA, optionsB) {
|
|
2738
|
+
return objectsMergeDeep(optionsA, optionsB || {});
|
|
2739
|
+
}
|
|
2740
|
+
function optionsAtMedia(options) {
|
|
2741
|
+
const optionsAtMedia = options.breakpoints || {};
|
|
2742
|
+
const matchedMediaOptions = objectKeys(optionsAtMedia).filter((media)=>ownerWindow.matchMedia(media).matches).map((media)=>optionsAtMedia[media]).reduce((a, mediaOption)=>mergeOptions(a, mediaOption), {});
|
|
2743
|
+
return mergeOptions(options, matchedMediaOptions);
|
|
2744
|
+
}
|
|
2745
|
+
function optionsMediaQueries(optionsList) {
|
|
2746
|
+
return optionsList.map((options)=>objectKeys(options.breakpoints || {})).reduce((acc, mediaQueries)=>acc.concat(mediaQueries), []).map(ownerWindow.matchMedia);
|
|
2747
|
+
}
|
|
2748
|
+
const self = {
|
|
2749
|
+
mergeOptions,
|
|
2750
|
+
optionsAtMedia,
|
|
2751
|
+
optionsMediaQueries
|
|
2752
|
+
};
|
|
2753
|
+
return self;
|
|
2754
|
+
}
|
|
2755
|
+
function PluginsHandler(optionsHandler) {
|
|
2756
|
+
let activePlugins = [];
|
|
2757
|
+
function init(emblaApi, plugins) {
|
|
2758
|
+
activePlugins = plugins.filter(({ options })=>false !== optionsHandler.optionsAtMedia(options).active);
|
|
2759
|
+
activePlugins.forEach((plugin)=>plugin.init(emblaApi, optionsHandler));
|
|
2760
|
+
return plugins.reduce((map, plugin)=>Object.assign(map, {
|
|
2761
|
+
[plugin.name]: plugin
|
|
2762
|
+
}), {});
|
|
2763
|
+
}
|
|
2764
|
+
function destroy() {
|
|
2765
|
+
activePlugins = activePlugins.filter((plugin)=>plugin.destroy());
|
|
2766
|
+
}
|
|
2767
|
+
const self = {
|
|
2768
|
+
init,
|
|
2769
|
+
destroy
|
|
2770
|
+
};
|
|
2771
|
+
return self;
|
|
2772
|
+
}
|
|
2773
|
+
function EmblaCarousel(root, userOptions, userPlugins) {
|
|
2774
|
+
const ownerDocument = root.ownerDocument;
|
|
2775
|
+
const ownerWindow = ownerDocument.defaultView;
|
|
2776
|
+
const optionsHandler = OptionsHandler(ownerWindow);
|
|
2777
|
+
const pluginsHandler = PluginsHandler(optionsHandler);
|
|
2778
|
+
const mediaHandlers = EventStore();
|
|
2779
|
+
const eventHandler = EventHandler();
|
|
2780
|
+
const { mergeOptions, optionsAtMedia, optionsMediaQueries } = optionsHandler;
|
|
2781
|
+
const { on, off, emit } = eventHandler;
|
|
2782
|
+
const reInit = reActivate;
|
|
2783
|
+
let destroyed = false;
|
|
2784
|
+
let engine;
|
|
2785
|
+
let optionsBase = mergeOptions(defaultOptions, EmblaCarousel.globalOptions);
|
|
2786
|
+
let options = mergeOptions(optionsBase);
|
|
2787
|
+
let pluginList = [];
|
|
2788
|
+
let pluginApis;
|
|
2789
|
+
let container;
|
|
2790
|
+
let slides;
|
|
2791
|
+
function storeElements() {
|
|
2792
|
+
const { container: userContainer, slides: userSlides } = options;
|
|
2793
|
+
const customContainer = isString(userContainer) ? root.querySelector(userContainer) : userContainer;
|
|
2794
|
+
container = customContainer || root.children[0];
|
|
2795
|
+
const customSlides = isString(userSlides) ? container.querySelectorAll(userSlides) : userSlides;
|
|
2796
|
+
slides = [].slice.call(customSlides || container.children);
|
|
2797
|
+
}
|
|
2798
|
+
function createEngine(options) {
|
|
2799
|
+
const engine = Engine(root, container, slides, ownerDocument, ownerWindow, options, eventHandler);
|
|
2800
|
+
if (options.loop && !engine.slideLooper.canLoop()) {
|
|
2801
|
+
const optionsWithoutLoop = Object.assign({}, options, {
|
|
2802
|
+
loop: false
|
|
2803
|
+
});
|
|
2804
|
+
return createEngine(optionsWithoutLoop);
|
|
2805
|
+
}
|
|
2806
|
+
return engine;
|
|
2807
|
+
}
|
|
2808
|
+
function activate(withOptions, withPlugins) {
|
|
2809
|
+
if (destroyed) return;
|
|
2810
|
+
optionsBase = mergeOptions(optionsBase, withOptions);
|
|
2811
|
+
options = optionsAtMedia(optionsBase);
|
|
2812
|
+
pluginList = withPlugins || pluginList;
|
|
2813
|
+
storeElements();
|
|
2814
|
+
engine = createEngine(options);
|
|
2815
|
+
optionsMediaQueries([
|
|
2816
|
+
optionsBase,
|
|
2817
|
+
...pluginList.map(({ options })=>options)
|
|
2818
|
+
]).forEach((query)=>mediaHandlers.add(query, 'change', reActivate));
|
|
2819
|
+
if (!options.active) return;
|
|
2820
|
+
engine.translate.to(engine.location.get());
|
|
2821
|
+
engine.animation.init();
|
|
2822
|
+
engine.slidesInView.init();
|
|
2823
|
+
engine.slideFocus.init(self);
|
|
2824
|
+
engine.eventHandler.init(self);
|
|
2825
|
+
engine.resizeHandler.init(self);
|
|
2826
|
+
engine.slidesHandler.init(self);
|
|
2827
|
+
if (engine.options.loop) engine.slideLooper.loop();
|
|
2828
|
+
if (container.offsetParent && slides.length) engine.dragHandler.init(self);
|
|
2829
|
+
pluginApis = pluginsHandler.init(self, pluginList);
|
|
2830
|
+
}
|
|
2831
|
+
function reActivate(withOptions, withPlugins) {
|
|
2832
|
+
const startIndex = selectedScrollSnap();
|
|
2833
|
+
deActivate();
|
|
2834
|
+
activate(mergeOptions({
|
|
2835
|
+
startIndex
|
|
2836
|
+
}, withOptions), withPlugins);
|
|
2837
|
+
eventHandler.emit('reInit');
|
|
2838
|
+
}
|
|
2839
|
+
function deActivate() {
|
|
2840
|
+
engine.dragHandler.destroy();
|
|
2841
|
+
engine.eventStore.clear();
|
|
2842
|
+
engine.translate.clear();
|
|
2843
|
+
engine.slideLooper.clear();
|
|
2844
|
+
engine.resizeHandler.destroy();
|
|
2845
|
+
engine.slidesHandler.destroy();
|
|
2846
|
+
engine.slidesInView.destroy();
|
|
2847
|
+
engine.animation.destroy();
|
|
2848
|
+
pluginsHandler.destroy();
|
|
2849
|
+
mediaHandlers.clear();
|
|
2850
|
+
}
|
|
2851
|
+
function destroy() {
|
|
2852
|
+
if (destroyed) return;
|
|
2853
|
+
destroyed = true;
|
|
2854
|
+
mediaHandlers.clear();
|
|
2855
|
+
deActivate();
|
|
2856
|
+
eventHandler.emit('destroy');
|
|
2857
|
+
eventHandler.clear();
|
|
2858
|
+
}
|
|
2859
|
+
function scrollTo(index, jump, direction) {
|
|
2860
|
+
if (!options.active || destroyed) return;
|
|
2861
|
+
engine.scrollBody.useBaseFriction().useDuration(true === jump ? 0 : options.duration);
|
|
2862
|
+
engine.scrollTo.index(index, direction || 0);
|
|
2863
|
+
}
|
|
2864
|
+
function scrollNext(jump) {
|
|
2865
|
+
const next = engine.index.add(1).get();
|
|
2866
|
+
scrollTo(next, jump, -1);
|
|
2867
|
+
}
|
|
2868
|
+
function scrollPrev(jump) {
|
|
2869
|
+
const prev = engine.index.add(-1).get();
|
|
2870
|
+
scrollTo(prev, jump, 1);
|
|
2871
|
+
}
|
|
2872
|
+
function canScrollNext() {
|
|
2873
|
+
const next = engine.index.add(1).get();
|
|
2874
|
+
return next !== selectedScrollSnap();
|
|
2875
|
+
}
|
|
2876
|
+
function canScrollPrev() {
|
|
2877
|
+
const prev = engine.index.add(-1).get();
|
|
2878
|
+
return prev !== selectedScrollSnap();
|
|
2879
|
+
}
|
|
2880
|
+
function scrollSnapList() {
|
|
2881
|
+
return engine.scrollSnapList;
|
|
2882
|
+
}
|
|
2883
|
+
function scrollProgress() {
|
|
2884
|
+
return engine.scrollProgress.get(engine.offsetLocation.get());
|
|
2885
|
+
}
|
|
2886
|
+
function selectedScrollSnap() {
|
|
2887
|
+
return engine.index.get();
|
|
2888
|
+
}
|
|
2889
|
+
function previousScrollSnap() {
|
|
2890
|
+
return engine.indexPrevious.get();
|
|
2891
|
+
}
|
|
2892
|
+
function slidesInView() {
|
|
2893
|
+
return engine.slidesInView.get();
|
|
2894
|
+
}
|
|
2895
|
+
function slidesNotInView() {
|
|
2896
|
+
return engine.slidesInView.get(false);
|
|
2897
|
+
}
|
|
2898
|
+
function plugins() {
|
|
2899
|
+
return pluginApis;
|
|
2900
|
+
}
|
|
2901
|
+
function internalEngine() {
|
|
2902
|
+
return engine;
|
|
2903
|
+
}
|
|
2904
|
+
function rootNode() {
|
|
2905
|
+
return root;
|
|
2906
|
+
}
|
|
2907
|
+
function containerNode() {
|
|
2908
|
+
return container;
|
|
2909
|
+
}
|
|
2910
|
+
function slideNodes() {
|
|
2911
|
+
return slides;
|
|
2912
|
+
}
|
|
2913
|
+
const self = {
|
|
2914
|
+
canScrollNext,
|
|
2915
|
+
canScrollPrev,
|
|
2916
|
+
containerNode,
|
|
2917
|
+
internalEngine,
|
|
2918
|
+
destroy,
|
|
2919
|
+
off,
|
|
2920
|
+
on,
|
|
2921
|
+
emit,
|
|
2922
|
+
plugins,
|
|
2923
|
+
previousScrollSnap,
|
|
2924
|
+
reInit,
|
|
2925
|
+
rootNode,
|
|
2926
|
+
scrollNext,
|
|
2927
|
+
scrollPrev,
|
|
2928
|
+
scrollProgress,
|
|
2929
|
+
scrollSnapList,
|
|
2930
|
+
scrollTo,
|
|
2931
|
+
selectedScrollSnap,
|
|
2932
|
+
slideNodes,
|
|
2933
|
+
slidesInView,
|
|
2934
|
+
slidesNotInView
|
|
2935
|
+
};
|
|
2936
|
+
activate(userOptions, userPlugins);
|
|
2937
|
+
setTimeout(()=>eventHandler.emit('init'), 0);
|
|
2938
|
+
return self;
|
|
2939
|
+
}
|
|
2940
|
+
EmblaCarousel.globalOptions = void 0;
|
|
2941
|
+
function useEmblaCarousel(options = {}, plugins = []) {
|
|
2942
|
+
const storedOptions = (0, external_react_.useRef)(options);
|
|
2943
|
+
const storedPlugins = (0, external_react_.useRef)(plugins);
|
|
2944
|
+
const [emblaApi, setEmblaApi] = (0, external_react_.useState)();
|
|
2945
|
+
const [viewport, setViewport] = (0, external_react_.useState)();
|
|
2946
|
+
const reInit = (0, external_react_.useCallback)(()=>{
|
|
2947
|
+
if (emblaApi) emblaApi.reInit(storedOptions.current, storedPlugins.current);
|
|
2948
|
+
}, [
|
|
2949
|
+
emblaApi
|
|
2950
|
+
]);
|
|
2951
|
+
(0, external_react_.useEffect)(()=>{
|
|
2952
|
+
if (areOptionsEqual(storedOptions.current, options)) return;
|
|
2953
|
+
storedOptions.current = options;
|
|
2954
|
+
reInit();
|
|
2955
|
+
}, [
|
|
2956
|
+
options,
|
|
2957
|
+
reInit
|
|
2958
|
+
]);
|
|
2959
|
+
(0, external_react_.useEffect)(()=>{
|
|
2960
|
+
if (arePluginsEqual(storedPlugins.current, plugins)) return;
|
|
2961
|
+
storedPlugins.current = plugins;
|
|
2962
|
+
reInit();
|
|
2963
|
+
}, [
|
|
2964
|
+
plugins,
|
|
2965
|
+
reInit
|
|
2966
|
+
]);
|
|
2967
|
+
(0, external_react_.useEffect)(()=>{
|
|
2968
|
+
if (canUseDOM() && viewport) {
|
|
2969
|
+
EmblaCarousel.globalOptions = useEmblaCarousel.globalOptions;
|
|
2970
|
+
const newEmblaApi = EmblaCarousel(viewport, storedOptions.current, storedPlugins.current);
|
|
2971
|
+
setEmblaApi(newEmblaApi);
|
|
2972
|
+
return ()=>newEmblaApi.destroy();
|
|
2973
|
+
}
|
|
2974
|
+
setEmblaApi(void 0);
|
|
2975
|
+
}, [
|
|
2976
|
+
viewport,
|
|
2977
|
+
setEmblaApi
|
|
2978
|
+
]);
|
|
2979
|
+
return [
|
|
2980
|
+
setViewport,
|
|
2981
|
+
emblaApi
|
|
2982
|
+
];
|
|
2983
|
+
}
|
|
2984
|
+
useEmblaCarousel.globalOptions = void 0;
|
|
2985
|
+
},
|
|
2986
|
+
"../../node_modules/.pnpm/vaul@1.1.2_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2.9_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/vaul/dist/index.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
2987
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
2988
|
+
_s: ()=>Drawer
|
|
2989
|
+
});
|
|
2990
|
+
var _radix_ui_react_dialog__rspack_import_0 = __webpack_require__("@radix-ui/react-dialog");
|
|
2991
|
+
var react__rspack_import_1 = __webpack_require__("react");
|
|
2992
|
+
function __insertCSS(code) {
|
|
2993
|
+
if (!code || "u" < typeof document) return;
|
|
2994
|
+
let head = document.head || document.getElementsByTagName('head')[0];
|
|
2995
|
+
let style = document.createElement('style');
|
|
2996
|
+
style.type = 'text/css';
|
|
2997
|
+
head.appendChild(style);
|
|
2998
|
+
style.styleSheet ? style.styleSheet.cssText = code : style.appendChild(document.createTextNode(code));
|
|
2999
|
+
}
|
|
3000
|
+
const DrawerContext = react__rspack_import_1["default"].createContext({
|
|
3001
|
+
drawerRef: {
|
|
3002
|
+
current: null
|
|
3003
|
+
},
|
|
3004
|
+
overlayRef: {
|
|
3005
|
+
current: null
|
|
3006
|
+
},
|
|
3007
|
+
onPress: ()=>{},
|
|
3008
|
+
onRelease: ()=>{},
|
|
3009
|
+
onDrag: ()=>{},
|
|
3010
|
+
onNestedDrag: ()=>{},
|
|
3011
|
+
onNestedOpenChange: ()=>{},
|
|
3012
|
+
onNestedRelease: ()=>{},
|
|
3013
|
+
openProp: void 0,
|
|
3014
|
+
dismissible: false,
|
|
3015
|
+
isOpen: false,
|
|
3016
|
+
isDragging: false,
|
|
3017
|
+
keyboardIsOpen: {
|
|
3018
|
+
current: false
|
|
3019
|
+
},
|
|
3020
|
+
snapPointsOffset: null,
|
|
3021
|
+
snapPoints: null,
|
|
3022
|
+
handleOnly: false,
|
|
3023
|
+
modal: false,
|
|
3024
|
+
shouldFade: false,
|
|
3025
|
+
activeSnapPoint: null,
|
|
3026
|
+
onOpenChange: ()=>{},
|
|
3027
|
+
setActiveSnapPoint: ()=>{},
|
|
3028
|
+
closeDrawer: ()=>{},
|
|
3029
|
+
direction: 'bottom',
|
|
3030
|
+
shouldAnimate: {
|
|
3031
|
+
current: true
|
|
3032
|
+
},
|
|
3033
|
+
shouldScaleBackground: false,
|
|
3034
|
+
setBackgroundColorOnScale: true,
|
|
3035
|
+
noBodyStyles: false,
|
|
3036
|
+
container: null,
|
|
3037
|
+
autoFocus: false
|
|
3038
|
+
});
|
|
3039
|
+
const useDrawerContext = ()=>{
|
|
3040
|
+
const context = react__rspack_import_1["default"].useContext(DrawerContext);
|
|
3041
|
+
if (!context) throw new Error('useDrawerContext must be used within a Drawer.Root');
|
|
3042
|
+
return context;
|
|
3043
|
+
};
|
|
3044
|
+
__insertCSS("[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(\n[data-state=closed]\n){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)}}");
|
|
3045
|
+
function isMobileFirefox() {
|
|
3046
|
+
const userAgent = navigator.userAgent;
|
|
3047
|
+
return "u" > typeof window && (/Firefox/.test(userAgent) && /Mobile/.test(userAgent) || /FxiOS/.test(userAgent));
|
|
3048
|
+
}
|
|
3049
|
+
function isMac() {
|
|
3050
|
+
return testPlatform(/^Mac/);
|
|
3051
|
+
}
|
|
3052
|
+
function isIPhone() {
|
|
3053
|
+
return testPlatform(/^iPhone/);
|
|
3054
|
+
}
|
|
3055
|
+
function isSafari() {
|
|
3056
|
+
return /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
3057
|
+
}
|
|
3058
|
+
function isIPad() {
|
|
3059
|
+
return testPlatform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
|
|
3060
|
+
}
|
|
3061
|
+
function isIOS() {
|
|
3062
|
+
return isIPhone() || isIPad();
|
|
3063
|
+
}
|
|
3064
|
+
function testPlatform(re) {
|
|
3065
|
+
return "u" > typeof window && null != window.navigator ? re.test(window.navigator.platform) : void 0;
|
|
3066
|
+
}
|
|
3067
|
+
const KEYBOARD_BUFFER = 24;
|
|
3068
|
+
const useIsomorphicLayoutEffect = "u" > typeof window ? react__rspack_import_1.useLayoutEffect : react__rspack_import_1.useEffect;
|
|
3069
|
+
function chain$1(...callbacks) {
|
|
3070
|
+
return (...args)=>{
|
|
3071
|
+
for (let callback of callbacks)if ('function' == typeof callback) callback(...args);
|
|
3072
|
+
};
|
|
3073
|
+
}
|
|
3074
|
+
const visualViewport = "u" > typeof document && window.visualViewport;
|
|
3075
|
+
function isScrollable(node) {
|
|
3076
|
+
let style = window.getComputedStyle(node);
|
|
3077
|
+
return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
|
|
3078
|
+
}
|
|
3079
|
+
function getScrollParent(node) {
|
|
3080
|
+
if (isScrollable(node)) node = node.parentElement;
|
|
3081
|
+
while(node && !isScrollable(node))node = node.parentElement;
|
|
3082
|
+
return node || document.scrollingElement || document.documentElement;
|
|
3083
|
+
}
|
|
3084
|
+
const nonTextInputTypes = new Set([
|
|
3085
|
+
'checkbox',
|
|
3086
|
+
'radio',
|
|
3087
|
+
'range',
|
|
3088
|
+
'color',
|
|
3089
|
+
'file',
|
|
3090
|
+
'image',
|
|
3091
|
+
'button',
|
|
3092
|
+
'submit',
|
|
3093
|
+
'reset'
|
|
3094
|
+
]);
|
|
3095
|
+
let preventScrollCount = 0;
|
|
3096
|
+
let restore;
|
|
3097
|
+
function usePreventScroll(options = {}) {
|
|
3098
|
+
let { isDisabled } = options;
|
|
3099
|
+
useIsomorphicLayoutEffect(()=>{
|
|
3100
|
+
if (isDisabled) return;
|
|
3101
|
+
preventScrollCount++;
|
|
3102
|
+
if (1 === preventScrollCount) {
|
|
3103
|
+
if (isIOS()) restore = preventScrollMobileSafari();
|
|
3104
|
+
}
|
|
3105
|
+
return ()=>{
|
|
3106
|
+
preventScrollCount--;
|
|
3107
|
+
if (0 === preventScrollCount) null == restore || restore();
|
|
3108
|
+
};
|
|
3109
|
+
}, [
|
|
3110
|
+
isDisabled
|
|
3111
|
+
]);
|
|
3112
|
+
}
|
|
3113
|
+
function preventScrollMobileSafari() {
|
|
3114
|
+
let scrollable;
|
|
3115
|
+
let lastY = 0;
|
|
3116
|
+
let onTouchStart = (e)=>{
|
|
3117
|
+
scrollable = getScrollParent(e.target);
|
|
3118
|
+
if (scrollable === document.documentElement && scrollable === document.body) return;
|
|
3119
|
+
lastY = e.changedTouches[0].pageY;
|
|
3120
|
+
};
|
|
3121
|
+
let onTouchMove = (e)=>{
|
|
3122
|
+
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) return void e.preventDefault();
|
|
3123
|
+
let y = e.changedTouches[0].pageY;
|
|
3124
|
+
let scrollTop = scrollable.scrollTop;
|
|
3125
|
+
let bottom = scrollable.scrollHeight - scrollable.clientHeight;
|
|
3126
|
+
if (0 === bottom) return;
|
|
3127
|
+
if (scrollTop <= 0 && y > lastY || scrollTop >= bottom && y < lastY) e.preventDefault();
|
|
3128
|
+
lastY = y;
|
|
3129
|
+
};
|
|
3130
|
+
let onTouchEnd = (e)=>{
|
|
3131
|
+
let target = e.target;
|
|
3132
|
+
if (isInput(target) && target !== document.activeElement) {
|
|
3133
|
+
e.preventDefault();
|
|
3134
|
+
target.style.transform = 'translateY(-2000px)';
|
|
3135
|
+
target.focus();
|
|
3136
|
+
requestAnimationFrame(()=>{
|
|
3137
|
+
target.style.transform = '';
|
|
3138
|
+
});
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3141
|
+
let onFocus = (e)=>{
|
|
3142
|
+
let target = e.target;
|
|
3143
|
+
if (isInput(target)) {
|
|
3144
|
+
target.style.transform = 'translateY(-2000px)';
|
|
3145
|
+
requestAnimationFrame(()=>{
|
|
3146
|
+
target.style.transform = '';
|
|
3147
|
+
if (visualViewport) if (visualViewport.height < window.innerHeight) requestAnimationFrame(()=>{
|
|
3148
|
+
scrollIntoView(target);
|
|
3149
|
+
});
|
|
3150
|
+
else visualViewport.addEventListener('resize', ()=>scrollIntoView(target), {
|
|
3151
|
+
once: true
|
|
3152
|
+
});
|
|
3153
|
+
});
|
|
3154
|
+
}
|
|
3155
|
+
};
|
|
3156
|
+
let onWindowScroll = ()=>{
|
|
3157
|
+
window.scrollTo(0, 0);
|
|
3158
|
+
};
|
|
3159
|
+
let scrollX = window.pageXOffset;
|
|
3160
|
+
let scrollY = window.pageYOffset;
|
|
3161
|
+
let restoreStyles = chain$1(setStyle(document.documentElement, 'paddingRight', `${window.innerWidth - document.documentElement.clientWidth}px`));
|
|
3162
|
+
window.scrollTo(0, 0);
|
|
3163
|
+
let removeEvents = chain$1(addEvent(document, 'touchstart', onTouchStart, {
|
|
3164
|
+
passive: false,
|
|
3165
|
+
capture: true
|
|
3166
|
+
}), addEvent(document, 'touchmove', onTouchMove, {
|
|
3167
|
+
passive: false,
|
|
3168
|
+
capture: true
|
|
3169
|
+
}), addEvent(document, 'touchend', onTouchEnd, {
|
|
3170
|
+
passive: false,
|
|
3171
|
+
capture: true
|
|
3172
|
+
}), addEvent(document, 'focus', onFocus, true), addEvent(window, 'scroll', onWindowScroll));
|
|
3173
|
+
return ()=>{
|
|
3174
|
+
restoreStyles();
|
|
3175
|
+
removeEvents();
|
|
3176
|
+
window.scrollTo(scrollX, scrollY);
|
|
3177
|
+
};
|
|
3178
|
+
}
|
|
3179
|
+
function setStyle(element, style, value) {
|
|
3180
|
+
let cur = element.style[style];
|
|
3181
|
+
element.style[style] = value;
|
|
3182
|
+
return ()=>{
|
|
3183
|
+
element.style[style] = cur;
|
|
3184
|
+
};
|
|
3185
|
+
}
|
|
3186
|
+
function addEvent(target, event, handler, options) {
|
|
3187
|
+
target.addEventListener(event, handler, options);
|
|
3188
|
+
return ()=>{
|
|
3189
|
+
target.removeEventListener(event, handler, options);
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
function scrollIntoView(target) {
|
|
3193
|
+
let root = document.scrollingElement || document.documentElement;
|
|
3194
|
+
while(target && target !== root){
|
|
3195
|
+
let scrollable = getScrollParent(target);
|
|
3196
|
+
if (scrollable !== document.documentElement && scrollable !== document.body && scrollable !== target) {
|
|
3197
|
+
let scrollableTop = scrollable.getBoundingClientRect().top;
|
|
3198
|
+
let targetTop = target.getBoundingClientRect().top;
|
|
3199
|
+
let targetBottom = target.getBoundingClientRect().bottom;
|
|
3200
|
+
const keyboardHeight = scrollable.getBoundingClientRect().bottom + KEYBOARD_BUFFER;
|
|
3201
|
+
if (targetBottom > keyboardHeight) scrollable.scrollTop += targetTop - scrollableTop;
|
|
3202
|
+
}
|
|
3203
|
+
target = scrollable.parentElement;
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
function isInput(target) {
|
|
3207
|
+
return target instanceof HTMLInputElement && !nonTextInputTypes.has(target.type) || target instanceof HTMLTextAreaElement || target instanceof HTMLElement && target.isContentEditable;
|
|
3208
|
+
}
|
|
3209
|
+
function setRef(ref, value) {
|
|
3210
|
+
if ('function' == typeof ref) ref(value);
|
|
3211
|
+
else if (null != ref) ref.current = value;
|
|
3212
|
+
}
|
|
3213
|
+
function composeRefs(...refs) {
|
|
3214
|
+
return (node)=>refs.forEach((ref)=>setRef(ref, node));
|
|
3215
|
+
}
|
|
3216
|
+
function useComposedRefs(...refs) {
|
|
3217
|
+
return react__rspack_import_1.useCallback(composeRefs(...refs), refs);
|
|
3218
|
+
}
|
|
3219
|
+
const cache = new WeakMap();
|
|
3220
|
+
function set(el, styles, ignoreCache = false) {
|
|
3221
|
+
if (!el || !(el instanceof HTMLElement)) return;
|
|
3222
|
+
let originalStyles = {};
|
|
3223
|
+
Object.entries(styles).forEach(([key, value])=>{
|
|
3224
|
+
if (key.startsWith('--')) return void el.style.setProperty(key, value);
|
|
3225
|
+
originalStyles[key] = el.style[key];
|
|
3226
|
+
el.style[key] = value;
|
|
3227
|
+
});
|
|
3228
|
+
if (ignoreCache) return;
|
|
3229
|
+
cache.set(el, originalStyles);
|
|
3230
|
+
}
|
|
3231
|
+
function reset(el, prop) {
|
|
3232
|
+
if (!el || !(el instanceof HTMLElement)) return;
|
|
3233
|
+
let originalStyles = cache.get(el);
|
|
3234
|
+
if (!originalStyles) return;
|
|
3235
|
+
el.style[prop] = originalStyles[prop];
|
|
3236
|
+
}
|
|
3237
|
+
const isVertical = (direction)=>{
|
|
3238
|
+
switch(direction){
|
|
3239
|
+
case 'top':
|
|
3240
|
+
case 'bottom':
|
|
3241
|
+
return true;
|
|
3242
|
+
case 'left':
|
|
3243
|
+
case 'right':
|
|
3244
|
+
return false;
|
|
3245
|
+
default:
|
|
3246
|
+
return direction;
|
|
3247
|
+
}
|
|
3248
|
+
};
|
|
3249
|
+
function getTranslate(element, direction) {
|
|
3250
|
+
if (!element) return null;
|
|
3251
|
+
const style = window.getComputedStyle(element);
|
|
3252
|
+
const transform = style.transform || style.webkitTransform || style.mozTransform;
|
|
3253
|
+
let mat = transform.match(/^matrix3d\((.+)\)$/);
|
|
3254
|
+
if (mat) return parseFloat(mat[1].split(', ')[isVertical(direction) ? 13 : 12]);
|
|
3255
|
+
mat = transform.match(/^matrix\((.+)\)$/);
|
|
3256
|
+
return mat ? parseFloat(mat[1].split(', ')[isVertical(direction) ? 5 : 4]) : null;
|
|
3257
|
+
}
|
|
3258
|
+
function dampenValue(v) {
|
|
3259
|
+
return 8 * (Math.log(v + 1) - 2);
|
|
3260
|
+
}
|
|
3261
|
+
function assignStyle(element, style) {
|
|
3262
|
+
if (!element) return ()=>{};
|
|
3263
|
+
const prevStyle = element.style.cssText;
|
|
3264
|
+
Object.assign(element.style, style);
|
|
3265
|
+
return ()=>{
|
|
3266
|
+
element.style.cssText = prevStyle;
|
|
3267
|
+
};
|
|
3268
|
+
}
|
|
3269
|
+
function chain(...fns) {
|
|
3270
|
+
return (...args)=>{
|
|
3271
|
+
for (const fn of fns)if ('function' == typeof fn) fn(...args);
|
|
3272
|
+
};
|
|
3273
|
+
}
|
|
3274
|
+
const TRANSITIONS = {
|
|
3275
|
+
DURATION: 0.5,
|
|
3276
|
+
EASE: [
|
|
3277
|
+
0.32,
|
|
3278
|
+
0.72,
|
|
3279
|
+
0,
|
|
3280
|
+
1
|
|
3281
|
+
]
|
|
3282
|
+
};
|
|
3283
|
+
const VELOCITY_THRESHOLD = 0.4;
|
|
3284
|
+
const CLOSE_THRESHOLD = 0.25;
|
|
3285
|
+
const SCROLL_LOCK_TIMEOUT = 100;
|
|
3286
|
+
const BORDER_RADIUS = 8;
|
|
3287
|
+
const NESTED_DISPLACEMENT = 16;
|
|
3288
|
+
const WINDOW_TOP_OFFSET = 26;
|
|
3289
|
+
const DRAG_CLASS = 'vaul-dragging';
|
|
3290
|
+
function useCallbackRef(callback) {
|
|
3291
|
+
const callbackRef = react__rspack_import_1["default"].useRef(callback);
|
|
3292
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3293
|
+
callbackRef.current = callback;
|
|
3294
|
+
});
|
|
3295
|
+
return react__rspack_import_1["default"].useMemo(()=>(...args)=>null == callbackRef.current ? void 0 : callbackRef.current.call(callbackRef, ...args), []);
|
|
3296
|
+
}
|
|
3297
|
+
function useUncontrolledState({ defaultProp, onChange }) {
|
|
3298
|
+
const uncontrolledState = react__rspack_import_1["default"].useState(defaultProp);
|
|
3299
|
+
const [value] = uncontrolledState;
|
|
3300
|
+
const prevValueRef = react__rspack_import_1["default"].useRef(value);
|
|
3301
|
+
const handleChange = useCallbackRef(onChange);
|
|
3302
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3303
|
+
if (prevValueRef.current !== value) {
|
|
3304
|
+
handleChange(value);
|
|
3305
|
+
prevValueRef.current = value;
|
|
3306
|
+
}
|
|
3307
|
+
}, [
|
|
3308
|
+
value,
|
|
3309
|
+
prevValueRef,
|
|
3310
|
+
handleChange
|
|
3311
|
+
]);
|
|
3312
|
+
return uncontrolledState;
|
|
3313
|
+
}
|
|
3314
|
+
function useControllableState({ prop, defaultProp, onChange = ()=>{} }) {
|
|
3315
|
+
const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({
|
|
3316
|
+
defaultProp,
|
|
3317
|
+
onChange
|
|
3318
|
+
});
|
|
3319
|
+
const isControlled = void 0 !== prop;
|
|
3320
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
3321
|
+
const handleChange = useCallbackRef(onChange);
|
|
3322
|
+
const setValue = react__rspack_import_1["default"].useCallback((nextValue)=>{
|
|
3323
|
+
if (isControlled) {
|
|
3324
|
+
const setter = nextValue;
|
|
3325
|
+
const value = 'function' == typeof nextValue ? setter(prop) : nextValue;
|
|
3326
|
+
if (value !== prop) handleChange(value);
|
|
3327
|
+
} else setUncontrolledProp(nextValue);
|
|
3328
|
+
}, [
|
|
3329
|
+
isControlled,
|
|
3330
|
+
prop,
|
|
3331
|
+
setUncontrolledProp,
|
|
3332
|
+
handleChange
|
|
3333
|
+
]);
|
|
3334
|
+
return [
|
|
3335
|
+
value,
|
|
3336
|
+
setValue
|
|
3337
|
+
];
|
|
3338
|
+
}
|
|
3339
|
+
function useSnapPoints({ activeSnapPointProp, setActiveSnapPointProp, snapPoints, drawerRef, overlayRef, fadeFromIndex, onSnapPointChange, direction = 'bottom', container, snapToSequentialPoint }) {
|
|
3340
|
+
const [activeSnapPoint, setActiveSnapPoint] = useControllableState({
|
|
3341
|
+
prop: activeSnapPointProp,
|
|
3342
|
+
defaultProp: null == snapPoints ? void 0 : snapPoints[0],
|
|
3343
|
+
onChange: setActiveSnapPointProp
|
|
3344
|
+
});
|
|
3345
|
+
const [windowDimensions, setWindowDimensions] = react__rspack_import_1["default"].useState("u" > typeof window ? {
|
|
3346
|
+
innerWidth: window.innerWidth,
|
|
3347
|
+
innerHeight: window.innerHeight
|
|
3348
|
+
} : void 0);
|
|
3349
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3350
|
+
function onResize() {
|
|
3351
|
+
setWindowDimensions({
|
|
3352
|
+
innerWidth: window.innerWidth,
|
|
3353
|
+
innerHeight: window.innerHeight
|
|
3354
|
+
});
|
|
3355
|
+
}
|
|
3356
|
+
window.addEventListener('resize', onResize);
|
|
3357
|
+
return ()=>window.removeEventListener('resize', onResize);
|
|
3358
|
+
}, []);
|
|
3359
|
+
const isLastSnapPoint = react__rspack_import_1["default"].useMemo(()=>activeSnapPoint === (null == snapPoints ? void 0 : snapPoints[snapPoints.length - 1]) || null, [
|
|
3360
|
+
snapPoints,
|
|
3361
|
+
activeSnapPoint
|
|
3362
|
+
]);
|
|
3363
|
+
const activeSnapPointIndex = react__rspack_import_1["default"].useMemo(()=>{
|
|
3364
|
+
var _snapPoints_findIndex;
|
|
3365
|
+
return null != (_snapPoints_findIndex = null == snapPoints ? void 0 : snapPoints.findIndex((snapPoint)=>snapPoint === activeSnapPoint)) ? _snapPoints_findIndex : null;
|
|
3366
|
+
}, [
|
|
3367
|
+
snapPoints,
|
|
3368
|
+
activeSnapPoint
|
|
3369
|
+
]);
|
|
3370
|
+
const shouldFade = snapPoints && snapPoints.length > 0 && (fadeFromIndex || 0 === fadeFromIndex) && !Number.isNaN(fadeFromIndex) && snapPoints[fadeFromIndex] === activeSnapPoint || !snapPoints;
|
|
3371
|
+
const snapPointsOffset = react__rspack_import_1["default"].useMemo(()=>{
|
|
3372
|
+
const containerSize = container ? {
|
|
3373
|
+
width: container.getBoundingClientRect().width,
|
|
3374
|
+
height: container.getBoundingClientRect().height
|
|
3375
|
+
} : "u" > typeof window ? {
|
|
3376
|
+
width: window.innerWidth,
|
|
3377
|
+
height: window.innerHeight
|
|
3378
|
+
} : {
|
|
3379
|
+
width: 0,
|
|
3380
|
+
height: 0
|
|
3381
|
+
};
|
|
3382
|
+
var _snapPoints_map;
|
|
3383
|
+
return null != (_snapPoints_map = null == snapPoints ? void 0 : snapPoints.map((snapPoint)=>{
|
|
3384
|
+
const isPx = 'string' == typeof snapPoint;
|
|
3385
|
+
let snapPointAsNumber = 0;
|
|
3386
|
+
if (isPx) snapPointAsNumber = parseInt(snapPoint, 10);
|
|
3387
|
+
if (isVertical(direction)) {
|
|
3388
|
+
const height = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.height : 0;
|
|
3389
|
+
if (windowDimensions) return 'bottom' === direction ? containerSize.height - height : -containerSize.height + height;
|
|
3390
|
+
return height;
|
|
3391
|
+
}
|
|
3392
|
+
const width = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.width : 0;
|
|
3393
|
+
if (windowDimensions) return 'right' === direction ? containerSize.width - width : -containerSize.width + width;
|
|
3394
|
+
return width;
|
|
3395
|
+
})) ? _snapPoints_map : [];
|
|
3396
|
+
}, [
|
|
3397
|
+
snapPoints,
|
|
3398
|
+
windowDimensions,
|
|
3399
|
+
container
|
|
3400
|
+
]);
|
|
3401
|
+
const activeSnapPointOffset = react__rspack_import_1["default"].useMemo(()=>null !== activeSnapPointIndex ? null == snapPointsOffset ? void 0 : snapPointsOffset[activeSnapPointIndex] : null, [
|
|
3402
|
+
snapPointsOffset,
|
|
3403
|
+
activeSnapPointIndex
|
|
3404
|
+
]);
|
|
3405
|
+
const snapToPoint = react__rspack_import_1["default"].useCallback((dimension)=>{
|
|
3406
|
+
var _snapPointsOffset_findIndex;
|
|
3407
|
+
const newSnapPointIndex = null != (_snapPointsOffset_findIndex = null == snapPointsOffset ? void 0 : snapPointsOffset.findIndex((snapPointDim)=>snapPointDim === dimension)) ? _snapPointsOffset_findIndex : null;
|
|
3408
|
+
onSnapPointChange(newSnapPointIndex);
|
|
3409
|
+
set(drawerRef.current, {
|
|
3410
|
+
transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
3411
|
+
transform: isVertical(direction) ? `translate3d(0, ${dimension}px, 0)` : `translate3d(${dimension}px, 0, 0)`
|
|
3412
|
+
});
|
|
3413
|
+
snapPointsOffset && newSnapPointIndex !== snapPointsOffset.length - 1 && void 0 !== fadeFromIndex && newSnapPointIndex !== fadeFromIndex && newSnapPointIndex < fadeFromIndex ? set(overlayRef.current, {
|
|
3414
|
+
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
3415
|
+
opacity: '0'
|
|
3416
|
+
}) : set(overlayRef.current, {
|
|
3417
|
+
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
3418
|
+
opacity: '1'
|
|
3419
|
+
});
|
|
3420
|
+
setActiveSnapPoint(null == snapPoints ? void 0 : snapPoints[Math.max(newSnapPointIndex, 0)]);
|
|
3421
|
+
}, [
|
|
3422
|
+
drawerRef.current,
|
|
3423
|
+
snapPoints,
|
|
3424
|
+
snapPointsOffset,
|
|
3425
|
+
fadeFromIndex,
|
|
3426
|
+
overlayRef,
|
|
3427
|
+
setActiveSnapPoint
|
|
3428
|
+
]);
|
|
3429
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3430
|
+
if (activeSnapPoint || activeSnapPointProp) {
|
|
3431
|
+
var _snapPoints_findIndex;
|
|
3432
|
+
const newIndex = null != (_snapPoints_findIndex = null == snapPoints ? void 0 : snapPoints.findIndex((snapPoint)=>snapPoint === activeSnapPointProp || snapPoint === activeSnapPoint)) ? _snapPoints_findIndex : -1;
|
|
3433
|
+
if (snapPointsOffset && -1 !== newIndex && 'number' == typeof snapPointsOffset[newIndex]) snapToPoint(snapPointsOffset[newIndex]);
|
|
3434
|
+
}
|
|
3435
|
+
}, [
|
|
3436
|
+
activeSnapPoint,
|
|
3437
|
+
activeSnapPointProp,
|
|
3438
|
+
snapPoints,
|
|
3439
|
+
snapPointsOffset,
|
|
3440
|
+
snapToPoint
|
|
3441
|
+
]);
|
|
3442
|
+
function onRelease({ draggedDistance, closeDrawer, velocity, dismissible }) {
|
|
3443
|
+
if (void 0 === fadeFromIndex) return;
|
|
3444
|
+
const currentPosition = 'bottom' === direction || 'right' === direction ? (null != activeSnapPointOffset ? activeSnapPointOffset : 0) - draggedDistance : (null != activeSnapPointOffset ? activeSnapPointOffset : 0) + draggedDistance;
|
|
3445
|
+
const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
|
|
3446
|
+
const isFirst = 0 === activeSnapPointIndex;
|
|
3447
|
+
const hasDraggedUp = draggedDistance > 0;
|
|
3448
|
+
if (isOverlaySnapPoint) set(overlayRef.current, {
|
|
3449
|
+
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`
|
|
3450
|
+
});
|
|
3451
|
+
if (!snapToSequentialPoint && velocity > 2 && !hasDraggedUp) {
|
|
3452
|
+
if (dismissible) closeDrawer();
|
|
3453
|
+
else snapToPoint(snapPointsOffset[0]);
|
|
3454
|
+
return;
|
|
3455
|
+
}
|
|
3456
|
+
if (!snapToSequentialPoint && velocity > 2 && hasDraggedUp && snapPointsOffset && snapPoints) return void snapToPoint(snapPointsOffset[snapPoints.length - 1]);
|
|
3457
|
+
const closestSnapPoint = null == snapPointsOffset ? void 0 : snapPointsOffset.reduce((prev, curr)=>{
|
|
3458
|
+
if ('number' != typeof prev || 'number' != typeof curr) return prev;
|
|
3459
|
+
return Math.abs(curr - currentPosition) < Math.abs(prev - currentPosition) ? curr : prev;
|
|
3460
|
+
});
|
|
3461
|
+
const dim = isVertical(direction) ? window.innerHeight : window.innerWidth;
|
|
3462
|
+
if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedDistance) < 0.4 * dim) {
|
|
3463
|
+
const dragDirection = hasDraggedUp ? 1 : -1;
|
|
3464
|
+
if (dragDirection > 0 && isLastSnapPoint && snapPoints) return void snapToPoint(snapPointsOffset[snapPoints.length - 1]);
|
|
3465
|
+
if (isFirst && dragDirection < 0 && dismissible) closeDrawer();
|
|
3466
|
+
if (null === activeSnapPointIndex) return;
|
|
3467
|
+
snapToPoint(snapPointsOffset[activeSnapPointIndex + dragDirection]);
|
|
3468
|
+
return;
|
|
3469
|
+
}
|
|
3470
|
+
snapToPoint(closestSnapPoint);
|
|
3471
|
+
}
|
|
3472
|
+
function onDrag({ draggedDistance }) {
|
|
3473
|
+
if (null === activeSnapPointOffset) return;
|
|
3474
|
+
const newValue = 'bottom' === direction || 'right' === direction ? activeSnapPointOffset - draggedDistance : activeSnapPointOffset + draggedDistance;
|
|
3475
|
+
if (('bottom' === direction || 'right' === direction) && newValue < snapPointsOffset[snapPointsOffset.length - 1]) return;
|
|
3476
|
+
if (('top' === direction || 'left' === direction) && newValue > snapPointsOffset[snapPointsOffset.length - 1]) return;
|
|
3477
|
+
set(drawerRef.current, {
|
|
3478
|
+
transform: isVertical(direction) ? `translate3d(0, ${newValue}px, 0)` : `translate3d(${newValue}px, 0, 0)`
|
|
3479
|
+
});
|
|
3480
|
+
}
|
|
3481
|
+
function getPercentageDragged(absDraggedDistance, isDraggingDown) {
|
|
3482
|
+
if (!snapPoints || 'number' != typeof activeSnapPointIndex || !snapPointsOffset || void 0 === fadeFromIndex) return null;
|
|
3483
|
+
const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
|
|
3484
|
+
const isOverlaySnapPointOrHigher = activeSnapPointIndex >= fadeFromIndex;
|
|
3485
|
+
if (isOverlaySnapPointOrHigher && isDraggingDown) return 0;
|
|
3486
|
+
if (isOverlaySnapPoint && !isDraggingDown) return 1;
|
|
3487
|
+
if (!shouldFade && !isOverlaySnapPoint) return null;
|
|
3488
|
+
const targetSnapPointIndex = isOverlaySnapPoint ? activeSnapPointIndex + 1 : activeSnapPointIndex - 1;
|
|
3489
|
+
const snapPointDistance = isOverlaySnapPoint ? snapPointsOffset[targetSnapPointIndex] - snapPointsOffset[targetSnapPointIndex - 1] : snapPointsOffset[targetSnapPointIndex + 1] - snapPointsOffset[targetSnapPointIndex];
|
|
3490
|
+
const percentageDragged = absDraggedDistance / Math.abs(snapPointDistance);
|
|
3491
|
+
if (isOverlaySnapPoint) return 1 - percentageDragged;
|
|
3492
|
+
return percentageDragged;
|
|
3493
|
+
}
|
|
3494
|
+
return {
|
|
3495
|
+
isLastSnapPoint,
|
|
3496
|
+
activeSnapPoint,
|
|
3497
|
+
shouldFade,
|
|
3498
|
+
getPercentageDragged,
|
|
3499
|
+
setActiveSnapPoint,
|
|
3500
|
+
activeSnapPointIndex,
|
|
3501
|
+
onRelease,
|
|
3502
|
+
onDrag,
|
|
3503
|
+
snapPointsOffset
|
|
3504
|
+
};
|
|
3505
|
+
}
|
|
3506
|
+
const noop = ()=>()=>{};
|
|
3507
|
+
function useScaleBackground() {
|
|
3508
|
+
const { direction, isOpen, shouldScaleBackground, setBackgroundColorOnScale, noBodyStyles } = useDrawerContext();
|
|
3509
|
+
const timeoutIdRef = react__rspack_import_1["default"].useRef(null);
|
|
3510
|
+
const initialBackgroundColor = (0, react__rspack_import_1.useMemo)(()=>document.body.style.backgroundColor, []);
|
|
3511
|
+
function getScale() {
|
|
3512
|
+
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
3513
|
+
}
|
|
3514
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3515
|
+
if (isOpen && shouldScaleBackground) {
|
|
3516
|
+
if (timeoutIdRef.current) clearTimeout(timeoutIdRef.current);
|
|
3517
|
+
const wrapper = document.querySelector('[data-vaul-drawer-wrapper]') || document.querySelector('[vaul-drawer-wrapper]');
|
|
3518
|
+
if (!wrapper) return;
|
|
3519
|
+
chain(setBackgroundColorOnScale && !noBodyStyles ? assignStyle(document.body, {
|
|
3520
|
+
background: 'black'
|
|
3521
|
+
}) : noop, assignStyle(wrapper, {
|
|
3522
|
+
transformOrigin: isVertical(direction) ? 'top' : 'left',
|
|
3523
|
+
transitionProperty: 'transform, border-radius',
|
|
3524
|
+
transitionDuration: `${TRANSITIONS.DURATION}s`,
|
|
3525
|
+
transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(',')})`
|
|
3526
|
+
}));
|
|
3527
|
+
const wrapperStylesCleanup = assignStyle(wrapper, {
|
|
3528
|
+
borderRadius: `${BORDER_RADIUS}px`,
|
|
3529
|
+
overflow: 'hidden',
|
|
3530
|
+
...isVertical(direction) ? {
|
|
3531
|
+
transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`
|
|
3532
|
+
} : {
|
|
3533
|
+
transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`
|
|
3534
|
+
}
|
|
3535
|
+
});
|
|
3536
|
+
return ()=>{
|
|
3537
|
+
wrapperStylesCleanup();
|
|
3538
|
+
timeoutIdRef.current = window.setTimeout(()=>{
|
|
3539
|
+
if (initialBackgroundColor) document.body.style.background = initialBackgroundColor;
|
|
3540
|
+
else document.body.style.removeProperty('background');
|
|
3541
|
+
}, 1000 * TRANSITIONS.DURATION);
|
|
3542
|
+
};
|
|
3543
|
+
}
|
|
3544
|
+
}, [
|
|
3545
|
+
isOpen,
|
|
3546
|
+
shouldScaleBackground,
|
|
3547
|
+
initialBackgroundColor
|
|
3548
|
+
]);
|
|
3549
|
+
}
|
|
3550
|
+
let previousBodyPosition = null;
|
|
3551
|
+
function usePositionFixed({ isOpen, modal, nested, hasBeenOpened, preventScrollRestoration, noBodyStyles }) {
|
|
3552
|
+
const [activeUrl, setActiveUrl] = react__rspack_import_1["default"].useState(()=>"u" > typeof window ? window.location.href : '');
|
|
3553
|
+
const scrollPos = react__rspack_import_1["default"].useRef(0);
|
|
3554
|
+
const setPositionFixed = react__rspack_import_1["default"].useCallback(()=>{
|
|
3555
|
+
if (!isSafari()) return;
|
|
3556
|
+
if (null === previousBodyPosition && isOpen && !noBodyStyles) {
|
|
3557
|
+
previousBodyPosition = {
|
|
3558
|
+
position: document.body.style.position,
|
|
3559
|
+
top: document.body.style.top,
|
|
3560
|
+
left: document.body.style.left,
|
|
3561
|
+
height: document.body.style.height,
|
|
3562
|
+
right: 'unset'
|
|
3563
|
+
};
|
|
3564
|
+
const { scrollX, innerHeight } = window;
|
|
3565
|
+
document.body.style.setProperty('position', 'fixed', 'important');
|
|
3566
|
+
Object.assign(document.body.style, {
|
|
3567
|
+
top: `${-scrollPos.current}px`,
|
|
3568
|
+
left: `${-scrollX}px`,
|
|
3569
|
+
right: '0px',
|
|
3570
|
+
height: 'auto'
|
|
3571
|
+
});
|
|
3572
|
+
window.setTimeout(()=>window.requestAnimationFrame(()=>{
|
|
3573
|
+
const bottomBarHeight = innerHeight - window.innerHeight;
|
|
3574
|
+
if (bottomBarHeight && scrollPos.current >= innerHeight) document.body.style.top = `${-(scrollPos.current + bottomBarHeight)}px`;
|
|
3575
|
+
}), 300);
|
|
3576
|
+
}
|
|
3577
|
+
}, [
|
|
3578
|
+
isOpen
|
|
3579
|
+
]);
|
|
3580
|
+
const restorePositionSetting = react__rspack_import_1["default"].useCallback(()=>{
|
|
3581
|
+
if (!isSafari()) return;
|
|
3582
|
+
if (null !== previousBodyPosition && !noBodyStyles) {
|
|
3583
|
+
const y = -parseInt(document.body.style.top, 10);
|
|
3584
|
+
const x = -parseInt(document.body.style.left, 10);
|
|
3585
|
+
Object.assign(document.body.style, previousBodyPosition);
|
|
3586
|
+
window.requestAnimationFrame(()=>{
|
|
3587
|
+
if (preventScrollRestoration && activeUrl !== window.location.href) return void setActiveUrl(window.location.href);
|
|
3588
|
+
window.scrollTo(x, y);
|
|
3589
|
+
});
|
|
3590
|
+
previousBodyPosition = null;
|
|
3591
|
+
}
|
|
3592
|
+
}, [
|
|
3593
|
+
activeUrl
|
|
3594
|
+
]);
|
|
3595
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3596
|
+
function onScroll() {
|
|
3597
|
+
scrollPos.current = window.scrollY;
|
|
3598
|
+
}
|
|
3599
|
+
onScroll();
|
|
3600
|
+
window.addEventListener('scroll', onScroll);
|
|
3601
|
+
return ()=>{
|
|
3602
|
+
window.removeEventListener('scroll', onScroll);
|
|
3603
|
+
};
|
|
3604
|
+
}, []);
|
|
3605
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3606
|
+
if (!modal) return;
|
|
3607
|
+
return ()=>{
|
|
3608
|
+
if ("u" < typeof document) return;
|
|
3609
|
+
const hasDrawerOpened = !!document.querySelector('[data-vaul-drawer]');
|
|
3610
|
+
if (hasDrawerOpened) return;
|
|
3611
|
+
restorePositionSetting();
|
|
3612
|
+
};
|
|
3613
|
+
}, [
|
|
3614
|
+
modal,
|
|
3615
|
+
restorePositionSetting
|
|
3616
|
+
]);
|
|
3617
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3618
|
+
if (nested || !hasBeenOpened) return;
|
|
3619
|
+
if (isOpen) {
|
|
3620
|
+
const isStandalone = window.matchMedia('(display-mode: standalone)').matches;
|
|
3621
|
+
isStandalone || setPositionFixed();
|
|
3622
|
+
if (!modal) window.setTimeout(()=>{
|
|
3623
|
+
restorePositionSetting();
|
|
3624
|
+
}, 500);
|
|
3625
|
+
} else restorePositionSetting();
|
|
3626
|
+
}, [
|
|
3627
|
+
isOpen,
|
|
3628
|
+
hasBeenOpened,
|
|
3629
|
+
activeUrl,
|
|
3630
|
+
modal,
|
|
3631
|
+
nested,
|
|
3632
|
+
setPositionFixed,
|
|
3633
|
+
restorePositionSetting
|
|
3634
|
+
]);
|
|
3635
|
+
return {
|
|
3636
|
+
restorePositionSetting
|
|
3637
|
+
};
|
|
3638
|
+
}
|
|
3639
|
+
function Root({ 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 }) {
|
|
3640
|
+
var _drawerRef_current, _drawerRef_current1;
|
|
3641
|
+
const [isOpen = false, setIsOpen] = useControllableState({
|
|
3642
|
+
defaultProp: defaultOpen,
|
|
3643
|
+
prop: openProp,
|
|
3644
|
+
onChange: (o)=>{
|
|
3645
|
+
null == onOpenChange || onOpenChange(o);
|
|
3646
|
+
if (!o && !nested) restorePositionSetting();
|
|
3647
|
+
setTimeout(()=>{
|
|
3648
|
+
null == onAnimationEnd || onAnimationEnd(o);
|
|
3649
|
+
}, 1000 * TRANSITIONS.DURATION);
|
|
3650
|
+
if (o && !modal) {
|
|
3651
|
+
if ("u" > typeof window) window.requestAnimationFrame(()=>{
|
|
3652
|
+
document.body.style.pointerEvents = 'auto';
|
|
3653
|
+
});
|
|
3654
|
+
}
|
|
3655
|
+
if (!o) document.body.style.pointerEvents = 'auto';
|
|
3656
|
+
}
|
|
3657
|
+
});
|
|
3658
|
+
const [hasBeenOpened, setHasBeenOpened] = react__rspack_import_1["default"].useState(false);
|
|
3659
|
+
const [isDragging, setIsDragging] = react__rspack_import_1["default"].useState(false);
|
|
3660
|
+
const [justReleased, setJustReleased] = react__rspack_import_1["default"].useState(false);
|
|
3661
|
+
const overlayRef = react__rspack_import_1["default"].useRef(null);
|
|
3662
|
+
const openTime = react__rspack_import_1["default"].useRef(null);
|
|
3663
|
+
const dragStartTime = react__rspack_import_1["default"].useRef(null);
|
|
3664
|
+
const dragEndTime = react__rspack_import_1["default"].useRef(null);
|
|
3665
|
+
const lastTimeDragPrevented = react__rspack_import_1["default"].useRef(null);
|
|
3666
|
+
const isAllowedToDrag = react__rspack_import_1["default"].useRef(false);
|
|
3667
|
+
const nestedOpenChangeTimer = react__rspack_import_1["default"].useRef(null);
|
|
3668
|
+
const pointerStart = react__rspack_import_1["default"].useRef(0);
|
|
3669
|
+
const keyboardIsOpen = react__rspack_import_1["default"].useRef(false);
|
|
3670
|
+
const shouldAnimate = react__rspack_import_1["default"].useRef(!defaultOpen);
|
|
3671
|
+
const previousDiffFromInitial = react__rspack_import_1["default"].useRef(0);
|
|
3672
|
+
const drawerRef = react__rspack_import_1["default"].useRef(null);
|
|
3673
|
+
const drawerHeightRef = react__rspack_import_1["default"].useRef((null == (_drawerRef_current = drawerRef.current) ? void 0 : _drawerRef_current.getBoundingClientRect().height) || 0);
|
|
3674
|
+
const drawerWidthRef = react__rspack_import_1["default"].useRef((null == (_drawerRef_current1 = drawerRef.current) ? void 0 : _drawerRef_current1.getBoundingClientRect().width) || 0);
|
|
3675
|
+
const initialDrawerHeight = react__rspack_import_1["default"].useRef(0);
|
|
3676
|
+
const onSnapPointChange = react__rspack_import_1["default"].useCallback((activeSnapPointIndex)=>{
|
|
3677
|
+
if (snapPoints && activeSnapPointIndex === snapPointsOffset.length - 1) openTime.current = new Date();
|
|
3678
|
+
}, []);
|
|
3679
|
+
const { activeSnapPoint, activeSnapPointIndex, setActiveSnapPoint, onRelease: onReleaseSnapPoints, snapPointsOffset, onDrag: onDragSnapPoints, shouldFade, getPercentageDragged: getSnapPointsPercentageDragged } = useSnapPoints({
|
|
3680
|
+
snapPoints,
|
|
3681
|
+
activeSnapPointProp,
|
|
3682
|
+
setActiveSnapPointProp,
|
|
3683
|
+
drawerRef,
|
|
3684
|
+
fadeFromIndex,
|
|
3685
|
+
overlayRef,
|
|
3686
|
+
onSnapPointChange,
|
|
3687
|
+
direction,
|
|
3688
|
+
container,
|
|
3689
|
+
snapToSequentialPoint
|
|
3690
|
+
});
|
|
3691
|
+
usePreventScroll({
|
|
3692
|
+
isDisabled: !isOpen || isDragging || !modal || justReleased || !hasBeenOpened || !repositionInputs || !disablePreventScroll
|
|
3693
|
+
});
|
|
3694
|
+
const { restorePositionSetting } = usePositionFixed({
|
|
3695
|
+
isOpen,
|
|
3696
|
+
modal,
|
|
3697
|
+
nested: null != nested ? nested : false,
|
|
3698
|
+
hasBeenOpened,
|
|
3699
|
+
preventScrollRestoration,
|
|
3700
|
+
noBodyStyles
|
|
3701
|
+
});
|
|
3702
|
+
function getScale() {
|
|
3703
|
+
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
3704
|
+
}
|
|
3705
|
+
function onPress(event) {
|
|
3706
|
+
var _drawerRef_current, _drawerRef_current1;
|
|
3707
|
+
if (!dismissible && !snapPoints) return;
|
|
3708
|
+
if (drawerRef.current && !drawerRef.current.contains(event.target)) return;
|
|
3709
|
+
drawerHeightRef.current = (null == (_drawerRef_current = drawerRef.current) ? void 0 : _drawerRef_current.getBoundingClientRect().height) || 0;
|
|
3710
|
+
drawerWidthRef.current = (null == (_drawerRef_current1 = drawerRef.current) ? void 0 : _drawerRef_current1.getBoundingClientRect().width) || 0;
|
|
3711
|
+
setIsDragging(true);
|
|
3712
|
+
dragStartTime.current = new Date();
|
|
3713
|
+
if (isIOS()) window.addEventListener('touchend', ()=>isAllowedToDrag.current = false, {
|
|
3714
|
+
once: true
|
|
3715
|
+
});
|
|
3716
|
+
event.target.setPointerCapture(event.pointerId);
|
|
3717
|
+
pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
|
|
3718
|
+
}
|
|
3719
|
+
function shouldDrag(el, isDraggingInDirection) {
|
|
3720
|
+
var _window_getSelection;
|
|
3721
|
+
let element = el;
|
|
3722
|
+
const highlightedText = null == (_window_getSelection = window.getSelection()) ? void 0 : _window_getSelection.toString();
|
|
3723
|
+
const swipeAmount = drawerRef.current ? getTranslate(drawerRef.current, direction) : null;
|
|
3724
|
+
const date = new Date();
|
|
3725
|
+
if ('SELECT' === element.tagName) return false;
|
|
3726
|
+
if (element.hasAttribute('data-vaul-no-drag') || element.closest('[data-vaul-no-drag]')) return false;
|
|
3727
|
+
if ('right' === direction || 'left' === direction) return true;
|
|
3728
|
+
if (openTime.current && date.getTime() - openTime.current.getTime() < 500) return false;
|
|
3729
|
+
if (null !== swipeAmount) {
|
|
3730
|
+
if ('bottom' === direction ? swipeAmount > 0 : swipeAmount < 0) return true;
|
|
3731
|
+
}
|
|
3732
|
+
if (highlightedText && highlightedText.length > 0) return false;
|
|
3733
|
+
if (lastTimeDragPrevented.current && date.getTime() - lastTimeDragPrevented.current.getTime() < scrollLockTimeout && 0 === swipeAmount) {
|
|
3734
|
+
lastTimeDragPrevented.current = date;
|
|
3735
|
+
return false;
|
|
3736
|
+
}
|
|
3737
|
+
if (isDraggingInDirection) {
|
|
3738
|
+
lastTimeDragPrevented.current = date;
|
|
3739
|
+
return false;
|
|
3740
|
+
}
|
|
3741
|
+
while(element){
|
|
3742
|
+
if (element.scrollHeight > element.clientHeight) {
|
|
3743
|
+
if (0 !== element.scrollTop) {
|
|
3744
|
+
lastTimeDragPrevented.current = new Date();
|
|
3745
|
+
return false;
|
|
3746
|
+
}
|
|
3747
|
+
if ('dialog' === element.getAttribute('role')) break;
|
|
3748
|
+
}
|
|
3749
|
+
element = element.parentNode;
|
|
3750
|
+
}
|
|
3751
|
+
return true;
|
|
3752
|
+
}
|
|
3753
|
+
function onDrag(event) {
|
|
3754
|
+
if (!drawerRef.current) return;
|
|
3755
|
+
if (isDragging) {
|
|
3756
|
+
const directionMultiplier = 'bottom' === direction || 'right' === direction ? 1 : -1;
|
|
3757
|
+
const draggedDistance = (pointerStart.current - (isVertical(direction) ? event.pageY : event.pageX)) * directionMultiplier;
|
|
3758
|
+
const isDraggingInDirection = draggedDistance > 0;
|
|
3759
|
+
const noCloseSnapPointsPreCondition = snapPoints && !dismissible && !isDraggingInDirection;
|
|
3760
|
+
if (noCloseSnapPointsPreCondition && 0 === activeSnapPointIndex) return;
|
|
3761
|
+
const absDraggedDistance = Math.abs(draggedDistance);
|
|
3762
|
+
const wrapper = document.querySelector('[data-vaul-drawer-wrapper]');
|
|
3763
|
+
const drawerDimension = 'bottom' === direction || 'top' === direction ? drawerHeightRef.current : drawerWidthRef.current;
|
|
3764
|
+
let percentageDragged = absDraggedDistance / drawerDimension;
|
|
3765
|
+
const snapPointPercentageDragged = getSnapPointsPercentageDragged(absDraggedDistance, isDraggingInDirection);
|
|
3766
|
+
if (null !== snapPointPercentageDragged) percentageDragged = snapPointPercentageDragged;
|
|
3767
|
+
if (noCloseSnapPointsPreCondition && percentageDragged >= 1) return;
|
|
3768
|
+
if (!isAllowedToDrag.current && !shouldDrag(event.target, isDraggingInDirection)) return;
|
|
3769
|
+
drawerRef.current.classList.add(DRAG_CLASS);
|
|
3770
|
+
isAllowedToDrag.current = true;
|
|
3771
|
+
set(drawerRef.current, {
|
|
3772
|
+
transition: 'none'
|
|
3773
|
+
});
|
|
3774
|
+
set(overlayRef.current, {
|
|
3775
|
+
transition: 'none'
|
|
3776
|
+
});
|
|
3777
|
+
if (snapPoints) onDragSnapPoints({
|
|
3778
|
+
draggedDistance
|
|
3779
|
+
});
|
|
3780
|
+
if (isDraggingInDirection && !snapPoints) {
|
|
3781
|
+
const dampenedDraggedDistance = dampenValue(draggedDistance);
|
|
3782
|
+
const translateValue = Math.min(-1 * dampenedDraggedDistance, 0) * directionMultiplier;
|
|
3783
|
+
set(drawerRef.current, {
|
|
3784
|
+
transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
|
|
3785
|
+
});
|
|
3786
|
+
return;
|
|
3787
|
+
}
|
|
3788
|
+
const opacityValue = 1 - percentageDragged;
|
|
3789
|
+
if (shouldFade || fadeFromIndex && activeSnapPointIndex === fadeFromIndex - 1) {
|
|
3790
|
+
null == onDragProp || onDragProp(event, percentageDragged);
|
|
3791
|
+
set(overlayRef.current, {
|
|
3792
|
+
opacity: `${opacityValue}`,
|
|
3793
|
+
transition: 'none'
|
|
3794
|
+
}, true);
|
|
3795
|
+
}
|
|
3796
|
+
if (wrapper && overlayRef.current && shouldScaleBackground) {
|
|
3797
|
+
const scaleValue = Math.min(getScale() + percentageDragged * (1 - getScale()), 1);
|
|
3798
|
+
const borderRadiusValue = 8 - 8 * percentageDragged;
|
|
3799
|
+
const translateValue = Math.max(0, 14 - 14 * percentageDragged);
|
|
3800
|
+
set(wrapper, {
|
|
3801
|
+
borderRadius: `${borderRadiusValue}px`,
|
|
3802
|
+
transform: isVertical(direction) ? `scale(${scaleValue}) translate3d(0, ${translateValue}px, 0)` : `scale(${scaleValue}) translate3d(${translateValue}px, 0, 0)`,
|
|
3803
|
+
transition: 'none'
|
|
3804
|
+
}, true);
|
|
3805
|
+
}
|
|
3806
|
+
if (!snapPoints) {
|
|
3807
|
+
const translateValue = absDraggedDistance * directionMultiplier;
|
|
3808
|
+
set(drawerRef.current, {
|
|
3809
|
+
transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
|
|
3810
|
+
});
|
|
3811
|
+
}
|
|
3812
|
+
}
|
|
3813
|
+
}
|
|
3814
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3815
|
+
window.requestAnimationFrame(()=>{
|
|
3816
|
+
shouldAnimate.current = true;
|
|
3817
|
+
});
|
|
3818
|
+
}, []);
|
|
3819
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3820
|
+
var _window_visualViewport;
|
|
3821
|
+
function onVisualViewportChange() {
|
|
3822
|
+
if (!drawerRef.current || !repositionInputs) return;
|
|
3823
|
+
const focusedElement = document.activeElement;
|
|
3824
|
+
if (isInput(focusedElement) || keyboardIsOpen.current) {
|
|
3825
|
+
var _window_visualViewport;
|
|
3826
|
+
const visualViewportHeight = (null == (_window_visualViewport = window.visualViewport) ? void 0 : _window_visualViewport.height) || 0;
|
|
3827
|
+
const totalHeight = window.innerHeight;
|
|
3828
|
+
let diffFromInitial = totalHeight - visualViewportHeight;
|
|
3829
|
+
const drawerHeight = drawerRef.current.getBoundingClientRect().height || 0;
|
|
3830
|
+
const isTallEnough = drawerHeight > 0.8 * totalHeight;
|
|
3831
|
+
if (!initialDrawerHeight.current) initialDrawerHeight.current = drawerHeight;
|
|
3832
|
+
const offsetFromTop = drawerRef.current.getBoundingClientRect().top;
|
|
3833
|
+
if (Math.abs(previousDiffFromInitial.current - diffFromInitial) > 60) keyboardIsOpen.current = !keyboardIsOpen.current;
|
|
3834
|
+
if (snapPoints && snapPoints.length > 0 && snapPointsOffset && activeSnapPointIndex) {
|
|
3835
|
+
const activeSnapPointHeight = snapPointsOffset[activeSnapPointIndex] || 0;
|
|
3836
|
+
diffFromInitial += activeSnapPointHeight;
|
|
3837
|
+
}
|
|
3838
|
+
previousDiffFromInitial.current = diffFromInitial;
|
|
3839
|
+
if (drawerHeight > visualViewportHeight || keyboardIsOpen.current) {
|
|
3840
|
+
const height = drawerRef.current.getBoundingClientRect().height;
|
|
3841
|
+
let newDrawerHeight = height;
|
|
3842
|
+
if (height > visualViewportHeight) newDrawerHeight = visualViewportHeight - (isTallEnough ? offsetFromTop : WINDOW_TOP_OFFSET);
|
|
3843
|
+
if (fixed) drawerRef.current.style.height = `${height - Math.max(diffFromInitial, 0)}px`;
|
|
3844
|
+
else drawerRef.current.style.height = `${Math.max(newDrawerHeight, visualViewportHeight - offsetFromTop)}px`;
|
|
3845
|
+
} else if (!isMobileFirefox()) drawerRef.current.style.height = `${initialDrawerHeight.current}px`;
|
|
3846
|
+
if (snapPoints && snapPoints.length > 0 && !keyboardIsOpen.current) drawerRef.current.style.bottom = "0px";
|
|
3847
|
+
else drawerRef.current.style.bottom = `${Math.max(diffFromInitial, 0)}px`;
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
null == (_window_visualViewport = window.visualViewport) || _window_visualViewport.addEventListener('resize', onVisualViewportChange);
|
|
3851
|
+
return ()=>{
|
|
3852
|
+
var _window_visualViewport;
|
|
3853
|
+
return null == (_window_visualViewport = window.visualViewport) ? void 0 : _window_visualViewport.removeEventListener('resize', onVisualViewportChange);
|
|
3854
|
+
};
|
|
3855
|
+
}, [
|
|
3856
|
+
activeSnapPointIndex,
|
|
3857
|
+
snapPoints,
|
|
3858
|
+
snapPointsOffset
|
|
3859
|
+
]);
|
|
3860
|
+
function closeDrawer(fromWithin) {
|
|
3861
|
+
cancelDrag();
|
|
3862
|
+
null == onClose || onClose();
|
|
3863
|
+
if (!fromWithin) setIsOpen(false);
|
|
3864
|
+
setTimeout(()=>{
|
|
3865
|
+
if (snapPoints) setActiveSnapPoint(snapPoints[0]);
|
|
3866
|
+
}, 1000 * TRANSITIONS.DURATION);
|
|
3867
|
+
}
|
|
3868
|
+
function resetDrawer() {
|
|
3869
|
+
if (!drawerRef.current) return;
|
|
3870
|
+
const wrapper = document.querySelector('[data-vaul-drawer-wrapper]');
|
|
3871
|
+
const currentSwipeAmount = getTranslate(drawerRef.current, direction);
|
|
3872
|
+
set(drawerRef.current, {
|
|
3873
|
+
transform: 'translate3d(0, 0, 0)',
|
|
3874
|
+
transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`
|
|
3875
|
+
});
|
|
3876
|
+
set(overlayRef.current, {
|
|
3877
|
+
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
3878
|
+
opacity: '1'
|
|
3879
|
+
});
|
|
3880
|
+
if (shouldScaleBackground && currentSwipeAmount && currentSwipeAmount > 0 && isOpen) set(wrapper, {
|
|
3881
|
+
borderRadius: `${BORDER_RADIUS}px`,
|
|
3882
|
+
overflow: 'hidden',
|
|
3883
|
+
...isVertical(direction) ? {
|
|
3884
|
+
transform: `scale(${getScale()}) translate3d(0, calc(env(safe-area-inset-top) + 14px), 0)`,
|
|
3885
|
+
transformOrigin: 'top'
|
|
3886
|
+
} : {
|
|
3887
|
+
transform: `scale(${getScale()}) translate3d(calc(env(safe-area-inset-top) + 14px), 0, 0)`,
|
|
3888
|
+
transformOrigin: 'left'
|
|
3889
|
+
},
|
|
3890
|
+
transitionProperty: 'transform, border-radius',
|
|
3891
|
+
transitionDuration: `${TRANSITIONS.DURATION}s`,
|
|
3892
|
+
transitionTimingFunction: `cubic-bezier(${TRANSITIONS.EASE.join(',')})`
|
|
3893
|
+
}, true);
|
|
3894
|
+
}
|
|
3895
|
+
function cancelDrag() {
|
|
3896
|
+
if (!isDragging || !drawerRef.current) return;
|
|
3897
|
+
drawerRef.current.classList.remove(DRAG_CLASS);
|
|
3898
|
+
isAllowedToDrag.current = false;
|
|
3899
|
+
setIsDragging(false);
|
|
3900
|
+
dragEndTime.current = new Date();
|
|
3901
|
+
}
|
|
3902
|
+
function onRelease(event) {
|
|
3903
|
+
if (!isDragging || !drawerRef.current) return;
|
|
3904
|
+
drawerRef.current.classList.remove(DRAG_CLASS);
|
|
3905
|
+
isAllowedToDrag.current = false;
|
|
3906
|
+
setIsDragging(false);
|
|
3907
|
+
dragEndTime.current = new Date();
|
|
3908
|
+
const swipeAmount = getTranslate(drawerRef.current, direction);
|
|
3909
|
+
if (!event || !shouldDrag(event.target, false) || !swipeAmount || Number.isNaN(swipeAmount)) return;
|
|
3910
|
+
if (null === dragStartTime.current) return;
|
|
3911
|
+
const timeTaken = dragEndTime.current.getTime() - dragStartTime.current.getTime();
|
|
3912
|
+
const distMoved = pointerStart.current - (isVertical(direction) ? event.pageY : event.pageX);
|
|
3913
|
+
const velocity = Math.abs(distMoved) / timeTaken;
|
|
3914
|
+
if (velocity > 0.05) {
|
|
3915
|
+
setJustReleased(true);
|
|
3916
|
+
setTimeout(()=>{
|
|
3917
|
+
setJustReleased(false);
|
|
3918
|
+
}, 200);
|
|
3919
|
+
}
|
|
3920
|
+
if (snapPoints) {
|
|
3921
|
+
const directionMultiplier = 'bottom' === direction || 'right' === direction ? 1 : -1;
|
|
3922
|
+
onReleaseSnapPoints({
|
|
3923
|
+
draggedDistance: distMoved * directionMultiplier,
|
|
3924
|
+
closeDrawer,
|
|
3925
|
+
velocity,
|
|
3926
|
+
dismissible
|
|
3927
|
+
});
|
|
3928
|
+
null == onReleaseProp || onReleaseProp(event, true);
|
|
3929
|
+
return;
|
|
3930
|
+
}
|
|
3931
|
+
if ('bottom' === direction || 'right' === direction ? distMoved > 0 : distMoved < 0) {
|
|
3932
|
+
resetDrawer();
|
|
3933
|
+
null == onReleaseProp || onReleaseProp(event, true);
|
|
3934
|
+
return;
|
|
3935
|
+
}
|
|
3936
|
+
if (velocity > VELOCITY_THRESHOLD) {
|
|
3937
|
+
closeDrawer();
|
|
3938
|
+
null == onReleaseProp || onReleaseProp(event, false);
|
|
3939
|
+
return;
|
|
3940
|
+
}
|
|
3941
|
+
var _drawerRef_current_getBoundingClientRect_height;
|
|
3942
|
+
const visibleDrawerHeight = Math.min(null != (_drawerRef_current_getBoundingClientRect_height = drawerRef.current.getBoundingClientRect().height) ? _drawerRef_current_getBoundingClientRect_height : 0, window.innerHeight);
|
|
3943
|
+
var _drawerRef_current_getBoundingClientRect_width;
|
|
3944
|
+
const visibleDrawerWidth = Math.min(null != (_drawerRef_current_getBoundingClientRect_width = drawerRef.current.getBoundingClientRect().width) ? _drawerRef_current_getBoundingClientRect_width : 0, window.innerWidth);
|
|
3945
|
+
const isHorizontalSwipe = 'left' === direction || 'right' === direction;
|
|
3946
|
+
if (Math.abs(swipeAmount) >= (isHorizontalSwipe ? visibleDrawerWidth : visibleDrawerHeight) * closeThreshold) {
|
|
3947
|
+
closeDrawer();
|
|
3948
|
+
null == onReleaseProp || onReleaseProp(event, false);
|
|
3949
|
+
return;
|
|
3950
|
+
}
|
|
3951
|
+
null == onReleaseProp || onReleaseProp(event, true);
|
|
3952
|
+
resetDrawer();
|
|
3953
|
+
}
|
|
3954
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
3955
|
+
if (isOpen) {
|
|
3956
|
+
set(document.documentElement, {
|
|
3957
|
+
scrollBehavior: 'auto'
|
|
3958
|
+
});
|
|
3959
|
+
openTime.current = new Date();
|
|
3960
|
+
}
|
|
3961
|
+
return ()=>{
|
|
3962
|
+
reset(document.documentElement, 'scrollBehavior');
|
|
3963
|
+
};
|
|
3964
|
+
}, [
|
|
3965
|
+
isOpen
|
|
3966
|
+
]);
|
|
3967
|
+
function onNestedOpenChange(o) {
|
|
3968
|
+
const scale = o ? (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth : 1;
|
|
3969
|
+
const initialTranslate = o ? -NESTED_DISPLACEMENT : 0;
|
|
3970
|
+
if (nestedOpenChangeTimer.current) window.clearTimeout(nestedOpenChangeTimer.current);
|
|
3971
|
+
set(drawerRef.current, {
|
|
3972
|
+
transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
3973
|
+
transform: isVertical(direction) ? `scale(${scale}) translate3d(0, ${initialTranslate}px, 0)` : `scale(${scale}) translate3d(${initialTranslate}px, 0, 0)`
|
|
3974
|
+
});
|
|
3975
|
+
if (!o && drawerRef.current) nestedOpenChangeTimer.current = setTimeout(()=>{
|
|
3976
|
+
const translateValue = getTranslate(drawerRef.current, direction);
|
|
3977
|
+
set(drawerRef.current, {
|
|
3978
|
+
transition: 'none',
|
|
3979
|
+
transform: isVertical(direction) ? `translate3d(0, ${translateValue}px, 0)` : `translate3d(${translateValue}px, 0, 0)`
|
|
3980
|
+
});
|
|
3981
|
+
}, 500);
|
|
3982
|
+
}
|
|
3983
|
+
function onNestedDrag(_event, percentageDragged) {
|
|
3984
|
+
if (percentageDragged < 0) return;
|
|
3985
|
+
const initialScale = (window.innerWidth - NESTED_DISPLACEMENT) / window.innerWidth;
|
|
3986
|
+
const newScale = initialScale + percentageDragged * (1 - initialScale);
|
|
3987
|
+
const newTranslate = -NESTED_DISPLACEMENT + percentageDragged * NESTED_DISPLACEMENT;
|
|
3988
|
+
set(drawerRef.current, {
|
|
3989
|
+
transform: isVertical(direction) ? `scale(${newScale}) translate3d(0, ${newTranslate}px, 0)` : `scale(${newScale}) translate3d(${newTranslate}px, 0, 0)`,
|
|
3990
|
+
transition: 'none'
|
|
3991
|
+
});
|
|
3992
|
+
}
|
|
3993
|
+
function onNestedRelease(_event, o) {
|
|
3994
|
+
const dim = isVertical(direction) ? window.innerHeight : window.innerWidth;
|
|
3995
|
+
const scale = o ? (dim - NESTED_DISPLACEMENT) / dim : 1;
|
|
3996
|
+
const translate = o ? -NESTED_DISPLACEMENT : 0;
|
|
3997
|
+
if (o) set(drawerRef.current, {
|
|
3998
|
+
transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
3999
|
+
transform: isVertical(direction) ? `scale(${scale}) translate3d(0, ${translate}px, 0)` : `scale(${scale}) translate3d(${translate}px, 0, 0)`
|
|
4000
|
+
});
|
|
4001
|
+
}
|
|
4002
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
4003
|
+
if (!modal) window.requestAnimationFrame(()=>{
|
|
4004
|
+
document.body.style.pointerEvents = 'auto';
|
|
4005
|
+
});
|
|
4006
|
+
}, [
|
|
4007
|
+
modal
|
|
4008
|
+
]);
|
|
4009
|
+
return /*#__PURE__*/ react__rspack_import_1["default"].createElement(_radix_ui_react_dialog__rspack_import_0.Root, {
|
|
4010
|
+
defaultOpen: defaultOpen,
|
|
4011
|
+
onOpenChange: (open)=>{
|
|
4012
|
+
if (!dismissible && !open) return;
|
|
4013
|
+
if (open) setHasBeenOpened(true);
|
|
4014
|
+
else closeDrawer(true);
|
|
4015
|
+
setIsOpen(open);
|
|
4016
|
+
},
|
|
4017
|
+
open: isOpen
|
|
4018
|
+
}, /*#__PURE__*/ react__rspack_import_1["default"].createElement(DrawerContext.Provider, {
|
|
4019
|
+
value: {
|
|
4020
|
+
activeSnapPoint,
|
|
4021
|
+
snapPoints,
|
|
4022
|
+
setActiveSnapPoint,
|
|
4023
|
+
drawerRef,
|
|
4024
|
+
overlayRef,
|
|
4025
|
+
onOpenChange,
|
|
4026
|
+
onPress,
|
|
4027
|
+
onRelease,
|
|
4028
|
+
onDrag,
|
|
4029
|
+
dismissible,
|
|
4030
|
+
shouldAnimate,
|
|
4031
|
+
handleOnly,
|
|
4032
|
+
isOpen,
|
|
4033
|
+
isDragging,
|
|
4034
|
+
shouldFade,
|
|
4035
|
+
closeDrawer,
|
|
4036
|
+
onNestedDrag,
|
|
4037
|
+
onNestedOpenChange,
|
|
4038
|
+
onNestedRelease,
|
|
4039
|
+
keyboardIsOpen,
|
|
4040
|
+
modal,
|
|
4041
|
+
snapPointsOffset,
|
|
4042
|
+
activeSnapPointIndex,
|
|
4043
|
+
direction,
|
|
4044
|
+
shouldScaleBackground,
|
|
4045
|
+
setBackgroundColorOnScale,
|
|
4046
|
+
noBodyStyles,
|
|
4047
|
+
container,
|
|
4048
|
+
autoFocus
|
|
4049
|
+
}
|
|
4050
|
+
}, children));
|
|
4051
|
+
}
|
|
4052
|
+
const Overlay = /*#__PURE__*/ react__rspack_import_1["default"].forwardRef(function({ ...rest }, ref) {
|
|
4053
|
+
const { overlayRef, snapPoints, onRelease, shouldFade, isOpen, modal, shouldAnimate } = useDrawerContext();
|
|
4054
|
+
const composedRef = useComposedRefs(ref, overlayRef);
|
|
4055
|
+
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
4056
|
+
if (!modal) return null;
|
|
4057
|
+
const onMouseUp = react__rspack_import_1["default"].useCallback((event)=>onRelease(event), [
|
|
4058
|
+
onRelease
|
|
4059
|
+
]);
|
|
4060
|
+
return /*#__PURE__*/ react__rspack_import_1["default"].createElement(_radix_ui_react_dialog__rspack_import_0.Overlay, {
|
|
4061
|
+
onMouseUp: onMouseUp,
|
|
4062
|
+
ref: composedRef,
|
|
4063
|
+
"data-vaul-overlay": "",
|
|
4064
|
+
"data-vaul-snap-points": isOpen && hasSnapPoints ? 'true' : 'false',
|
|
4065
|
+
"data-vaul-snap-points-overlay": isOpen && shouldFade ? 'true' : 'false',
|
|
4066
|
+
"data-vaul-animate": (null == shouldAnimate ? void 0 : shouldAnimate.current) ? 'true' : 'false',
|
|
4067
|
+
...rest
|
|
4068
|
+
});
|
|
4069
|
+
});
|
|
4070
|
+
Overlay.displayName = 'Drawer.Overlay';
|
|
4071
|
+
const Content = /*#__PURE__*/ react__rspack_import_1["default"].forwardRef(function({ onPointerDownOutside, style, onOpenAutoFocus, ...rest }, ref) {
|
|
4072
|
+
const { drawerRef, onPress, onRelease, onDrag, keyboardIsOpen, snapPointsOffset, activeSnapPointIndex, modal, isOpen, direction, snapPoints, container, handleOnly, shouldAnimate, autoFocus } = useDrawerContext();
|
|
4073
|
+
const [delayedSnapPoints, setDelayedSnapPoints] = react__rspack_import_1["default"].useState(false);
|
|
4074
|
+
const composedRef = useComposedRefs(ref, drawerRef);
|
|
4075
|
+
const pointerStartRef = react__rspack_import_1["default"].useRef(null);
|
|
4076
|
+
const lastKnownPointerEventRef = react__rspack_import_1["default"].useRef(null);
|
|
4077
|
+
const wasBeyondThePointRef = react__rspack_import_1["default"].useRef(false);
|
|
4078
|
+
const hasSnapPoints = snapPoints && snapPoints.length > 0;
|
|
4079
|
+
useScaleBackground();
|
|
4080
|
+
const isDeltaInDirection = (delta, direction, threshold = 0)=>{
|
|
4081
|
+
if (wasBeyondThePointRef.current) return true;
|
|
4082
|
+
const deltaY = Math.abs(delta.y);
|
|
4083
|
+
const deltaX = Math.abs(delta.x);
|
|
4084
|
+
const isDeltaX = deltaX > deltaY;
|
|
4085
|
+
const dFactor = [
|
|
4086
|
+
'bottom',
|
|
4087
|
+
'right'
|
|
4088
|
+
].includes(direction) ? 1 : -1;
|
|
4089
|
+
if ('left' === direction || 'right' === direction) {
|
|
4090
|
+
const isReverseDirection = delta.x * dFactor < 0;
|
|
4091
|
+
if (!isReverseDirection && deltaX >= 0 && deltaX <= threshold) return isDeltaX;
|
|
4092
|
+
} else {
|
|
4093
|
+
const isReverseDirection = delta.y * dFactor < 0;
|
|
4094
|
+
if (!isReverseDirection && deltaY >= 0 && deltaY <= threshold) return !isDeltaX;
|
|
4095
|
+
}
|
|
4096
|
+
wasBeyondThePointRef.current = true;
|
|
4097
|
+
return true;
|
|
4098
|
+
};
|
|
4099
|
+
react__rspack_import_1["default"].useEffect(()=>{
|
|
4100
|
+
if (hasSnapPoints) window.requestAnimationFrame(()=>{
|
|
4101
|
+
setDelayedSnapPoints(true);
|
|
4102
|
+
});
|
|
4103
|
+
}, []);
|
|
4104
|
+
function handleOnPointerUp(event) {
|
|
4105
|
+
pointerStartRef.current = null;
|
|
4106
|
+
wasBeyondThePointRef.current = false;
|
|
4107
|
+
onRelease(event);
|
|
4108
|
+
}
|
|
4109
|
+
return /*#__PURE__*/ react__rspack_import_1["default"].createElement(_radix_ui_react_dialog__rspack_import_0.Content, {
|
|
4110
|
+
"data-vaul-drawer-direction": direction,
|
|
4111
|
+
"data-vaul-drawer": "",
|
|
4112
|
+
"data-vaul-delayed-snap-points": delayedSnapPoints ? 'true' : 'false',
|
|
4113
|
+
"data-vaul-snap-points": isOpen && hasSnapPoints ? 'true' : 'false',
|
|
4114
|
+
"data-vaul-custom-container": container ? 'true' : 'false',
|
|
4115
|
+
"data-vaul-animate": (null == shouldAnimate ? void 0 : shouldAnimate.current) ? 'true' : 'false',
|
|
4116
|
+
...rest,
|
|
4117
|
+
ref: composedRef,
|
|
4118
|
+
style: snapPointsOffset && snapPointsOffset.length > 0 ? {
|
|
4119
|
+
'--snap-point-height': `${snapPointsOffset[null != activeSnapPointIndex ? activeSnapPointIndex : 0]}px`,
|
|
4120
|
+
...style
|
|
4121
|
+
} : style,
|
|
4122
|
+
onPointerDown: (event)=>{
|
|
4123
|
+
if (handleOnly) return;
|
|
4124
|
+
null == rest.onPointerDown || rest.onPointerDown.call(rest, event);
|
|
4125
|
+
pointerStartRef.current = {
|
|
4126
|
+
x: event.pageX,
|
|
4127
|
+
y: event.pageY
|
|
4128
|
+
};
|
|
4129
|
+
onPress(event);
|
|
4130
|
+
},
|
|
4131
|
+
onOpenAutoFocus: (e)=>{
|
|
4132
|
+
null == onOpenAutoFocus || onOpenAutoFocus(e);
|
|
4133
|
+
if (!autoFocus) e.preventDefault();
|
|
4134
|
+
},
|
|
4135
|
+
onPointerDownOutside: (e)=>{
|
|
4136
|
+
null == onPointerDownOutside || onPointerDownOutside(e);
|
|
4137
|
+
if (!modal || e.defaultPrevented) return void e.preventDefault();
|
|
4138
|
+
if (keyboardIsOpen.current) keyboardIsOpen.current = false;
|
|
4139
|
+
},
|
|
4140
|
+
onFocusOutside: (e)=>{
|
|
4141
|
+
if (!modal) return void e.preventDefault();
|
|
4142
|
+
},
|
|
4143
|
+
onPointerMove: (event)=>{
|
|
4144
|
+
lastKnownPointerEventRef.current = event;
|
|
4145
|
+
if (handleOnly) return;
|
|
4146
|
+
null == rest.onPointerMove || rest.onPointerMove.call(rest, event);
|
|
4147
|
+
if (!pointerStartRef.current) return;
|
|
4148
|
+
const yPosition = event.pageY - pointerStartRef.current.y;
|
|
4149
|
+
const xPosition = event.pageX - pointerStartRef.current.x;
|
|
4150
|
+
const swipeStartThreshold = 'touch' === event.pointerType ? 10 : 2;
|
|
4151
|
+
const delta = {
|
|
4152
|
+
x: xPosition,
|
|
4153
|
+
y: yPosition
|
|
4154
|
+
};
|
|
4155
|
+
const isAllowedToSwipe = isDeltaInDirection(delta, direction, swipeStartThreshold);
|
|
4156
|
+
if (isAllowedToSwipe) onDrag(event);
|
|
4157
|
+
else if (Math.abs(xPosition) > swipeStartThreshold || Math.abs(yPosition) > swipeStartThreshold) pointerStartRef.current = null;
|
|
4158
|
+
},
|
|
4159
|
+
onPointerUp: (event)=>{
|
|
4160
|
+
null == rest.onPointerUp || rest.onPointerUp.call(rest, event);
|
|
4161
|
+
pointerStartRef.current = null;
|
|
4162
|
+
wasBeyondThePointRef.current = false;
|
|
4163
|
+
onRelease(event);
|
|
4164
|
+
},
|
|
4165
|
+
onPointerOut: (event)=>{
|
|
4166
|
+
null == rest.onPointerOut || rest.onPointerOut.call(rest, event);
|
|
4167
|
+
handleOnPointerUp(lastKnownPointerEventRef.current);
|
|
4168
|
+
},
|
|
4169
|
+
onContextMenu: (event)=>{
|
|
4170
|
+
null == rest.onContextMenu || rest.onContextMenu.call(rest, event);
|
|
4171
|
+
if (lastKnownPointerEventRef.current) handleOnPointerUp(lastKnownPointerEventRef.current);
|
|
4172
|
+
}
|
|
4173
|
+
});
|
|
4174
|
+
});
|
|
4175
|
+
Content.displayName = 'Drawer.Content';
|
|
4176
|
+
const LONG_HANDLE_PRESS_TIMEOUT = 250;
|
|
4177
|
+
const DOUBLE_TAP_TIMEOUT = 120;
|
|
4178
|
+
const Handle = /*#__PURE__*/ react__rspack_import_1["default"].forwardRef(function({ preventCycle = false, children, ...rest }, ref) {
|
|
4179
|
+
const { closeDrawer, isDragging, snapPoints, activeSnapPoint, setActiveSnapPoint, dismissible, handleOnly, isOpen, onPress, onDrag } = useDrawerContext();
|
|
4180
|
+
const closeTimeoutIdRef = react__rspack_import_1["default"].useRef(null);
|
|
4181
|
+
const shouldCancelInteractionRef = react__rspack_import_1["default"].useRef(false);
|
|
4182
|
+
function handleStartCycle() {
|
|
4183
|
+
if (shouldCancelInteractionRef.current) return void handleCancelInteraction();
|
|
4184
|
+
window.setTimeout(()=>{
|
|
4185
|
+
handleCycleSnapPoints();
|
|
4186
|
+
}, DOUBLE_TAP_TIMEOUT);
|
|
4187
|
+
}
|
|
4188
|
+
function handleCycleSnapPoints() {
|
|
4189
|
+
if (isDragging || preventCycle || shouldCancelInteractionRef.current) return void handleCancelInteraction();
|
|
4190
|
+
handleCancelInteraction();
|
|
4191
|
+
if (!snapPoints || 0 === snapPoints.length) {
|
|
4192
|
+
if (!dismissible) closeDrawer();
|
|
4193
|
+
return;
|
|
4194
|
+
}
|
|
4195
|
+
const isLastSnapPoint = activeSnapPoint === snapPoints[snapPoints.length - 1];
|
|
4196
|
+
if (isLastSnapPoint && dismissible) return void closeDrawer();
|
|
4197
|
+
const currentSnapIndex = snapPoints.findIndex((point)=>point === activeSnapPoint);
|
|
4198
|
+
if (-1 === currentSnapIndex) return;
|
|
4199
|
+
const nextSnapPoint = snapPoints[currentSnapIndex + 1];
|
|
4200
|
+
setActiveSnapPoint(nextSnapPoint);
|
|
4201
|
+
}
|
|
4202
|
+
function handleStartInteraction() {
|
|
4203
|
+
closeTimeoutIdRef.current = window.setTimeout(()=>{
|
|
4204
|
+
shouldCancelInteractionRef.current = true;
|
|
4205
|
+
}, LONG_HANDLE_PRESS_TIMEOUT);
|
|
4206
|
+
}
|
|
4207
|
+
function handleCancelInteraction() {
|
|
4208
|
+
if (closeTimeoutIdRef.current) window.clearTimeout(closeTimeoutIdRef.current);
|
|
4209
|
+
shouldCancelInteractionRef.current = false;
|
|
4210
|
+
}
|
|
4211
|
+
return /*#__PURE__*/ react__rspack_import_1["default"].createElement("div", {
|
|
4212
|
+
onClick: handleStartCycle,
|
|
4213
|
+
onPointerCancel: handleCancelInteraction,
|
|
4214
|
+
onPointerDown: (e)=>{
|
|
4215
|
+
if (handleOnly) onPress(e);
|
|
4216
|
+
handleStartInteraction();
|
|
4217
|
+
},
|
|
4218
|
+
onPointerMove: (e)=>{
|
|
4219
|
+
if (handleOnly) onDrag(e);
|
|
4220
|
+
},
|
|
4221
|
+
ref: ref,
|
|
4222
|
+
"data-vaul-drawer-visible": isOpen ? 'true' : 'false',
|
|
4223
|
+
"data-vaul-handle": "",
|
|
4224
|
+
"aria-hidden": "true",
|
|
4225
|
+
...rest
|
|
4226
|
+
}, /*#__PURE__*/ react__rspack_import_1["default"].createElement("span", {
|
|
4227
|
+
"data-vaul-handle-hitarea": "",
|
|
4228
|
+
"aria-hidden": "true"
|
|
4229
|
+
}, children));
|
|
4230
|
+
});
|
|
4231
|
+
Handle.displayName = 'Drawer.Handle';
|
|
4232
|
+
function NestedRoot({ onDrag, onOpenChange, open: nestedIsOpen, ...rest }) {
|
|
4233
|
+
const { onNestedDrag, onNestedOpenChange, onNestedRelease } = useDrawerContext();
|
|
4234
|
+
if (!onNestedDrag) throw new Error('Drawer.NestedRoot must be placed in another drawer');
|
|
4235
|
+
return /*#__PURE__*/ react__rspack_import_1["default"].createElement(Root, {
|
|
4236
|
+
nested: true,
|
|
4237
|
+
open: nestedIsOpen,
|
|
4238
|
+
onClose: ()=>{
|
|
4239
|
+
onNestedOpenChange(false);
|
|
4240
|
+
},
|
|
4241
|
+
onDrag: (e, p)=>{
|
|
4242
|
+
onNestedDrag(e, p);
|
|
4243
|
+
null == onDrag || onDrag(e, p);
|
|
4244
|
+
},
|
|
4245
|
+
onOpenChange: (o)=>{
|
|
4246
|
+
if (o) onNestedOpenChange(o);
|
|
4247
|
+
null == onOpenChange || onOpenChange(o);
|
|
4248
|
+
},
|
|
4249
|
+
onRelease: onNestedRelease,
|
|
4250
|
+
...rest
|
|
4251
|
+
});
|
|
4252
|
+
}
|
|
4253
|
+
function Portal(props) {
|
|
4254
|
+
const context = useDrawerContext();
|
|
4255
|
+
const { container = context.container, ...portalProps } = props;
|
|
4256
|
+
return /*#__PURE__*/ react__rspack_import_1["default"].createElement(_radix_ui_react_dialog__rspack_import_0.Portal, {
|
|
4257
|
+
container: container,
|
|
4258
|
+
...portalProps
|
|
4259
|
+
});
|
|
4260
|
+
}
|
|
4261
|
+
const Drawer = {
|
|
4262
|
+
Root,
|
|
4263
|
+
NestedRoot,
|
|
4264
|
+
Content,
|
|
4265
|
+
Overlay,
|
|
4266
|
+
Trigger: _radix_ui_react_dialog__rspack_import_0.Trigger,
|
|
4267
|
+
Portal,
|
|
4268
|
+
Handle,
|
|
4269
|
+
Close: _radix_ui_react_dialog__rspack_import_0.Close,
|
|
4270
|
+
Title: _radix_ui_react_dialog__rspack_import_0.Title,
|
|
4271
|
+
Description: _radix_ui_react_dialog__rspack_import_0.Description
|
|
4272
|
+
};
|
|
4273
|
+
}
|
|
4274
|
+
};
|