@cloudparse/up-miniapps-sdk 0.6.3 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.min.js +27 -27
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +294 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -2
- package/dist/index.d.ts +30 -2
- package/dist/index.js +290 -39
- package/dist/index.js.map +1 -1
- package/dist/style.css +3 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,7 @@ __export(src_exports, {
|
|
|
44
44
|
MapMenuTitle: () => MapMenuTitle,
|
|
45
45
|
MiniAppSDK: () => MiniAppSDK,
|
|
46
46
|
MockLocationContext: () => MockLocationContext,
|
|
47
|
+
PullToRefresh: () => PullToRefresh,
|
|
47
48
|
QRScanner: () => QRScanner,
|
|
48
49
|
RouteLayer: () => RouteLayer,
|
|
49
50
|
SDKMapProvider: () => SDKMapProvider,
|
|
@@ -3375,7 +3376,7 @@ async function generateQrCode(data, options = {}) {
|
|
|
3375
3376
|
const size = options.size ?? DEFAULT_SIZE;
|
|
3376
3377
|
const color = options.color ?? DEFAULT_COLOR;
|
|
3377
3378
|
const backgroundColor = options.backgroundColor ?? DEFAULT_BACKGROUND;
|
|
3378
|
-
const label = options.label || (options.appName ?
|
|
3379
|
+
const label = options.label || (options.appName ? `${options.appName} by UP` : "");
|
|
3379
3380
|
const qr = new import_qr_code_styling.default({
|
|
3380
3381
|
backgroundOptions: {
|
|
3381
3382
|
color: backgroundColor,
|
|
@@ -3714,7 +3715,7 @@ var RoutingService = {
|
|
|
3714
3715
|
};
|
|
3715
3716
|
|
|
3716
3717
|
// package.json
|
|
3717
|
-
var version = "0.6.
|
|
3718
|
+
var version = "0.6.6";
|
|
3718
3719
|
|
|
3719
3720
|
// src/sdk.ts
|
|
3720
3721
|
function deepFreeze(obj) {
|
|
@@ -4860,18 +4861,268 @@ var DebugConsole = ({
|
|
|
4860
4861
|
] });
|
|
4861
4862
|
};
|
|
4862
4863
|
|
|
4863
|
-
// src/components/
|
|
4864
|
-
var import_jsqr2 = __toESM(require("jsqr"), 1);
|
|
4864
|
+
// src/components/PullToRefresh.tsx
|
|
4865
4865
|
var import_react16 = require("react");
|
|
4866
4866
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4867
|
+
var DEFAULT_PULL_THRESHOLD = 64;
|
|
4868
|
+
var DEFAULT_MAX_PULL = 96;
|
|
4869
|
+
var RESISTANCE = 0.5;
|
|
4870
|
+
var DRAG_DEADZONE = 8;
|
|
4871
|
+
var FLING_FRICTION = 0.95;
|
|
4872
|
+
var FLING_MIN_VELOCITY = 0.02;
|
|
4873
|
+
function DefaultIndicator({ progress, isRefreshing }) {
|
|
4874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
4875
|
+
"div",
|
|
4876
|
+
{
|
|
4877
|
+
style: {
|
|
4878
|
+
alignItems: "center",
|
|
4879
|
+
background: "rgba(24, 24, 27, 0.9)",
|
|
4880
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
4881
|
+
borderRadius: 9999,
|
|
4882
|
+
boxShadow: "0 4px 16px -4px rgba(0, 0, 0, 0.5)",
|
|
4883
|
+
display: "flex",
|
|
4884
|
+
height: 28,
|
|
4885
|
+
justifyContent: "center",
|
|
4886
|
+
width: 28
|
|
4887
|
+
},
|
|
4888
|
+
children: [
|
|
4889
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
4890
|
+
"svg",
|
|
4891
|
+
{
|
|
4892
|
+
height: 14,
|
|
4893
|
+
style: {
|
|
4894
|
+
animation: isRefreshing ? "up-sdk-ptr-spin 0.8s linear infinite" : void 0,
|
|
4895
|
+
color: isRefreshing ? "#a78bfa" : "#a1a1aa",
|
|
4896
|
+
transform: isRefreshing ? void 0 : `rotate(${progress * 360}deg)`
|
|
4897
|
+
},
|
|
4898
|
+
viewBox: "0 0 24 24",
|
|
4899
|
+
width: 14,
|
|
4900
|
+
children: [
|
|
4901
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("title", { children: "Refreshing" }),
|
|
4902
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4903
|
+
"path",
|
|
4904
|
+
{
|
|
4905
|
+
d: "M21 12a9 9 0 1 1-2.64-6.36",
|
|
4906
|
+
fill: "none",
|
|
4907
|
+
stroke: "currentColor",
|
|
4908
|
+
strokeLinecap: "round",
|
|
4909
|
+
strokeWidth: 2.5
|
|
4910
|
+
}
|
|
4911
|
+
)
|
|
4912
|
+
]
|
|
4913
|
+
}
|
|
4914
|
+
),
|
|
4915
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("style", { children: "@keyframes up-sdk-ptr-spin { to { transform: rotate(360deg); } }" })
|
|
4916
|
+
]
|
|
4917
|
+
}
|
|
4918
|
+
);
|
|
4919
|
+
}
|
|
4920
|
+
var PullToRefresh = ({
|
|
4921
|
+
onRefresh,
|
|
4922
|
+
children,
|
|
4923
|
+
className = "",
|
|
4924
|
+
disabled = false,
|
|
4925
|
+
pullThreshold = DEFAULT_PULL_THRESHOLD,
|
|
4926
|
+
maxPull = DEFAULT_MAX_PULL,
|
|
4927
|
+
renderIndicator
|
|
4928
|
+
}) => {
|
|
4929
|
+
const containerRef = (0, import_react16.useRef)(null);
|
|
4930
|
+
const startYRef = (0, import_react16.useRef)(null);
|
|
4931
|
+
const lastYRef = (0, import_react16.useRef)(0);
|
|
4932
|
+
const lastMoveTimeRef = (0, import_react16.useRef)(0);
|
|
4933
|
+
const velocityRef = (0, import_react16.useRef)(0);
|
|
4934
|
+
const pointerIdRef = (0, import_react16.useRef)(null);
|
|
4935
|
+
const isPullingRef = (0, import_react16.useRef)(false);
|
|
4936
|
+
const pullDistanceRef = (0, import_react16.useRef)(0);
|
|
4937
|
+
const flingRafRef = (0, import_react16.useRef)(null);
|
|
4938
|
+
const [pullDistance, setPullDistance] = (0, import_react16.useState)(0);
|
|
4939
|
+
const [isRefreshing, setIsRefreshing] = (0, import_react16.useState)(false);
|
|
4940
|
+
const [isTracking, setIsTracking] = (0, import_react16.useState)(false);
|
|
4941
|
+
const disabledRef = (0, import_react16.useRef)(disabled);
|
|
4942
|
+
disabledRef.current = disabled;
|
|
4943
|
+
const onRefreshRef = (0, import_react16.useRef)(onRefresh);
|
|
4944
|
+
onRefreshRef.current = onRefresh;
|
|
4945
|
+
const pullThresholdRef = (0, import_react16.useRef)(pullThreshold);
|
|
4946
|
+
pullThresholdRef.current = pullThreshold;
|
|
4947
|
+
const maxPullRef = (0, import_react16.useRef)(maxPull);
|
|
4948
|
+
maxPullRef.current = maxPull;
|
|
4874
4949
|
(0, import_react16.useEffect)(() => {
|
|
4950
|
+
const el = containerRef.current;
|
|
4951
|
+
if (!el) return;
|
|
4952
|
+
const updatePullDistance = (value) => {
|
|
4953
|
+
pullDistanceRef.current = value;
|
|
4954
|
+
setPullDistance(value);
|
|
4955
|
+
};
|
|
4956
|
+
const stopFling = () => {
|
|
4957
|
+
if (flingRafRef.current !== null) {
|
|
4958
|
+
cancelAnimationFrame(flingRafRef.current);
|
|
4959
|
+
flingRafRef.current = null;
|
|
4960
|
+
}
|
|
4961
|
+
};
|
|
4962
|
+
const resetTracking = () => {
|
|
4963
|
+
pointerIdRef.current = null;
|
|
4964
|
+
startYRef.current = null;
|
|
4965
|
+
isPullingRef.current = false;
|
|
4966
|
+
setIsTracking(false);
|
|
4967
|
+
updatePullDistance(0);
|
|
4968
|
+
};
|
|
4969
|
+
const runFling = () => {
|
|
4970
|
+
velocityRef.current *= FLING_FRICTION;
|
|
4971
|
+
if (Math.abs(velocityRef.current) < FLING_MIN_VELOCITY) {
|
|
4972
|
+
flingRafRef.current = null;
|
|
4973
|
+
return;
|
|
4974
|
+
}
|
|
4975
|
+
el.scrollTop -= velocityRef.current * 16;
|
|
4976
|
+
if (el.scrollTop <= 0 || el.scrollTop >= el.scrollHeight - el.clientHeight) {
|
|
4977
|
+
flingRafRef.current = null;
|
|
4978
|
+
return;
|
|
4979
|
+
}
|
|
4980
|
+
flingRafRef.current = requestAnimationFrame(runFling);
|
|
4981
|
+
};
|
|
4982
|
+
const handlePointerDown = (e) => {
|
|
4983
|
+
if (disabledRef.current) return;
|
|
4984
|
+
if (pointerIdRef.current !== null) return;
|
|
4985
|
+
stopFling();
|
|
4986
|
+
pointerIdRef.current = e.pointerId;
|
|
4987
|
+
startYRef.current = e.clientY;
|
|
4988
|
+
lastYRef.current = e.clientY;
|
|
4989
|
+
lastMoveTimeRef.current = performance.now();
|
|
4990
|
+
velocityRef.current = 0;
|
|
4991
|
+
isPullingRef.current = false;
|
|
4992
|
+
setIsTracking(true);
|
|
4993
|
+
try {
|
|
4994
|
+
el.setPointerCapture(e.pointerId);
|
|
4995
|
+
} catch {
|
|
4996
|
+
}
|
|
4997
|
+
};
|
|
4998
|
+
const handlePointerMove = (e) => {
|
|
4999
|
+
if (startYRef.current === null || e.pointerId !== pointerIdRef.current) {
|
|
5000
|
+
return;
|
|
5001
|
+
}
|
|
5002
|
+
const totalDelta = e.clientY - startYRef.current;
|
|
5003
|
+
if (!isPullingRef.current && Math.abs(totalDelta) < DRAG_DEADZONE) {
|
|
5004
|
+
return;
|
|
5005
|
+
}
|
|
5006
|
+
const now = performance.now();
|
|
5007
|
+
const stepDelta = e.clientY - lastYRef.current;
|
|
5008
|
+
const dt = Math.max(now - lastMoveTimeRef.current, 1);
|
|
5009
|
+
velocityRef.current = stepDelta / dt;
|
|
5010
|
+
lastYRef.current = e.clientY;
|
|
5011
|
+
lastMoveTimeRef.current = now;
|
|
5012
|
+
if (e.cancelable) e.preventDefault();
|
|
5013
|
+
const atTop = el.scrollTop <= 0;
|
|
5014
|
+
if (atTop && totalDelta > 0) {
|
|
5015
|
+
isPullingRef.current = true;
|
|
5016
|
+
updatePullDistance(
|
|
5017
|
+
Math.min(
|
|
5018
|
+
Math.max(totalDelta - DRAG_DEADZONE, 0) * RESISTANCE,
|
|
5019
|
+
maxPullRef.current
|
|
5020
|
+
)
|
|
5021
|
+
);
|
|
5022
|
+
return;
|
|
5023
|
+
}
|
|
5024
|
+
if (isPullingRef.current) {
|
|
5025
|
+
isPullingRef.current = false;
|
|
5026
|
+
updatePullDistance(0);
|
|
5027
|
+
}
|
|
5028
|
+
el.scrollTop -= stepDelta;
|
|
5029
|
+
};
|
|
5030
|
+
const handlePointerEnd = (e) => {
|
|
5031
|
+
if (startYRef.current === null || e.pointerId !== pointerIdRef.current) {
|
|
5032
|
+
return;
|
|
5033
|
+
}
|
|
5034
|
+
const wasPulling = isPullingRef.current;
|
|
5035
|
+
pointerIdRef.current = null;
|
|
5036
|
+
startYRef.current = null;
|
|
5037
|
+
isPullingRef.current = false;
|
|
5038
|
+
setIsTracking(false);
|
|
5039
|
+
if (!wasPulling) {
|
|
5040
|
+
if (Math.abs(velocityRef.current) > FLING_MIN_VELOCITY) {
|
|
5041
|
+
stopFling();
|
|
5042
|
+
flingRafRef.current = requestAnimationFrame(runFling);
|
|
5043
|
+
}
|
|
5044
|
+
return;
|
|
5045
|
+
}
|
|
5046
|
+
const shouldRefresh = pullDistanceRef.current >= pullThresholdRef.current;
|
|
5047
|
+
if (!shouldRefresh) {
|
|
5048
|
+
updatePullDistance(0);
|
|
5049
|
+
return;
|
|
5050
|
+
}
|
|
5051
|
+
setIsRefreshing(true);
|
|
5052
|
+
updatePullDistance(pullThresholdRef.current);
|
|
5053
|
+
Promise.resolve(onRefreshRef.current()).catch((err) => {
|
|
5054
|
+
console.error("Pull-to-refresh failed:", err);
|
|
5055
|
+
}).finally(() => {
|
|
5056
|
+
setIsRefreshing(false);
|
|
5057
|
+
updatePullDistance(0);
|
|
5058
|
+
});
|
|
5059
|
+
};
|
|
5060
|
+
const handlePointerCancel = (e) => {
|
|
5061
|
+
if (e.pointerId !== pointerIdRef.current) return;
|
|
5062
|
+
stopFling();
|
|
5063
|
+
resetTracking();
|
|
5064
|
+
};
|
|
5065
|
+
el.addEventListener("pointerdown", handlePointerDown);
|
|
5066
|
+
el.addEventListener("pointermove", handlePointerMove, { passive: false });
|
|
5067
|
+
el.addEventListener("pointerup", handlePointerEnd);
|
|
5068
|
+
el.addEventListener("pointercancel", handlePointerCancel);
|
|
5069
|
+
return () => {
|
|
5070
|
+
stopFling();
|
|
5071
|
+
el.removeEventListener("pointerdown", handlePointerDown);
|
|
5072
|
+
el.removeEventListener("pointermove", handlePointerMove);
|
|
5073
|
+
el.removeEventListener("pointerup", handlePointerEnd);
|
|
5074
|
+
el.removeEventListener("pointercancel", handlePointerCancel);
|
|
5075
|
+
};
|
|
5076
|
+
}, []);
|
|
5077
|
+
const indicatorHeight = isRefreshing ? pullThreshold : pullDistance;
|
|
5078
|
+
const progress = Math.min(indicatorHeight / pullThreshold, 1);
|
|
5079
|
+
const isSettling = pullDistance === 0 && !isRefreshing && !isTracking;
|
|
5080
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
5081
|
+
"div",
|
|
5082
|
+
{
|
|
5083
|
+
className: `up-sdk-pull-to-refresh ${className}`,
|
|
5084
|
+
ref: containerRef,
|
|
5085
|
+
style: {
|
|
5086
|
+
overflowY: "auto",
|
|
5087
|
+
overscrollBehavior: "none",
|
|
5088
|
+
touchAction: "none"
|
|
5089
|
+
},
|
|
5090
|
+
children: [
|
|
5091
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("style", { children: ".up-sdk-pull-to-refresh::-webkit-scrollbar { display: none; } .up-sdk-pull-to-refresh { scrollbar-width: none; -ms-overflow-style: none; }" }),
|
|
5092
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
5093
|
+
"div",
|
|
5094
|
+
{
|
|
5095
|
+
style: {
|
|
5096
|
+
alignItems: "center",
|
|
5097
|
+
display: "flex",
|
|
5098
|
+
height: indicatorHeight,
|
|
5099
|
+
justifyContent: "center",
|
|
5100
|
+
overflow: "hidden",
|
|
5101
|
+
transition: isSettling ? "height 0.2s ease-out" : "none",
|
|
5102
|
+
userSelect: "none",
|
|
5103
|
+
width: "100%"
|
|
5104
|
+
},
|
|
5105
|
+
children: renderIndicator ? renderIndicator({ isRefreshing, progress }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DefaultIndicator, { isRefreshing, progress })
|
|
5106
|
+
}
|
|
5107
|
+
),
|
|
5108
|
+
children
|
|
5109
|
+
]
|
|
5110
|
+
}
|
|
5111
|
+
);
|
|
5112
|
+
};
|
|
5113
|
+
|
|
5114
|
+
// src/components/QRScanner.tsx
|
|
5115
|
+
var import_jsqr2 = __toESM(require("jsqr"), 1);
|
|
5116
|
+
var import_react17 = require("react");
|
|
5117
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
5118
|
+
function QRScanner({ onScan, onError, className = "" }) {
|
|
5119
|
+
const videoRef = (0, import_react17.useRef)(null);
|
|
5120
|
+
const canvasRef = (0, import_react17.useRef)(null);
|
|
5121
|
+
const streamRef = (0, import_react17.useRef)(null);
|
|
5122
|
+
const tickRequestRef = (0, import_react17.useRef)(null);
|
|
5123
|
+
const hasScannedRef = (0, import_react17.useRef)(false);
|
|
5124
|
+
const [isReady, setIsReady] = (0, import_react17.useState)(false);
|
|
5125
|
+
(0, import_react17.useEffect)(() => {
|
|
4875
5126
|
let cancelled = false;
|
|
4876
5127
|
hasScannedRef.current = false;
|
|
4877
5128
|
const cleanup = () => {
|
|
@@ -4954,7 +5205,7 @@ function QRScanner({ onScan, onError, className = "" }) {
|
|
|
4954
5205
|
cleanup();
|
|
4955
5206
|
};
|
|
4956
5207
|
}, []);
|
|
4957
|
-
return /* @__PURE__ */ (0,
|
|
5208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
4958
5209
|
"div",
|
|
4959
5210
|
{
|
|
4960
5211
|
className,
|
|
@@ -4966,7 +5217,7 @@ function QRScanner({ onScan, onError, className = "" }) {
|
|
|
4966
5217
|
position: "relative"
|
|
4967
5218
|
},
|
|
4968
5219
|
children: [
|
|
4969
|
-
/* @__PURE__ */ (0,
|
|
5220
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4970
5221
|
"video",
|
|
4971
5222
|
{
|
|
4972
5223
|
playsInline: true,
|
|
@@ -4974,8 +5225,8 @@ function QRScanner({ onScan, onError, className = "" }) {
|
|
|
4974
5225
|
style: { height: "100%", objectFit: "cover", width: "100%" }
|
|
4975
5226
|
}
|
|
4976
5227
|
),
|
|
4977
|
-
/* @__PURE__ */ (0,
|
|
4978
|
-
isReady && /* @__PURE__ */ (0,
|
|
5228
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("canvas", { ref: canvasRef, style: { display: "none" } }),
|
|
5229
|
+
isReady && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
4979
5230
|
"div",
|
|
4980
5231
|
{
|
|
4981
5232
|
style: {
|
|
@@ -4996,30 +5247,30 @@ function QRScanner({ onScan, onError, className = "" }) {
|
|
|
4996
5247
|
}
|
|
4997
5248
|
|
|
4998
5249
|
// src/components/SDKProvider.tsx
|
|
4999
|
-
var
|
|
5000
|
-
var
|
|
5001
|
-
var SDKContext = (0,
|
|
5002
|
-
var useIsMocked = () => (0,
|
|
5250
|
+
var import_react18 = require("react");
|
|
5251
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
5252
|
+
var SDKContext = (0, import_react18.createContext)({ isMocked: false });
|
|
5253
|
+
var useIsMocked = () => (0, import_react18.useContext)(SDKContext).isMocked;
|
|
5003
5254
|
var SDKProvider = ({
|
|
5004
5255
|
children,
|
|
5005
5256
|
debug = false,
|
|
5006
5257
|
...mockerProps
|
|
5007
5258
|
}) => {
|
|
5008
5259
|
const isMocked = typeof window !== "undefined" && !(window.__UP_REACT_NATIVE_APP__ === true || !!window.ReactNativeWebView);
|
|
5009
|
-
const value = (0,
|
|
5010
|
-
const content = /* @__PURE__ */ (0,
|
|
5260
|
+
const value = (0, import_react18.useMemo)(() => ({ isMocked }), [isMocked]);
|
|
5261
|
+
const content = /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
5011
5262
|
children,
|
|
5012
|
-
(debug || isMocked) && /* @__PURE__ */ (0,
|
|
5263
|
+
(debug || isMocked) && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(DebugConsole, {})
|
|
5013
5264
|
] });
|
|
5014
5265
|
if (isMocked) {
|
|
5015
|
-
return /* @__PURE__ */ (0,
|
|
5266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SDKContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(BridgeMocker, { ...mockerProps, children: content }) });
|
|
5016
5267
|
}
|
|
5017
|
-
return /* @__PURE__ */ (0,
|
|
5268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SDKContext.Provider, { value, children: content });
|
|
5018
5269
|
};
|
|
5019
5270
|
|
|
5020
5271
|
// src/components/SwipeCarousel.tsx
|
|
5021
|
-
var
|
|
5022
|
-
var
|
|
5272
|
+
var import_react19 = require("react");
|
|
5273
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
5023
5274
|
var DIRECTION_LOCK_THRESHOLD_PX = 8;
|
|
5024
5275
|
var SWIPE_DISTANCE_THRESHOLD_PX = 40;
|
|
5025
5276
|
var SWIPE_VELOCITY_THRESHOLD = 0.4;
|
|
@@ -5046,28 +5297,28 @@ var SwipeCarousel = ({
|
|
|
5046
5297
|
overscan = DEFAULT_OVERSCAN,
|
|
5047
5298
|
visibleOverscan = DEFAULT_VISIBLE_OVERSCAN
|
|
5048
5299
|
}) => {
|
|
5049
|
-
const containerRef = (0,
|
|
5050
|
-
const [containerWidth, setContainerWidth] = (0,
|
|
5051
|
-
const [dragX, setDragX] = (0,
|
|
5052
|
-
const [dragY, setDragY] = (0,
|
|
5053
|
-
const [isDraggingX, setIsDraggingX] = (0,
|
|
5054
|
-
const [isDraggingY, setIsDraggingY] = (0,
|
|
5055
|
-
const touchStateRef = (0,
|
|
5056
|
-
const [internalIndex, setInternalIndex] = (0,
|
|
5300
|
+
const containerRef = (0, import_react19.useRef)(null);
|
|
5301
|
+
const [containerWidth, setContainerWidth] = (0, import_react19.useState)(0);
|
|
5302
|
+
const [dragX, setDragX] = (0, import_react19.useState)(0);
|
|
5303
|
+
const [dragY, setDragY] = (0, import_react19.useState)(0);
|
|
5304
|
+
const [isDraggingX, setIsDraggingX] = (0, import_react19.useState)(false);
|
|
5305
|
+
const [isDraggingY, setIsDraggingY] = (0, import_react19.useState)(false);
|
|
5306
|
+
const touchStateRef = (0, import_react19.useRef)(null);
|
|
5307
|
+
const [internalIndex, setInternalIndex] = (0, import_react19.useState)(
|
|
5057
5308
|
() => Math.max(
|
|
5058
5309
|
0,
|
|
5059
5310
|
items.findIndex((item) => item.id === activeId)
|
|
5060
5311
|
)
|
|
5061
5312
|
);
|
|
5062
|
-
const prevActiveIdRef = (0,
|
|
5063
|
-
const [timingWaiting, setTimingWaiting] = (0,
|
|
5064
|
-
(0,
|
|
5313
|
+
const prevActiveIdRef = (0, import_react19.useRef)(activeId);
|
|
5314
|
+
const [timingWaiting, setTimingWaiting] = (0, import_react19.useState)(true);
|
|
5315
|
+
(0, import_react19.useEffect)(() => {
|
|
5065
5316
|
const timer = setTimeout(() => {
|
|
5066
5317
|
setTimingWaiting(false);
|
|
5067
5318
|
}, 1e3);
|
|
5068
5319
|
return () => clearTimeout(timer);
|
|
5069
5320
|
}, []);
|
|
5070
|
-
(0,
|
|
5321
|
+
(0, import_react19.useEffect)(() => {
|
|
5071
5322
|
if (activeId !== prevActiveIdRef.current) {
|
|
5072
5323
|
const idx = items.findIndex((item) => item.id === activeId);
|
|
5073
5324
|
if (idx !== -1) setInternalIndex(idx);
|
|
@@ -5078,7 +5329,7 @@ var SwipeCarousel = ({
|
|
|
5078
5329
|
Math.max(internalIndex, 0),
|
|
5079
5330
|
Math.max(items.length - 1, 0)
|
|
5080
5331
|
);
|
|
5081
|
-
(0,
|
|
5332
|
+
(0, import_react19.useLayoutEffect)(() => {
|
|
5082
5333
|
const el = containerRef.current;
|
|
5083
5334
|
if (!el) return;
|
|
5084
5335
|
const update = () => setContainerWidth(el.clientWidth);
|
|
@@ -5196,7 +5447,7 @@ var SwipeCarousel = ({
|
|
|
5196
5447
|
};
|
|
5197
5448
|
const windowStart = Math.max(0, activeIndex - overscan);
|
|
5198
5449
|
const windowEnd = Math.min(items.length - 1, activeIndex + overscan);
|
|
5199
|
-
return /* @__PURE__ */ (0,
|
|
5450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5200
5451
|
"div",
|
|
5201
5452
|
{
|
|
5202
5453
|
className: `relative overflow-hidden touch-pan-y ${className ?? ""}`,
|
|
@@ -5205,7 +5456,7 @@ var SwipeCarousel = ({
|
|
|
5205
5456
|
onTouchMove: handleTouchMove,
|
|
5206
5457
|
onTouchStart: handleTouchStart,
|
|
5207
5458
|
ref: containerRef,
|
|
5208
|
-
children: /* @__PURE__ */ (0,
|
|
5459
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5209
5460
|
"div",
|
|
5210
5461
|
{
|
|
5211
5462
|
className: "relative h-full",
|
|
@@ -5220,7 +5471,7 @@ var SwipeCarousel = ({
|
|
|
5220
5471
|
const verticalOffset = isActive ? dragY : 0;
|
|
5221
5472
|
const distance = Math.abs(index - activeIndex);
|
|
5222
5473
|
const isVisible = distance <= visibleOverscan;
|
|
5223
|
-
return /* @__PURE__ */ (0,
|
|
5474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
5224
5475
|
"div",
|
|
5225
5476
|
{
|
|
5226
5477
|
className: `absolute top-0 left-0 h-full shrink-0 ${itemClassName ?? ""} ${item.className ?? ""}`,
|
|
@@ -5561,6 +5812,7 @@ var src_default = sdk;
|
|
|
5561
5812
|
MapMenuTitle,
|
|
5562
5813
|
MiniAppSDK,
|
|
5563
5814
|
MockLocationContext,
|
|
5815
|
+
PullToRefresh,
|
|
5564
5816
|
QRScanner,
|
|
5565
5817
|
RouteLayer,
|
|
5566
5818
|
SDKMapProvider,
|