@rootnative/web 0.0.0-alpha.0 → 0.0.0-alpha.2
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/CHANGELOG.md +47 -1
- package/README.md +7 -6
- package/dist/{StyleRegistryContext-ButsUd8D.js → StyleRegistryContext-CAD45r4n.js} +3 -8
- package/dist/StyleRegistryContext-CAD45r4n.js.map +1 -0
- package/dist/env-DK5Mt9yX.js +9 -0
- package/dist/env-DK5Mt9yX.js.map +1 -0
- package/dist/index.d.ts +191 -49
- package/dist/index.js +2149 -1651
- package/dist/index.js.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/vite/index.d.ts +7 -0
- package/dist/vite/index.js +206 -0
- package/dist/vite/index.js.map +1 -0
- package/llms.txt +128 -20
- package/package.json +18 -9
- package/dist/StyleRegistryContext-ButsUd8D.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as matchesMedia, n as isProductionEnv, r as isTestEnv, t as hasDOM } from "./env-DK5Mt9yX.js";
|
|
2
|
+
import { n as useStyleRegistry, o as getStyleRegistry } from "./StyleRegistryContext-CAD45r4n.js";
|
|
2
3
|
import normalizeColor from "@react-native/normalize-colors";
|
|
3
4
|
import { Children, Fragment, cloneElement, createContext, createElement, isValidElement, memo, useCallback, useContext, useEffect, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -1052,1635 +1053,1980 @@ function useViewElement(props, extraClassName) {
|
|
|
1052
1053
|
domProps["ref"] = element;
|
|
1053
1054
|
return createElement(tag, domProps, children);
|
|
1054
1055
|
}
|
|
1055
|
-
// src/components/
|
|
1056
|
-
const
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1056
|
+
// src/components/ActivityIndicator/index.tsx
|
|
1057
|
+
const GRAY = "#999999";
|
|
1058
|
+
const SPIN_CLASS = "rn-activity-indicator";
|
|
1059
|
+
const SPIN_RULES = ["@keyframes rn-activity-indicator-spin{to{transform:rotate(360deg)}}", `.${SPIN_CLASS}{animation:rn-activity-indicator-spin .75s linear infinite}`];
|
|
1060
|
+
const pausedStyle = { animationPlayState: "paused" };
|
|
1061
|
+
function ActivityIndicator(props) {
|
|
1062
|
+
const { animating = true, color = GRAY, hidesWhenStopped = true, onLayout, ref, size = "small", style, ...rest } = props;
|
|
1063
|
+
const spinClass = useStyleRegistry().staticClass(SPIN_CLASS, SPIN_RULES);
|
|
1064
|
+
const stroke = toCSSColor(color) ?? GRAY;
|
|
1065
|
+
const sizeStyle = size === "small" ? styles$2.sizeSmall : size === "large" ? styles$2.sizeLarge : {
|
|
1066
|
+
width: size,
|
|
1067
|
+
height: size
|
|
1068
|
+
};
|
|
1069
|
+
return /* @__PURE__ */ jsx(View, {
|
|
1070
|
+
onLayout,
|
|
1071
|
+
style: [styles$2.container, style],
|
|
1072
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
1073
|
+
role: "progressbar",
|
|
1074
|
+
...rest,
|
|
1075
|
+
ref,
|
|
1076
|
+
style: [sizeStyle, !animating && hidesWhenStopped && styles$2.hidden],
|
|
1077
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
1078
|
+
"aria-hidden": true,
|
|
1079
|
+
className: spinClass,
|
|
1080
|
+
height: "100%",
|
|
1081
|
+
style: animating ? void 0 : pausedStyle,
|
|
1082
|
+
viewBox: "0 0 32 32",
|
|
1083
|
+
width: "100%",
|
|
1084
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
1085
|
+
cx: "16",
|
|
1086
|
+
cy: "16",
|
|
1087
|
+
fill: "none",
|
|
1088
|
+
opacity: "0.2",
|
|
1089
|
+
r: "14",
|
|
1090
|
+
stroke,
|
|
1091
|
+
strokeWidth: "4"
|
|
1092
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
1093
|
+
cx: "16",
|
|
1094
|
+
cy: "16",
|
|
1095
|
+
fill: "none",
|
|
1096
|
+
r: "14",
|
|
1097
|
+
stroke,
|
|
1098
|
+
strokeDasharray: "80",
|
|
1099
|
+
strokeDashoffset: "60",
|
|
1100
|
+
strokeWidth: "4"
|
|
1101
|
+
})]
|
|
1102
|
+
})
|
|
1103
|
+
})
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
const styles$2 = StyleSheet.create({
|
|
1107
|
+
container: {
|
|
1108
|
+
alignItems: "center",
|
|
1109
|
+
justifyContent: "center"
|
|
1110
|
+
},
|
|
1111
|
+
sizeSmall: {
|
|
1112
|
+
width: 20,
|
|
1113
|
+
height: 20
|
|
1114
|
+
},
|
|
1115
|
+
sizeLarge: {
|
|
1116
|
+
width: 36,
|
|
1117
|
+
height: 36
|
|
1118
|
+
},
|
|
1119
|
+
hidden: { visibility: "hidden" }
|
|
1120
|
+
});
|
|
1121
|
+
// src/events/responderEvent.ts
|
|
1122
|
+
const hasPoint = (event) => event.clientX !== void 0 && !(event.type === "click" && event.detail === 0);
|
|
1123
|
+
const activeTypes = /* @__PURE__ */ new Set([
|
|
1124
|
+
"pointerdown",
|
|
1125
|
+
"pointermove",
|
|
1126
|
+
"keydown"
|
|
1127
|
+
]);
|
|
1128
|
+
const define = (target, fields) => {
|
|
1129
|
+
for (const key in fields) {
|
|
1130
|
+
if (key in target) continue;
|
|
1131
|
+
Object.defineProperty(target, key, {
|
|
1132
|
+
value: fields[key],
|
|
1133
|
+
configurable: true
|
|
1134
|
+
});
|
|
1065
1135
|
}
|
|
1066
|
-
return best;
|
|
1067
1136
|
};
|
|
1068
|
-
const
|
|
1069
|
-
const
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
const
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1137
|
+
const toGestureResponderEvent = (event, element) => {
|
|
1138
|
+
const native = event.nativeEvent;
|
|
1139
|
+
if (!("locationX" in native)) {
|
|
1140
|
+
const rect = element.getBoundingClientRect();
|
|
1141
|
+
const point = hasPoint(native);
|
|
1142
|
+
const clientX = point ? native.clientX ?? 0 : rect.left + rect.width / 2;
|
|
1143
|
+
const clientY = point ? native.clientY ?? 0 : rect.top + rect.height / 2;
|
|
1144
|
+
const touch = {
|
|
1145
|
+
changedTouches: [],
|
|
1146
|
+
force: native.pressure,
|
|
1147
|
+
identifier: native.pointerId ?? 0,
|
|
1148
|
+
locationX: clientX - rect.left,
|
|
1149
|
+
locationY: clientY - rect.top,
|
|
1150
|
+
pageX: clientX + window.scrollX,
|
|
1151
|
+
pageY: clientY + window.scrollY,
|
|
1152
|
+
target: native.target,
|
|
1153
|
+
timestamp: event.timeStamp,
|
|
1154
|
+
touches: []
|
|
1155
|
+
};
|
|
1156
|
+
define(native, {
|
|
1157
|
+
...touch,
|
|
1158
|
+
changedTouches: [touch],
|
|
1159
|
+
touches: activeTypes.has(native.type) ? [touch] : []
|
|
1160
|
+
});
|
|
1085
1161
|
}
|
|
1086
|
-
|
|
1087
|
-
target = Math.min(max, Math.max(0, target));
|
|
1088
|
-
return Math.abs(target - offset) < .5 ? void 0 : target;
|
|
1162
|
+
return event;
|
|
1089
1163
|
};
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
const disabledScrollerStyle = Object.freeze({
|
|
1104
|
-
overflowX: "hidden",
|
|
1105
|
-
overflowY: "hidden"
|
|
1106
|
-
});
|
|
1107
|
-
const horizontalContentStyle = Object.freeze({ flexDirection: "row" });
|
|
1108
|
-
const centerContentStyle = Object.freeze({
|
|
1109
|
-
flexGrow: 1,
|
|
1110
|
-
justifyContent: "center"
|
|
1111
|
-
});
|
|
1112
|
-
const stickyStyle = Object.freeze({
|
|
1113
|
-
position: "sticky",
|
|
1114
|
-
top: 0,
|
|
1115
|
-
zIndex: 10
|
|
1116
|
-
});
|
|
1117
|
-
const invertedStickyStyle = Object.freeze({
|
|
1118
|
-
position: "sticky",
|
|
1119
|
-
bottom: 0,
|
|
1120
|
-
zIndex: 10
|
|
1121
|
-
});
|
|
1122
|
-
const hiddenScrollbarClass = (registry) => registry.staticClass("rn-scrollbar-none", [".rn-scrollbar-none{scrollbar-width:none;-ms-overflow-style:none}", ".rn-scrollbar-none::-webkit-scrollbar{display:none}"]);
|
|
1123
|
-
const supportsScrollEnd = hasDOM() && "onscrollend" in window;
|
|
1124
|
-
const SCROLL_END_DELAY = 150;
|
|
1125
|
-
const behaviorFor = (animated) => animated !== false && !Platform.isDisableAnimations ? "smooth" : "auto";
|
|
1126
|
-
const describe = (element) => ({
|
|
1127
|
-
contentInset: {
|
|
1128
|
-
top: 0,
|
|
1129
|
-
left: 0,
|
|
1130
|
-
bottom: 0,
|
|
1131
|
-
right: 0
|
|
1164
|
+
const toMouseEvent = (event) => {
|
|
1165
|
+
define(event.nativeEvent, { timestamp: event.timeStamp });
|
|
1166
|
+
return event;
|
|
1167
|
+
};
|
|
1168
|
+
// src/events/press/Pressability.ts
|
|
1169
|
+
const transitions = {
|
|
1170
|
+
NOT_RESPONDER: { RESPONDER_GRANT: "RESPONDER_INACTIVE_PRESS_IN" },
|
|
1171
|
+
RESPONDER_INACTIVE_PRESS_IN: {
|
|
1172
|
+
DELAY: "RESPONDER_ACTIVE_PRESS_IN",
|
|
1173
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
1174
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
1175
|
+
ENTER_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_IN",
|
|
1176
|
+
LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT"
|
|
1132
1177
|
},
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1178
|
+
RESPONDER_INACTIVE_PRESS_OUT: {
|
|
1179
|
+
DELAY: "RESPONDER_ACTIVE_PRESS_OUT",
|
|
1180
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
1181
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
1182
|
+
ENTER_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_IN",
|
|
1183
|
+
LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT"
|
|
1136
1184
|
},
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1185
|
+
RESPONDER_ACTIVE_PRESS_IN: {
|
|
1186
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
1187
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
1188
|
+
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
|
|
1189
|
+
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT",
|
|
1190
|
+
LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
|
|
1140
1191
|
},
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1192
|
+
RESPONDER_ACTIVE_PRESS_OUT: {
|
|
1193
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
1194
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
1195
|
+
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
|
|
1196
|
+
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT"
|
|
1144
1197
|
},
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1198
|
+
RESPONDER_ACTIVE_LONG_PRESS_IN: {
|
|
1199
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
1200
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
1201
|
+
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
|
|
1202
|
+
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_OUT",
|
|
1203
|
+
LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
|
|
1204
|
+
},
|
|
1205
|
+
RESPONDER_ACTIVE_LONG_PRESS_OUT: {
|
|
1206
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
1207
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
1208
|
+
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
|
|
1209
|
+
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_OUT"
|
|
1210
|
+
}
|
|
1153
1211
|
};
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1212
|
+
const isActive = (state) => state === "RESPONDER_ACTIVE_PRESS_IN" || state === "RESPONDER_ACTIVE_LONG_PRESS_IN";
|
|
1213
|
+
const isActivation = (state) => state === "RESPONDER_ACTIVE_PRESS_OUT" || state === "RESPONDER_ACTIVE_PRESS_IN";
|
|
1214
|
+
const isPressIn = (state) => state === "RESPONDER_INACTIVE_PRESS_IN" || state === "RESPONDER_ACTIVE_PRESS_IN" || state === "RESPONDER_ACTIVE_LONG_PRESS_IN";
|
|
1215
|
+
const isTerminal = (signal) => signal === "RESPONDER_TERMINATED" || signal === "RESPONDER_RELEASE";
|
|
1216
|
+
const DEFAULT_LONG_PRESS_DELAY_MS = 500;
|
|
1217
|
+
const DEFAULT_MIN_PRESS_DURATION = 130;
|
|
1218
|
+
const DEFAULT_PRESS_RECT_OFFSETS = {
|
|
1219
|
+
bottom: 30,
|
|
1220
|
+
left: 20,
|
|
1221
|
+
right: 20,
|
|
1222
|
+
top: 20
|
|
1223
|
+
};
|
|
1224
|
+
let longPressDeactivationDistance = 10;
|
|
1225
|
+
const normalizeDelay = (delay, min = 0, fallback = 0) => Math.max(min, delay ?? fallback);
|
|
1226
|
+
const normalizeRect = (rect) => typeof rect === "number" ? {
|
|
1227
|
+
bottom: rect,
|
|
1228
|
+
left: rect,
|
|
1229
|
+
right: rect,
|
|
1230
|
+
top: rect
|
|
1231
|
+
} : rect;
|
|
1232
|
+
const claimed = /* @__PURE__ */ new WeakSet();
|
|
1233
|
+
const isActivationKey = (key) => key === "Enter" || key === " ";
|
|
1234
|
+
const hasNativeActivation = (element) => {
|
|
1235
|
+
switch (element.tagName) {
|
|
1236
|
+
case "BUTTON":
|
|
1237
|
+
case "INPUT":
|
|
1238
|
+
case "SELECT":
|
|
1239
|
+
case "SUMMARY":
|
|
1240
|
+
case "TEXTAREA": return true;
|
|
1241
|
+
case "A":
|
|
1242
|
+
case "AREA": return element.hasAttribute("href");
|
|
1243
|
+
default: return element.isContentEditable;
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
const nativeControl = "a[href],area[href],audio[controls],button,input,select,summary,textarea,video[controls],[contenteditable]:not([contenteditable=\"false\"])";
|
|
1247
|
+
const startsInNativeControl = (event) => {
|
|
1248
|
+
const { currentTarget, target } = event;
|
|
1249
|
+
if (!(target instanceof Element)) return false;
|
|
1250
|
+
const control = target.closest(nativeControl);
|
|
1251
|
+
return control !== null && control !== currentTarget && currentTarget.contains(control);
|
|
1252
|
+
};
|
|
1253
|
+
const clear = (timer) => {
|
|
1254
|
+
if (timer !== null) clearTimeout(timer);
|
|
1255
|
+
return null;
|
|
1256
|
+
};
|
|
1257
|
+
var Pressability = class {
|
|
1258
|
+
constructor(config) {
|
|
1259
|
+
this.state = "NOT_RESPONDER";
|
|
1260
|
+
this.element = null;
|
|
1261
|
+
this.region = null;
|
|
1262
|
+
this.pointerId = null;
|
|
1263
|
+
this.key = null;
|
|
1264
|
+
this.activatePosition = null;
|
|
1265
|
+
this.activateTime = null;
|
|
1266
|
+
this.hovered = false;
|
|
1267
|
+
this.pointerClickPending = false;
|
|
1268
|
+
this.cancelClick = false;
|
|
1269
|
+
this.hoverInTimer = null;
|
|
1270
|
+
this.hoverOutTimer = null;
|
|
1271
|
+
this.longPressTimer = null;
|
|
1272
|
+
this.pressDelayTimer = null;
|
|
1273
|
+
this.pressOutTimer = null;
|
|
1274
|
+
this.config = config;
|
|
1275
|
+
this.handlers = this.createEventHandlers();
|
|
1276
|
+
}
|
|
1277
|
+
configure(config) {
|
|
1278
|
+
this.config = config;
|
|
1279
|
+
}
|
|
1280
|
+
reset() {
|
|
1281
|
+
this.hoverInTimer = clear(this.hoverInTimer);
|
|
1282
|
+
this.hoverOutTimer = clear(this.hoverOutTimer);
|
|
1283
|
+
this.longPressTimer = clear(this.longPressTimer);
|
|
1284
|
+
this.pressDelayTimer = clear(this.pressDelayTimer);
|
|
1285
|
+
this.pressOutTimer = clear(this.pressOutTimer);
|
|
1286
|
+
this.config = Object.freeze({});
|
|
1287
|
+
}
|
|
1288
|
+
getEventHandlers() {
|
|
1289
|
+
return this.handlers;
|
|
1290
|
+
}
|
|
1291
|
+
static setLongPressDeactivationDistance(distance) {
|
|
1292
|
+
longPressDeactivationDistance = distance;
|
|
1293
|
+
}
|
|
1294
|
+
createEventHandlers() {
|
|
1295
|
+
return {
|
|
1296
|
+
onPointerDown: (event) => {
|
|
1297
|
+
const native = event.nativeEvent;
|
|
1298
|
+
if (event.button !== 0 || claimed.has(native) || this.config.disabled === true) return;
|
|
1299
|
+
if (startsInNativeControl(event)) return;
|
|
1300
|
+
claimed.add(native);
|
|
1301
|
+
if (this.pointerId !== null || this.key !== null) return;
|
|
1302
|
+
const element = event.currentTarget;
|
|
1303
|
+
this.pointerId = event.pointerId;
|
|
1304
|
+
this.pointerClickPending = true;
|
|
1305
|
+
try {
|
|
1306
|
+
element.setPointerCapture(event.pointerId);
|
|
1307
|
+
} catch {}
|
|
1308
|
+
this.grant(element, toGestureResponderEvent(event, element));
|
|
1309
|
+
},
|
|
1310
|
+
onPointerMove: (event) => {
|
|
1311
|
+
const element = this.element;
|
|
1312
|
+
if (event.pointerId !== this.pointerId || element === null) return;
|
|
1313
|
+
const pressEvent = toGestureResponderEvent(event, element);
|
|
1314
|
+
this.config.onPressMove?.(pressEvent);
|
|
1315
|
+
const region = this.region;
|
|
1316
|
+
if (region === null) return;
|
|
1317
|
+
const { pageX, pageY } = pressEvent.nativeEvent;
|
|
1318
|
+
const start = this.activatePosition;
|
|
1319
|
+
if (start !== null && Math.hypot(start.pageX - pageX, start.pageY - pageY) > longPressDeactivationDistance) this.longPressTimer = clear(this.longPressTimer);
|
|
1320
|
+
if (this.isWithinRegion(pageX, pageY, region)) this.receiveSignal("ENTER_PRESS_RECT", pressEvent);
|
|
1321
|
+
else {
|
|
1322
|
+
this.longPressTimer = clear(this.longPressTimer);
|
|
1323
|
+
this.receiveSignal("LEAVE_PRESS_RECT", pressEvent);
|
|
1255
1324
|
}
|
|
1256
|
-
} else {
|
|
1257
|
-
state.phase = "momentum";
|
|
1258
|
-
handlers.current.onMomentumScrollBegin?.(scrollEvent);
|
|
1259
|
-
}
|
|
1260
|
-
} else if (state.phase === "released") {
|
|
1261
|
-
state.phase = "momentum";
|
|
1262
|
-
handlers.current.onMomentumScrollBegin?.(scrollEvent);
|
|
1263
|
-
}
|
|
1264
|
-
if (config.stickyHeaderHiddenOnScroll && !config.horizontal && delta !== 0) {
|
|
1265
|
-
const hidden = delta > 0;
|
|
1266
|
-
for (const header of stickyHeaders.current) {
|
|
1267
|
-
header.style.transition = "transform 150ms";
|
|
1268
|
-
header.style.transform = hidden ? "translateY(-100%)" : "";
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
handlers.current.onScroll?.(scrollEvent);
|
|
1272
|
-
if (!supportsScrollEnd) {
|
|
1273
|
-
if (state.timer !== void 0) clearTimeout(state.timer);
|
|
1274
|
-
state.timer = setTimeout(settle, SCROLL_END_DELAY);
|
|
1275
|
-
}
|
|
1276
|
-
};
|
|
1277
|
-
const handleScrollEnd = (event) => {
|
|
1278
|
-
if (event.target !== event.currentTarget) return;
|
|
1279
|
-
settle();
|
|
1280
|
-
};
|
|
1281
|
-
const handlePointerDown = (event) => {
|
|
1282
|
-
onPointerDown?.(event);
|
|
1283
|
-
const state = sequence.current;
|
|
1284
|
-
if (state.pointerDown) return;
|
|
1285
|
-
state.pointerDown = true;
|
|
1286
|
-
const release = () => {
|
|
1287
|
-
window.removeEventListener("pointerup", release);
|
|
1288
|
-
window.removeEventListener("pointercancel", release);
|
|
1289
|
-
state.pointerDown = false;
|
|
1290
|
-
if (state.phase === "drag") {
|
|
1291
|
-
state.phase = "released";
|
|
1292
|
-
const scrollEvent = refreshEvent();
|
|
1293
|
-
if (scrollEvent !== null) handlers.current.onScrollEndDrag?.(scrollEvent);
|
|
1294
|
-
}
|
|
1295
|
-
};
|
|
1296
|
-
window.addEventListener("pointerup", release);
|
|
1297
|
-
window.addEventListener("pointercancel", release);
|
|
1298
|
-
};
|
|
1299
|
-
useEffect(() => {
|
|
1300
|
-
const state = sequence.current;
|
|
1301
|
-
return () => {
|
|
1302
|
-
if (state.timer !== void 0) clearTimeout(state.timer);
|
|
1303
|
-
};
|
|
1304
|
-
}, []);
|
|
1305
|
-
const onContentLayout = onContentSizeChange === void 0 ? void 0 : (event) => onContentSizeChange(event.nativeEvent.layout.width, event.nativeEvent.layout.height);
|
|
1306
|
-
const stickySet = stickyHeaderIndices !== void 0 && stickyHeaderIndices.length > 0 && !horizontal ? new Set(stickyHeaderIndices) : void 0;
|
|
1307
|
-
const setStickyHeader = useCallback((node) => {
|
|
1308
|
-
const list = stickyHeaders.current;
|
|
1309
|
-
if (node === null) return;
|
|
1310
|
-
if (!list.includes(node)) list.push(node);
|
|
1311
|
-
return () => {
|
|
1312
|
-
const index = list.indexOf(node);
|
|
1313
|
-
if (index !== -1) list.splice(index, 1);
|
|
1314
|
-
};
|
|
1315
|
-
}, []);
|
|
1316
|
-
let items = children;
|
|
1317
|
-
if (stickySet !== void 0) items = Children.toArray(children).map((child, index) => stickySet.has(index) ? /* @__PURE__ */ jsx(View, {
|
|
1318
|
-
ref: setStickyHeader,
|
|
1319
|
-
style: invertStickyHeaders === true ? invertedStickyStyle : stickyStyle,
|
|
1320
|
-
children: child
|
|
1321
|
-
}, isValidElement(child) && child.key !== null ? child.key : `sticky-${index}`) : child);
|
|
1322
|
-
const contentElement = /* @__PURE__ */ jsx(View, {
|
|
1323
|
-
ref: content,
|
|
1324
|
-
onLayout: onContentLayout,
|
|
1325
|
-
style: [
|
|
1326
|
-
horizontal && horizontalContentStyle,
|
|
1327
|
-
centerContent === true && centerContentStyle,
|
|
1328
|
-
contentContainerStyle
|
|
1329
|
-
],
|
|
1330
|
-
children: items
|
|
1331
|
-
});
|
|
1332
|
-
const hideScrollbar = horizontal ? !showsHorizontalScrollIndicator : !showsVerticalScrollIndicator;
|
|
1333
|
-
const scrollerElement = useViewElement({
|
|
1334
|
-
...rest,
|
|
1335
|
-
ref: scroller,
|
|
1336
|
-
style: [
|
|
1337
|
-
scrollerStyle,
|
|
1338
|
-
horizontal && horizontalScrollerStyle,
|
|
1339
|
-
!scrollEnabled && disabledScrollerStyle,
|
|
1340
|
-
style
|
|
1341
|
-
],
|
|
1342
|
-
onScroll: handleScroll,
|
|
1343
|
-
onScrollEnd: handleScrollEnd,
|
|
1344
|
-
onPointerDown: handlePointerDown,
|
|
1345
|
-
children: contentElement
|
|
1346
|
-
}, hideScrollbar ? hiddenScrollbarClass(registry) : void 0);
|
|
1347
|
-
const offsetX = contentOffset?.x;
|
|
1348
|
-
const offsetY = contentOffset?.y;
|
|
1349
|
-
useLayoutEffect(() => {
|
|
1350
|
-
const element = scroller.current;
|
|
1351
|
-
if (element === null || offsetX === void 0 && offsetY === void 0) return;
|
|
1352
|
-
if (offsetX !== void 0) element.scrollLeft = offsetX;
|
|
1353
|
-
if (offsetY !== void 0) element.scrollTop = offsetY;
|
|
1354
|
-
sequence.current.lastOffset = horizontal ? element.scrollLeft : element.scrollTop;
|
|
1355
|
-
}, [
|
|
1356
|
-
offsetX,
|
|
1357
|
-
offsetY,
|
|
1358
|
-
horizontal
|
|
1359
|
-
]);
|
|
1360
|
-
useImperativeHandle(ref, () => {
|
|
1361
|
-
const element = scroller.current;
|
|
1362
|
-
const nativeScrollTo = element.scrollTo.bind(element);
|
|
1363
|
-
const instance = element;
|
|
1364
|
-
return Object.assign(instance, {
|
|
1365
|
-
scrollTo: ((first, second) => {
|
|
1366
|
-
if (isReactNativeScrollTo(first)) domScrollTo(element, first);
|
|
1367
|
-
else if (typeof first === "number" && typeof second === "number") nativeScrollTo(first, second);
|
|
1368
|
-
else nativeScrollTo(first);
|
|
1369
|
-
}),
|
|
1370
|
-
scrollToEnd: (options) => {
|
|
1371
|
-
const animated = options?.animated;
|
|
1372
|
-
domScrollTo(element, horizontal ? {
|
|
1373
|
-
x: element.scrollWidth,
|
|
1374
|
-
animated
|
|
1375
|
-
} : {
|
|
1376
|
-
y: element.scrollHeight,
|
|
1377
|
-
animated
|
|
1378
|
-
});
|
|
1379
1325
|
},
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1326
|
+
onPointerUp: (event) => {
|
|
1327
|
+
const element = this.element;
|
|
1328
|
+
if (event.pointerId !== this.pointerId || element === null) return;
|
|
1329
|
+
this.pointerId = null;
|
|
1330
|
+
this.receiveSignal("RESPONDER_RELEASE", toGestureResponderEvent(event, element));
|
|
1331
|
+
},
|
|
1332
|
+
onPointerCancel: (event) => {
|
|
1333
|
+
const element = this.element;
|
|
1334
|
+
if (event.pointerId !== this.pointerId || element === null) return;
|
|
1335
|
+
this.pointerId = null;
|
|
1336
|
+
this.pointerClickPending = false;
|
|
1337
|
+
this.receiveSignal("RESPONDER_TERMINATED", toGestureResponderEvent(event, element));
|
|
1338
|
+
},
|
|
1339
|
+
onClick: (event) => {
|
|
1340
|
+
const native = event.nativeEvent;
|
|
1341
|
+
if (claimed.has(native) || startsInNativeControl(event)) return;
|
|
1342
|
+
if (this.pointerClickPending && event.detail > 0) {
|
|
1343
|
+
this.pointerClickPending = false;
|
|
1344
|
+
claimed.add(native);
|
|
1345
|
+
if (this.cancelClick) event.preventDefault();
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
if (this.config.disabled === true) return;
|
|
1349
|
+
claimed.add(native);
|
|
1350
|
+
this.config.onPress?.(toGestureResponderEvent(event, event.currentTarget));
|
|
1351
|
+
},
|
|
1352
|
+
onKeyDown: (event) => {
|
|
1353
|
+
if (!isActivationKey(event.key) || event.repeat || event.nativeEvent.isComposing) return;
|
|
1354
|
+
const element = event.currentTarget;
|
|
1355
|
+
if (event.target !== element || this.config.disabled === true) return;
|
|
1356
|
+
if (hasNativeActivation(element)) return;
|
|
1357
|
+
if (event.key === " ") event.preventDefault();
|
|
1358
|
+
if (this.pointerId !== null || this.key !== null) return;
|
|
1359
|
+
this.key = event.key;
|
|
1360
|
+
this.grant(element, toGestureResponderEvent(event, element));
|
|
1361
|
+
},
|
|
1362
|
+
onKeyUp: (event) => {
|
|
1363
|
+
const element = this.element;
|
|
1364
|
+
if (event.key !== this.key || element === null) return;
|
|
1365
|
+
this.key = null;
|
|
1366
|
+
this.receiveSignal("RESPONDER_RELEASE", toGestureResponderEvent(event, element));
|
|
1367
|
+
},
|
|
1368
|
+
onFocus: (event) => {
|
|
1369
|
+
this.config.onFocus?.(event);
|
|
1370
|
+
},
|
|
1371
|
+
onBlur: (event) => {
|
|
1372
|
+
const element = this.element;
|
|
1373
|
+
if (this.key !== null && element !== null && event.target === event.currentTarget) {
|
|
1374
|
+
this.key = null;
|
|
1375
|
+
this.receiveSignal("RESPONDER_TERMINATED", toGestureResponderEvent(event, element));
|
|
1376
|
+
}
|
|
1377
|
+
this.config.onBlur?.(event);
|
|
1378
|
+
},
|
|
1379
|
+
onPointerEnter: (event) => {
|
|
1380
|
+
if (event.pointerType === "touch") return;
|
|
1381
|
+
this.hovered = true;
|
|
1382
|
+
this.hoverOutTimer = clear(this.hoverOutTimer);
|
|
1383
|
+
this.hover(event, this.config.onHoverIn, this.config.delayHoverIn, "in");
|
|
1384
|
+
},
|
|
1385
|
+
onPointerLeave: (event) => {
|
|
1386
|
+
if (!this.hovered) return;
|
|
1387
|
+
this.hovered = false;
|
|
1388
|
+
this.hoverInTimer = clear(this.hoverInTimer);
|
|
1389
|
+
this.hover(event, this.config.onHoverOut, this.config.delayHoverOut, "out");
|
|
1390
|
+
},
|
|
1391
|
+
onContextMenu: (event) => {
|
|
1392
|
+
if (this.pointerId !== null && this.config.onLongPress != null) event.preventDefault();
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1414
1395
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
const
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
this.
|
|
1396
|
+
hover(event, callback, delay, direction) {
|
|
1397
|
+
if (callback == null) return;
|
|
1398
|
+
const hoverEvent = toMouseEvent(event);
|
|
1399
|
+
const wait = normalizeDelay(delay);
|
|
1400
|
+
if (wait === 0) {
|
|
1401
|
+
callback(hoverEvent);
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
const timer = setTimeout(() => callback(hoverEvent), wait);
|
|
1405
|
+
if (direction === "in") this.hoverInTimer = timer;
|
|
1406
|
+
else this.hoverOutTimer = timer;
|
|
1425
1407
|
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
this.
|
|
1408
|
+
grant(element, event) {
|
|
1409
|
+
this.pressOutTimer = clear(this.pressOutTimer);
|
|
1410
|
+
this.element = element;
|
|
1411
|
+
this.cancelClick = false;
|
|
1412
|
+
this.state = "NOT_RESPONDER";
|
|
1413
|
+
this.receiveSignal("RESPONDER_GRANT", event);
|
|
1414
|
+
const delayPressIn = normalizeDelay(this.config.delayPressIn);
|
|
1415
|
+
if (delayPressIn > 0) this.pressDelayTimer = setTimeout(() => this.receiveSignal("DELAY", event), delayPressIn);
|
|
1416
|
+
else this.receiveSignal("DELAY", event);
|
|
1417
|
+
const delayLongPress = normalizeDelay(this.config.delayLongPress, 10, DEFAULT_LONG_PRESS_DELAY_MS - delayPressIn);
|
|
1418
|
+
this.longPressTimer = setTimeout(() => {
|
|
1419
|
+
if (this.state === "RESPONDER_ACTIVE_PRESS_IN" || this.state === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.receiveSignal("LONG_PRESS_DETECTED", event);
|
|
1420
|
+
}, delayLongPress + delayPressIn);
|
|
1429
1421
|
}
|
|
1430
|
-
|
|
1431
|
-
|
|
1422
|
+
receiveSignal(signal, event) {
|
|
1423
|
+
const prevState = this.state;
|
|
1424
|
+
const nextState = transitions[prevState][signal];
|
|
1425
|
+
if (nextState === void 0 || nextState === prevState) return;
|
|
1426
|
+
this.performTransitionSideEffects(prevState, nextState, signal, event);
|
|
1427
|
+
this.state = nextState;
|
|
1432
1428
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1429
|
+
performTransitionSideEffects(prevState, nextState, signal, event) {
|
|
1430
|
+
if (isTerminal(signal)) {
|
|
1431
|
+
this.activatePosition = null;
|
|
1432
|
+
this.longPressTimer = clear(this.longPressTimer);
|
|
1433
|
+
}
|
|
1434
|
+
const isInitialTransition = prevState === "NOT_RESPONDER" && nextState === "RESPONDER_INACTIVE_PRESS_IN";
|
|
1435
|
+
const isActivationTransition = !isActivation(prevState) && isActivation(nextState);
|
|
1436
|
+
if (isInitialTransition || isActivationTransition) this.measureRegion();
|
|
1437
|
+
if (isPressIn(prevState) && signal === "LONG_PRESS_DETECTED") this.config.onLongPress?.(event);
|
|
1438
|
+
const isPrevActive = isActive(prevState);
|
|
1439
|
+
const isNextActive = isActive(nextState);
|
|
1440
|
+
if (!isPrevActive && isNextActive) this.activate(event);
|
|
1441
|
+
else if (isPrevActive && !isNextActive) this.deactivate(event);
|
|
1442
|
+
if (isPressIn(prevState) && signal === "RESPONDER_RELEASE") {
|
|
1443
|
+
if (!isNextActive && !isPrevActive) {
|
|
1444
|
+
this.activate(event);
|
|
1445
|
+
this.deactivate(event);
|
|
1446
|
+
}
|
|
1447
|
+
const { onLongPress, onPress } = this.config;
|
|
1448
|
+
if (onLongPress != null && prevState === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.cancelClick = true;
|
|
1449
|
+
else if (onPress != null) {
|
|
1450
|
+
onPress(event);
|
|
1451
|
+
if (event.isDefaultPrevented()) this.cancelClick = true;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
this.pressDelayTimer = clear(this.pressDelayTimer);
|
|
1435
1455
|
}
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
const timer = setTimeout(() => {
|
|
1445
|
-
this.timers.delete(timer);
|
|
1446
|
-
if (this.viewableIndices !== next) return;
|
|
1447
|
-
this.report(next, createViewToken, onViewableItemsChanged);
|
|
1448
|
-
}, minimumViewTime);
|
|
1449
|
-
this.timers.add(timer);
|
|
1450
|
-
} else this.report(next, createViewToken, onViewableItemsChanged);
|
|
1456
|
+
activate(event) {
|
|
1457
|
+
const { pageX, pageY } = event.nativeEvent;
|
|
1458
|
+
this.activatePosition = {
|
|
1459
|
+
pageX,
|
|
1460
|
+
pageY
|
|
1461
|
+
};
|
|
1462
|
+
this.activateTime = Date.now();
|
|
1463
|
+
this.config.onPressIn?.(event);
|
|
1451
1464
|
}
|
|
1452
|
-
|
|
1453
|
-
const
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
const
|
|
1457
|
-
|
|
1465
|
+
deactivate(event) {
|
|
1466
|
+
const { onPressOut } = this.config;
|
|
1467
|
+
if (onPressOut != null) {
|
|
1468
|
+
const minPressDuration = normalizeDelay(this.config.minPressDuration, 0, DEFAULT_MIN_PRESS_DURATION);
|
|
1469
|
+
const pressDuration = Date.now() - (this.activateTime ?? 0);
|
|
1470
|
+
const delayPressOut = Math.max(minPressDuration - pressDuration, normalizeDelay(this.config.delayPressOut));
|
|
1471
|
+
if (delayPressOut > 0) this.pressOutTimer = setTimeout(() => onPressOut(event), delayPressOut);
|
|
1472
|
+
else onPressOut(event);
|
|
1458
1473
|
}
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
}
|
|
1474
|
+
this.activateTime = null;
|
|
1475
|
+
}
|
|
1476
|
+
measureRegion() {
|
|
1477
|
+
if (this.element === null) return;
|
|
1478
|
+
const rect = this.element.getBoundingClientRect();
|
|
1479
|
+
if (rect.width === 0 && rect.height === 0 && rect.top === 0 && rect.left === 0) return;
|
|
1480
|
+
this.region = {
|
|
1481
|
+
bottom: rect.bottom + window.scrollY,
|
|
1482
|
+
left: rect.left + window.scrollX,
|
|
1483
|
+
right: rect.right + window.scrollX,
|
|
1484
|
+
top: rect.top + window.scrollY
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
isWithinRegion(pageX, pageY, region) {
|
|
1488
|
+
const hitSlop = normalizeRect(this.config.hitSlop);
|
|
1489
|
+
const offset = normalizeRect(this.config.pressRectOffset);
|
|
1490
|
+
const bottom = region.bottom + (hitSlop?.bottom ?? 0) + (offset?.bottom ?? DEFAULT_PRESS_RECT_OFFSETS.bottom);
|
|
1491
|
+
const left = region.left - (hitSlop?.left ?? 0) - (offset?.left ?? DEFAULT_PRESS_RECT_OFFSETS.left);
|
|
1492
|
+
const right = region.right + (hitSlop?.right ?? 0) + (offset?.right ?? DEFAULT_PRESS_RECT_OFFSETS.right);
|
|
1493
|
+
const top = region.top - (hitSlop?.top ?? 0) - (offset?.top ?? DEFAULT_PRESS_RECT_OFFSETS.top);
|
|
1494
|
+
return pageX > left && pageX < right && pageY > top && pageY < bottom;
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
// src/events/press/usePressability.ts
|
|
1498
|
+
function usePressability(config) {
|
|
1499
|
+
const [pressability, setPressability] = useState(() => config == null ? null : new Pressability(config));
|
|
1500
|
+
if (pressability === null && config != null) setPressability(new Pressability(config));
|
|
1501
|
+
useInsertionEffect(() => {
|
|
1502
|
+
if (config != null && pressability !== null) pressability.configure(config);
|
|
1503
|
+
}, [config, pressability]);
|
|
1504
|
+
useInsertionEffect(() => {
|
|
1505
|
+
if (pressability === null) return void 0;
|
|
1506
|
+
return () => pressability.reset();
|
|
1507
|
+
}, [pressability]);
|
|
1508
|
+
return pressability === null ? null : pressability.getEventHandlers();
|
|
1509
|
+
}
|
|
1510
|
+
// src/events/press/mergeHandlers.ts
|
|
1511
|
+
const sharedHandlers = [
|
|
1512
|
+
"onClick",
|
|
1513
|
+
"onContextMenu",
|
|
1514
|
+
"onKeyDown",
|
|
1515
|
+
"onKeyUp",
|
|
1516
|
+
"onPointerCancel",
|
|
1517
|
+
"onPointerDown",
|
|
1518
|
+
"onPointerEnter",
|
|
1519
|
+
"onPointerLeave",
|
|
1520
|
+
"onPointerMove",
|
|
1521
|
+
"onPointerUp"
|
|
1522
|
+
];
|
|
1523
|
+
const mergeHandlers = (app, own) => {
|
|
1524
|
+
const merged = { ...own };
|
|
1525
|
+
for (const key of sharedHandlers) {
|
|
1526
|
+
const value = app[key];
|
|
1527
|
+
if (typeof value !== "function") continue;
|
|
1528
|
+
const appHandler = value;
|
|
1529
|
+
const ownHandler = own[key];
|
|
1530
|
+
merged[key] = (event) => {
|
|
1531
|
+
appHandler(event);
|
|
1532
|
+
ownHandler(event);
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
return merged;
|
|
1536
|
+
};
|
|
1537
|
+
// src/components/Text/TextAncestorContext.ts
|
|
1538
|
+
const TextAncestorContext = createContext(false);
|
|
1539
|
+
// src/components/Text/index.tsx
|
|
1540
|
+
const resetStyle$1 = Object.freeze({
|
|
1541
|
+
backgroundColor: "transparent",
|
|
1542
|
+
border: "0 solid black",
|
|
1543
|
+
boxSizing: "border-box",
|
|
1544
|
+
color: "black",
|
|
1545
|
+
display: "inline",
|
|
1546
|
+
fontFamily: "System",
|
|
1547
|
+
fontSize: 14,
|
|
1548
|
+
listStyle: "none",
|
|
1549
|
+
margin: 0,
|
|
1550
|
+
padding: 0,
|
|
1551
|
+
position: "relative",
|
|
1552
|
+
textAlign: "start",
|
|
1553
|
+
textDecoration: "none",
|
|
1554
|
+
whiteSpace: "pre-wrap",
|
|
1555
|
+
wordWrap: "break-word"
|
|
1556
|
+
});
|
|
1557
|
+
const nestedResetStyle = Object.freeze({
|
|
1558
|
+
color: "inherit",
|
|
1559
|
+
font: "inherit",
|
|
1560
|
+
textAlign: "inherit",
|
|
1561
|
+
textDecoration: "inherit",
|
|
1562
|
+
whiteSpace: "inherit"
|
|
1563
|
+
});
|
|
1564
|
+
const singleLineStyle = Object.freeze({
|
|
1565
|
+
overflow: "hidden",
|
|
1566
|
+
textOverflow: "ellipsis",
|
|
1567
|
+
whiteSpace: "nowrap"
|
|
1568
|
+
});
|
|
1569
|
+
const multiLineStyle = (lines) => ({
|
|
1570
|
+
display: "-webkit-box",
|
|
1571
|
+
WebkitBoxOrient: "vertical",
|
|
1572
|
+
WebkitLineClamp: lines,
|
|
1573
|
+
overflow: "hidden"
|
|
1574
|
+
});
|
|
1575
|
+
const selectionClass$1 = (registry, color) => {
|
|
1576
|
+
const css = toCSSColor(color);
|
|
1577
|
+
if (css === void 0) return void 0;
|
|
1578
|
+
const name = `rn-sel-${css.replace(/[^a-z0-9]/g, "")}`;
|
|
1579
|
+
return registry.staticClass(name, [`.${name}::selection{background-color:${css}}`]);
|
|
1580
|
+
};
|
|
1581
|
+
function Text(props) {
|
|
1582
|
+
const { children, disabled, ellipsizeMode, numberOfLines, onBlur, onFocus, onLayout, onLongPress, onPress, onPressIn, onPressOut, pointerEvents, pressRetentionOffset, ref, selectable, selectionColor, style, suppressHighlighting: _suppressHighlighting, ...rest } = props;
|
|
1583
|
+
const nested = useContext(TextAncestorContext);
|
|
1584
|
+
const element = useRef(null);
|
|
1585
|
+
useImperativeHandle(ref, () => element.current, []);
|
|
1586
|
+
useElementLayout(element, onLayout);
|
|
1587
|
+
const registry = useStyleRegistry();
|
|
1588
|
+
const pressable = (onPress != null || onLongPress != null) && disabled !== true;
|
|
1589
|
+
const handlers = usePressability(useMemo(() => pressable ? {
|
|
1590
|
+
pressRectOffset: pressRetentionOffset,
|
|
1591
|
+
onBlur,
|
|
1592
|
+
onFocus,
|
|
1593
|
+
onLongPress,
|
|
1594
|
+
onPress,
|
|
1595
|
+
onPressIn,
|
|
1596
|
+
onPressOut
|
|
1597
|
+
} : null, [
|
|
1598
|
+
pressable,
|
|
1599
|
+
pressRetentionOffset,
|
|
1600
|
+
onBlur,
|
|
1601
|
+
onFocus,
|
|
1602
|
+
onLongPress,
|
|
1603
|
+
onPress,
|
|
1604
|
+
onPressIn,
|
|
1605
|
+
onPressOut
|
|
1606
|
+
]));
|
|
1607
|
+
const roleProps = pressable && rest.role === void 0 && rest.accessibilityRole === void 0 ? {
|
|
1608
|
+
...rest,
|
|
1609
|
+
role: "link"
|
|
1610
|
+
} : rest;
|
|
1611
|
+
const { tag, role } = resolveTag(roleProps, "span", children != null);
|
|
1612
|
+
const lineStyle = numberOfLines === void 0 || numberOfLines < 1 ? void 0 : numberOfLines === 1 ? singleLineStyle : multiLineStyle(numberOfLines);
|
|
1613
|
+
let className = compileStyle([
|
|
1614
|
+
nested ? nestedResetStyle : resetStyle$1,
|
|
1615
|
+
style,
|
|
1616
|
+
lineStyle,
|
|
1617
|
+
ellipsizeMode === "clip" ? { textOverflow: "clip" } : void 0,
|
|
1618
|
+
selectable === false ? { userSelect: "none" } : void 0,
|
|
1619
|
+
pointerEvents === "none" || pointerEvents === "auto" ? { pointerEvents } : void 0
|
|
1620
|
+
], registry);
|
|
1621
|
+
if (selectionColor !== void 0) {
|
|
1622
|
+
const extra = selectionClass$1(registry, selectionColor);
|
|
1623
|
+
if (extra !== void 0) className = `${className} ${extra}`;
|
|
1471
1624
|
}
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
const record = item;
|
|
1484
|
-
if (record.key != null) return String(record.key);
|
|
1485
|
-
if (record.id != null) return String(record.id);
|
|
1625
|
+
const domProps = toDOMProps(rest);
|
|
1626
|
+
if (role !== void 0) domProps["role"] = role;
|
|
1627
|
+
if (tag.length === 2 && tag[0] === "h") delete domProps["aria-level"];
|
|
1628
|
+
if (tag === "button") domProps["type"] = "button";
|
|
1629
|
+
if (disabled === true) domProps["aria-disabled"] = true;
|
|
1630
|
+
if (pressable && handlers !== null) {
|
|
1631
|
+
Object.assign(domProps, mergeHandlers(rest, handlers));
|
|
1632
|
+
if (domProps["tabIndex"] === void 0 && tag !== "a" && tag !== "button") domProps["tabIndex"] = 0;
|
|
1633
|
+
} else {
|
|
1634
|
+
if (onFocus !== void 0) domProps["onFocus"] = onFocus;
|
|
1635
|
+
if (onBlur !== void 0) domProps["onBlur"] = onBlur;
|
|
1486
1636
|
}
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
if (component == null) return null;
|
|
1492
|
-
if (isValidElement(component)) return component;
|
|
1493
|
-
return /* @__PURE__ */ jsx(component, {});
|
|
1494
|
-
};
|
|
1495
|
-
function CustomScroller({ render, ref, ...props }) {
|
|
1496
|
-
return cloneElement(render(props), { ref }, props.children);
|
|
1637
|
+
domProps["className"] = className;
|
|
1638
|
+
domProps["ref"] = element;
|
|
1639
|
+
const content = nested ? children : createElement(TextAncestorContext.Provider, { value: true }, children);
|
|
1640
|
+
return createElement(tag, domProps, content);
|
|
1497
1641
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1642
|
+
// src/render/hitSlop.ts
|
|
1643
|
+
const hitSlopClass = (registry, hitSlop) => {
|
|
1644
|
+
if (hitSlop === void 0) return void 0;
|
|
1645
|
+
const { top = 0, right = 0, bottom = 0, left = 0 } = typeof hitSlop === "number" ? {
|
|
1646
|
+
top: hitSlop,
|
|
1647
|
+
right: hitSlop,
|
|
1648
|
+
bottom: hitSlop,
|
|
1649
|
+
left: hitSlop
|
|
1650
|
+
} : hitSlop;
|
|
1651
|
+
if (top === 0 && right === 0 && bottom === 0 && left === 0) return void 0;
|
|
1652
|
+
const name = `rn-hs-${[
|
|
1653
|
+
top,
|
|
1654
|
+
right,
|
|
1655
|
+
bottom,
|
|
1656
|
+
left
|
|
1657
|
+
].map((n) => String(n).replace(/[^0-9]/g, "_")).join("-")}`;
|
|
1658
|
+
return registry.staticClass(name, [`.${name}::before{content:"";position:absolute;top:${-top}px;right:${-right}px;bottom:${-bottom}px;left:${-left}px;z-index:-1}`]);
|
|
1659
|
+
};
|
|
1660
|
+
// src/components/TouchableOpacity/index.tsx
|
|
1661
|
+
const EASE_IN_OUT_QUAD = "cubic-bezier(0.455, 0.03, 0.515, 0.955)";
|
|
1662
|
+
const DEFAULT_ACTIVE_OPACITY$1 = .2;
|
|
1663
|
+
const notCancelableStyle$2 = Object.freeze({ touchAction: "none" });
|
|
1664
|
+
const isTrue$1 = (value) => value === void 0 ? void 0 : value === true || value === "true";
|
|
1665
|
+
const restingOpacity = (style) => {
|
|
1666
|
+
const opacity = flattenStyle(style)?.["opacity"];
|
|
1667
|
+
return typeof opacity === "number" ? opacity : 1;
|
|
1668
|
+
};
|
|
1669
|
+
function TouchableOpacity(props) {
|
|
1670
|
+
const { activeOpacity, children, delayLongPress, delayPressIn, delayPressOut, disabled, focusable, hasTVPreferredFocus: _hasTVPreferredFocus, hitSlop, nextFocusDown: _nextFocusDown, nextFocusForward: _nextFocusForward, nextFocusLeft: _nextFocusLeft, nextFocusRight: _nextFocusRight, nextFocusUp: _nextFocusUp, onBlur, onFocus, onLongPress, onPress, onPressIn, onPressOut, pressRetentionOffset, ref, rejectResponderTermination, style, touchSoundDisabled, ...rest } = props;
|
|
1671
|
+
const element = useRef(null);
|
|
1672
|
+
const animation = useRef(null);
|
|
1673
|
+
const resting = restingOpacity(style);
|
|
1674
|
+
const resolvedDisabled = disabled ?? isTrue$1(props["aria-disabled"]) ?? props.accessibilityState?.disabled;
|
|
1675
|
+
const fadeTo = useCallback((opacity, duration, settle) => {
|
|
1676
|
+
const node = element.current;
|
|
1677
|
+
if (node === null || typeof node.animate !== "function") return;
|
|
1678
|
+
const from = getComputedStyle(node).opacity;
|
|
1679
|
+
animation.current?.cancel();
|
|
1680
|
+
const next = node.animate([{ opacity: from }, { opacity: String(opacity) }], {
|
|
1681
|
+
duration,
|
|
1682
|
+
easing: EASE_IN_OUT_QUAD,
|
|
1683
|
+
fill: "forwards"
|
|
1514
1684
|
});
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
const update = (keys, next) => {
|
|
1521
|
-
for (const key of keys) if (key !== void 0) separatorUpdaters.get(key)?.(next);
|
|
1685
|
+
animation.current = next;
|
|
1686
|
+
if (settle) next.onfinish = () => {
|
|
1687
|
+
if (animation.current !== next) return;
|
|
1688
|
+
next.cancel();
|
|
1689
|
+
animation.current = null;
|
|
1522
1690
|
};
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1691
|
+
}, []);
|
|
1692
|
+
const handlers = usePressability(useMemo(() => ({
|
|
1693
|
+
cancelable: rejectResponderTermination !== true,
|
|
1694
|
+
disabled: resolvedDisabled,
|
|
1695
|
+
hitSlop,
|
|
1696
|
+
delayLongPress,
|
|
1697
|
+
delayPressIn,
|
|
1698
|
+
delayPressOut,
|
|
1699
|
+
minPressDuration: 0,
|
|
1700
|
+
pressRectOffset: pressRetentionOffset,
|
|
1701
|
+
android_disableSound: touchSoundDisabled,
|
|
1702
|
+
onBlur,
|
|
1703
|
+
onFocus,
|
|
1704
|
+
onLongPress,
|
|
1705
|
+
onPress,
|
|
1706
|
+
onPressIn: (event) => {
|
|
1707
|
+
const starts = event.type === "pointerdown" || event.type === "keydown";
|
|
1708
|
+
fadeTo(activeOpacity ?? DEFAULT_ACTIVE_OPACITY$1, starts ? 0 : 150, false);
|
|
1709
|
+
onPressIn?.(event);
|
|
1710
|
+
},
|
|
1711
|
+
onPressOut: (event) => {
|
|
1712
|
+
fadeTo(resting, 250, true);
|
|
1713
|
+
onPressOut?.(event);
|
|
1714
|
+
}
|
|
1715
|
+
}), [
|
|
1716
|
+
activeOpacity,
|
|
1717
|
+
delayLongPress,
|
|
1718
|
+
delayPressIn,
|
|
1719
|
+
delayPressOut,
|
|
1720
|
+
fadeTo,
|
|
1721
|
+
hitSlop,
|
|
1722
|
+
onBlur,
|
|
1723
|
+
onFocus,
|
|
1724
|
+
onLongPress,
|
|
1725
|
+
onPress,
|
|
1726
|
+
onPressIn,
|
|
1727
|
+
onPressOut,
|
|
1728
|
+
pressRetentionOffset,
|
|
1729
|
+
rejectResponderTermination,
|
|
1730
|
+
resolvedDisabled,
|
|
1731
|
+
resting,
|
|
1732
|
+
touchSoundDisabled
|
|
1733
|
+
]));
|
|
1734
|
+
const registry = useStyleRegistry();
|
|
1735
|
+
const previous = useRef({
|
|
1736
|
+
disabled,
|
|
1737
|
+
resting
|
|
1738
|
+
});
|
|
1739
|
+
useEffect(() => {
|
|
1740
|
+
if (previous.current.disabled === disabled && previous.current.resting === resting) return;
|
|
1741
|
+
previous.current = {
|
|
1742
|
+
disabled,
|
|
1743
|
+
resting
|
|
1527
1744
|
};
|
|
1745
|
+
fadeTo(resting, 250, true);
|
|
1528
1746
|
}, [
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1747
|
+
disabled,
|
|
1748
|
+
fadeTo,
|
|
1749
|
+
resting
|
|
1532
1750
|
]);
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1751
|
+
useEffect(() => () => {
|
|
1752
|
+
animation.current?.cancel();
|
|
1753
|
+
}, []);
|
|
1754
|
+
const view = useViewElement({
|
|
1755
|
+
...rest,
|
|
1756
|
+
...mergeHandlers(rest, handlers),
|
|
1757
|
+
ref: element,
|
|
1758
|
+
focusable: focusable !== false && onPress !== void 0 && disabled !== true,
|
|
1759
|
+
style: [style, rejectResponderTermination === true && notCancelableStyle$2],
|
|
1760
|
+
children,
|
|
1761
|
+
...resolvedDisabled === true && { "aria-disabled": true }
|
|
1762
|
+
}, hitSlopClass(registry, hitSlop));
|
|
1763
|
+
useImperativeHandle(ref, () => element.current, []);
|
|
1764
|
+
return view;
|
|
1765
|
+
}
|
|
1766
|
+
// src/components/Button/index.tsx
|
|
1767
|
+
function Button(props) {
|
|
1768
|
+
const { accessibilityActions: _accessibilityActions, accessibilityLanguage, accessibilityState, "aria-disabled": ariaDisabled, color, importantForAccessibility, onAccessibilityAction: _onAccessibilityAction, title, ...rest } = props;
|
|
1769
|
+
if (typeof title !== "string") throw new Error("The title prop of a Button must be a string");
|
|
1770
|
+
const disabled = props.disabled ?? ariaDisabled ?? accessibilityState?.disabled;
|
|
1771
|
+
const state = disabled === accessibilityState?.disabled ? accessibilityState : {
|
|
1772
|
+
...accessibilityState,
|
|
1773
|
+
disabled
|
|
1774
|
+
};
|
|
1775
|
+
return /* @__PURE__ */ jsx(TouchableOpacity, {
|
|
1776
|
+
...rest,
|
|
1777
|
+
...accessibilityLanguage !== void 0 && { lang: accessibilityLanguage },
|
|
1778
|
+
role: "button",
|
|
1779
|
+
accessibilityState: state,
|
|
1780
|
+
disabled,
|
|
1781
|
+
importantForAccessibility: importantForAccessibility === "no" ? "no-hide-descendants" : importantForAccessibility,
|
|
1782
|
+
style: [
|
|
1783
|
+
styles$1.button,
|
|
1784
|
+
color != null && color !== "" && { backgroundColor: color },
|
|
1785
|
+
disabled === true && styles$1.buttonDisabled
|
|
1786
|
+
],
|
|
1787
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
1788
|
+
style: [styles$1.text, disabled === true && styles$1.textDisabled],
|
|
1789
|
+
children: title
|
|
1552
1790
|
})
|
|
1553
1791
|
});
|
|
1554
|
-
return /* @__PURE__ */ jsxs(View, {
|
|
1555
|
-
ref: setElement,
|
|
1556
|
-
style,
|
|
1557
|
-
children: [element, separator]
|
|
1558
|
-
});
|
|
1559
1792
|
}
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1793
|
+
const styles$1 = StyleSheet.create({
|
|
1794
|
+
button: {
|
|
1795
|
+
backgroundColor: "#2196F3",
|
|
1796
|
+
borderRadius: 2
|
|
1797
|
+
},
|
|
1798
|
+
text: {
|
|
1799
|
+
color: "white",
|
|
1800
|
+
fontWeight: "500",
|
|
1801
|
+
margin: 8,
|
|
1802
|
+
textAlign: "center"
|
|
1803
|
+
},
|
|
1804
|
+
buttonDisabled: { backgroundColor: "#dfdfdf" },
|
|
1805
|
+
textDisabled: { color: "#a1a1a1" }
|
|
1806
|
+
});
|
|
1807
|
+
// src/components/ScrollView/snap.ts
|
|
1808
|
+
const nearest = (offset, candidates) => {
|
|
1809
|
+
let best;
|
|
1810
|
+
let distance = Infinity;
|
|
1811
|
+
for (const candidate of candidates) {
|
|
1812
|
+
const d = Math.abs(candidate - offset);
|
|
1813
|
+
if (d < distance) {
|
|
1814
|
+
distance = d;
|
|
1815
|
+
best = candidate;
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
return best;
|
|
1819
|
+
};
|
|
1820
|
+
const snapTarget = (offset, viewport, contentSize, config) => {
|
|
1821
|
+
const max = Math.max(0, contentSize - viewport);
|
|
1822
|
+
let target;
|
|
1823
|
+
if (config.offsets !== void 0) {
|
|
1824
|
+
if (config.offsets.length === 0) return void 0;
|
|
1825
|
+
const first = Math.min(...config.offsets);
|
|
1826
|
+
const last = Math.max(...config.offsets);
|
|
1827
|
+
if (!config.snapToStart && offset < first) return void 0;
|
|
1828
|
+
if (!config.snapToEnd && offset > last) return void 0;
|
|
1829
|
+
const candidates = [...config.offsets];
|
|
1830
|
+
if (config.snapToStart) candidates.push(0);
|
|
1831
|
+
if (config.snapToEnd) candidates.push(max);
|
|
1832
|
+
target = nearest(offset, candidates);
|
|
1833
|
+
} else if (config.interval !== void 0 && config.interval > 0) {
|
|
1834
|
+
const { interval, alignment } = config;
|
|
1835
|
+
const shift = alignment === "center" ? (viewport - interval) / 2 : alignment === "end" ? viewport - interval : 0;
|
|
1836
|
+
target = Math.round((offset + shift) / interval) * interval - shift;
|
|
1837
|
+
}
|
|
1838
|
+
if (target === void 0) return void 0;
|
|
1839
|
+
target = Math.min(max, Math.max(0, target));
|
|
1840
|
+
return Math.abs(target - offset) < .5 ? void 0 : target;
|
|
1841
|
+
};
|
|
1842
|
+
// src/components/ScrollView/index.tsx
|
|
1843
|
+
const scrollerStyle = Object.freeze({
|
|
1844
|
+
flexGrow: 1,
|
|
1845
|
+
flexShrink: 1,
|
|
1846
|
+
overflowX: "hidden",
|
|
1847
|
+
overflowY: "auto",
|
|
1848
|
+
WebkitOverflowScrolling: "touch"
|
|
1849
|
+
});
|
|
1850
|
+
const horizontalScrollerStyle = Object.freeze({
|
|
1851
|
+
flexDirection: "row",
|
|
1852
|
+
overflowX: "auto",
|
|
1853
|
+
overflowY: "hidden"
|
|
1854
|
+
});
|
|
1855
|
+
const disabledScrollerStyle = Object.freeze({
|
|
1856
|
+
overflowX: "hidden",
|
|
1857
|
+
overflowY: "hidden"
|
|
1858
|
+
});
|
|
1859
|
+
const horizontalContentStyle = Object.freeze({ flexDirection: "row" });
|
|
1860
|
+
const centerContentStyle = Object.freeze({
|
|
1861
|
+
flexGrow: 1,
|
|
1862
|
+
justifyContent: "center"
|
|
1863
|
+
});
|
|
1864
|
+
const stickyStyle = Object.freeze({
|
|
1865
|
+
position: "sticky",
|
|
1866
|
+
top: 0,
|
|
1867
|
+
zIndex: 10
|
|
1868
|
+
});
|
|
1869
|
+
const invertedStickyStyle = Object.freeze({
|
|
1870
|
+
position: "sticky",
|
|
1871
|
+
bottom: 0,
|
|
1872
|
+
zIndex: 10
|
|
1873
|
+
});
|
|
1874
|
+
const hiddenScrollbarClass = (registry) => registry.staticClass("rn-scrollbar-none", [".rn-scrollbar-none{scrollbar-width:none;-ms-overflow-style:none}", ".rn-scrollbar-none::-webkit-scrollbar{display:none}"]);
|
|
1875
|
+
const supportsScrollEnd = hasDOM() && "onscrollend" in window;
|
|
1876
|
+
const SCROLL_END_DELAY = 150;
|
|
1877
|
+
const behaviorFor = (animated) => animated !== false && !Platform.isDisableAnimations ? "smooth" : "auto";
|
|
1878
|
+
const describe = (element) => ({
|
|
1879
|
+
contentInset: {
|
|
1880
|
+
top: 0,
|
|
1881
|
+
left: 0,
|
|
1882
|
+
bottom: 0,
|
|
1883
|
+
right: 0
|
|
1884
|
+
},
|
|
1885
|
+
contentOffset: {
|
|
1886
|
+
x: element.scrollLeft,
|
|
1887
|
+
y: element.scrollTop
|
|
1888
|
+
},
|
|
1889
|
+
contentSize: {
|
|
1890
|
+
width: element.scrollWidth,
|
|
1891
|
+
height: element.scrollHeight
|
|
1892
|
+
},
|
|
1893
|
+
layoutMeasurement: {
|
|
1894
|
+
width: element.clientWidth,
|
|
1895
|
+
height: element.clientHeight
|
|
1896
|
+
},
|
|
1897
|
+
zoomScale: 1
|
|
1898
|
+
});
|
|
1899
|
+
const isReactNativeScrollTo = (value) => typeof value === "object" && value !== null && ("x" in value || "y" in value || "animated" in value);
|
|
1900
|
+
const domScrollTo = (element, options) => {
|
|
1901
|
+
const init = { behavior: behaviorFor(options.animated) };
|
|
1902
|
+
if (options.x !== void 0) init.left = options.x;
|
|
1903
|
+
if (options.y !== void 0) init.top = options.y;
|
|
1904
|
+
element.scrollTo(init);
|
|
1570
1905
|
};
|
|
1571
|
-
function
|
|
1572
|
-
const {
|
|
1573
|
-
|
|
1574
|
-
const
|
|
1906
|
+
function ScrollView(props) {
|
|
1907
|
+
const { centerContent, children, contentContainerStyle, contentOffset, horizontal = false, invertStickyHeaders, keyboardDismissMode, onContentSizeChange, onMomentumScrollBegin, onMomentumScrollEnd, onPointerDown, onScroll, onScrollBeginDrag, onScrollEndDrag, pagingEnabled, ref, refreshControl, scrollEnabled = true, showsHorizontalScrollIndicator = true, showsVerticalScrollIndicator = true, snapToAlignment = "start", snapToEnd = true, snapToInterval, snapToOffsets, snapToStart = true, stickyHeaderHiddenOnScroll, stickyHeaderIndices, style, alwaysBounceHorizontal: _alwaysBounceHorizontal, alwaysBounceVertical: _alwaysBounceVertical, automaticallyAdjustContentInsets: _automaticallyAdjustContentInsets, automaticallyAdjustKeyboardInsets: _automaticallyAdjustKeyboardInsets, automaticallyAdjustsScrollIndicatorInsets: _automaticallyAdjustsScrollIndicatorInsets, bounces: _bounces, bouncesZoom: _bouncesZoom, canCancelContentTouches: _canCancelContentTouches, contentInset: _contentInset, contentInsetAdjustmentBehavior: _contentInsetAdjustmentBehavior, decelerationRate: _decelerationRate, directionalLockEnabled: _directionalLockEnabled, disableIntervalMomentum: _disableIntervalMomentum, disableScrollViewPanResponder: _disableScrollViewPanResponder, endFillColor: _endFillColor, fadingEdgeLength: _fadingEdgeLength, indicatorStyle: _indicatorStyle, keyboardShouldPersistTaps: _keyboardShouldPersistTaps, maintainVisibleContentPosition: _maintainVisibleContentPosition, maximumZoomScale: _maximumZoomScale, minimumZoomScale: _minimumZoomScale, nestedScrollEnabled: _nestedScrollEnabled, onScrollToTop: _onScrollToTop, overScrollMode: _overScrollMode, persistentScrollbar: _persistentScrollbar, pinchGestureEnabled: _pinchGestureEnabled, removeClippedSubviews: _removeClippedSubviews, scrollEventThrottle: _scrollEventThrottle, scrollIndicatorInsets: _scrollIndicatorInsets, scrollPerfTag: _scrollPerfTag, scrollToOverflowEnabled: _scrollToOverflowEnabled, scrollsToTop: _scrollsToTop, snapToIntervalMomentum: _snapToIntervalMomentum, zoomScale: _zoomScale, ...rest } = props;
|
|
1908
|
+
const registry = useStyleRegistry();
|
|
1909
|
+
const scroller = useRef(null);
|
|
1910
|
+
const content = useRef(null);
|
|
1911
|
+
const handlers = useRef({});
|
|
1575
1912
|
useEffect(() => {
|
|
1576
|
-
|
|
1913
|
+
handlers.current = {
|
|
1914
|
+
onScroll,
|
|
1915
|
+
onScrollBeginDrag,
|
|
1916
|
+
onScrollEndDrag,
|
|
1917
|
+
onMomentumScrollBegin,
|
|
1918
|
+
onMomentumScrollEnd
|
|
1919
|
+
};
|
|
1577
1920
|
});
|
|
1578
|
-
const
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1921
|
+
const snap = useRef({
|
|
1922
|
+
horizontal,
|
|
1923
|
+
pagingEnabled: pagingEnabled === true,
|
|
1924
|
+
snapToInterval,
|
|
1925
|
+
snapToOffsets,
|
|
1926
|
+
snapToAlignment,
|
|
1927
|
+
snapToStart,
|
|
1928
|
+
snapToEnd,
|
|
1929
|
+
keyboardDismissMode,
|
|
1930
|
+
stickyHeaderHiddenOnScroll: stickyHeaderHiddenOnScroll === true
|
|
1585
1931
|
});
|
|
1586
1932
|
useEffect(() => {
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
const rowAt = (index) => {
|
|
1598
|
-
if (numColumns === 1) return items[index];
|
|
1599
|
-
const row = [];
|
|
1600
|
-
for (let column = 0; column < numColumns; column++) {
|
|
1601
|
-
const itemIndex = index * numColumns + column;
|
|
1602
|
-
if (itemIndex < items.length) row.push(items[itemIndex]);
|
|
1603
|
-
}
|
|
1604
|
-
return row;
|
|
1605
|
-
};
|
|
1606
|
-
const rowKey = (row, index) => {
|
|
1607
|
-
if (numColumns === 1) return keyExtractor(row, index);
|
|
1608
|
-
return row.map((item, column) => keyExtractor(item, index * numColumns + column)).join(":");
|
|
1609
|
-
};
|
|
1610
|
-
const metricsAt = useCallback((index) => {
|
|
1611
|
-
const element = cells.get(index);
|
|
1612
|
-
const { horizontal: isHorizontal = false, getItemLayout, data: currentData } = latest.current;
|
|
1613
|
-
if (element !== void 0) return isHorizontal ? {
|
|
1614
|
-
offset: element.offsetLeft,
|
|
1615
|
-
length: element.offsetWidth
|
|
1616
|
-
} : {
|
|
1617
|
-
offset: element.offsetTop,
|
|
1618
|
-
length: element.offsetHeight
|
|
1619
|
-
};
|
|
1620
|
-
const layout = getItemLayout?.(currentData, index);
|
|
1621
|
-
return layout === void 0 ? void 0 : {
|
|
1622
|
-
offset: layout.offset,
|
|
1623
|
-
length: layout.length
|
|
1624
|
-
};
|
|
1625
|
-
}, [cells]);
|
|
1626
|
-
const maybeCallOnEdgeReached = useCallback(() => {
|
|
1627
|
-
const element = scroller.current;
|
|
1628
|
-
if (element === null) return;
|
|
1629
|
-
const { horizontal: isHorizontal = false, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold } = latest.current;
|
|
1630
|
-
const visibleLength = isHorizontal ? element.clientWidth : element.clientHeight;
|
|
1631
|
-
const contentLength = isHorizontal ? element.scrollWidth : element.scrollHeight;
|
|
1632
|
-
if (visibleLength === 0 || contentLength === 0) return;
|
|
1633
|
-
const offset = isHorizontal ? element.scrollLeft : element.scrollTop;
|
|
1634
|
-
let distanceFromStart = offset;
|
|
1635
|
-
let distanceFromEnd = contentLength - visibleLength - offset;
|
|
1636
|
-
if (distanceFromStart < ON_EDGE_REACHED_EPSILON) distanceFromStart = 0;
|
|
1637
|
-
if (distanceFromEnd < ON_EDGE_REACHED_EPSILON) distanceFromEnd = 0;
|
|
1638
|
-
const startThreshold = onStartReachedThreshold != null ? onStartReachedThreshold * visibleLength : DEFAULT_EDGE_THRESHOLD_PX;
|
|
1639
|
-
const endThreshold = onEndReachedThreshold != null ? onEndReachedThreshold * visibleLength : DEFAULT_EDGE_THRESHOLD_PX;
|
|
1640
|
-
const withinStart = distanceFromStart <= startThreshold;
|
|
1641
|
-
const withinEnd = distanceFromEnd <= endThreshold;
|
|
1642
|
-
const state = edge.current;
|
|
1643
|
-
if (onEndReached != null && withinEnd && contentLength !== state.sentEndForContentLength) {
|
|
1644
|
-
state.sentEndForContentLength = contentLength;
|
|
1645
|
-
onEndReached({ distanceFromEnd });
|
|
1646
|
-
}
|
|
1647
|
-
if (onStartReached != null && withinStart && contentLength !== state.sentStartForContentLength) {
|
|
1648
|
-
state.sentStartForContentLength = contentLength;
|
|
1649
|
-
onStartReached({ distanceFromStart });
|
|
1650
|
-
}
|
|
1651
|
-
if (!withinStart) state.sentStartForContentLength = 0;
|
|
1652
|
-
if (!withinEnd) state.sentEndForContentLength = 0;
|
|
1653
|
-
}, []);
|
|
1654
|
-
const updateViewability = useCallback(() => {
|
|
1655
|
-
const element = scroller.current;
|
|
1656
|
-
if (element === null || trackers.length === 0) return;
|
|
1657
|
-
const current = latest.current;
|
|
1658
|
-
const isHorizontal = current.horizontal === true;
|
|
1659
|
-
const columns = current.numColumns ?? 1;
|
|
1660
|
-
const extract = current.keyExtractor ?? defaultKeyExtractor;
|
|
1661
|
-
const currentItems = isArrayLike(current.data) ? current.data : [];
|
|
1662
|
-
const count = columns > 1 ? Math.ceil(currentItems.length / columns) : currentItems.length;
|
|
1663
|
-
const createToken = (index, isViewable) => {
|
|
1664
|
-
if (columns === 1) {
|
|
1665
|
-
const item = currentItems[index];
|
|
1666
|
-
return {
|
|
1667
|
-
item,
|
|
1668
|
-
key: extract(item, index),
|
|
1669
|
-
index,
|
|
1670
|
-
isViewable
|
|
1671
|
-
};
|
|
1672
|
-
}
|
|
1673
|
-
const row = [];
|
|
1674
|
-
for (let column = 0; column < columns; column++) {
|
|
1675
|
-
const itemIndex = index * columns + column;
|
|
1676
|
-
if (itemIndex < currentItems.length) row.push(currentItems[itemIndex]);
|
|
1677
|
-
}
|
|
1678
|
-
return {
|
|
1679
|
-
item: row,
|
|
1680
|
-
key: row.map((item, column) => extract(item, index * columns + column)).join(":"),
|
|
1681
|
-
index,
|
|
1682
|
-
isViewable
|
|
1683
|
-
};
|
|
1684
|
-
};
|
|
1685
|
-
const expand = (tokens) => {
|
|
1686
|
-
if (columns === 1) return tokens;
|
|
1687
|
-
const out = [];
|
|
1688
|
-
for (const token of tokens) token.item.forEach((item, column) => {
|
|
1689
|
-
const index = (token.index ?? 0) * columns + column;
|
|
1690
|
-
out.push({
|
|
1691
|
-
...token,
|
|
1692
|
-
item,
|
|
1693
|
-
key: extract(item, index),
|
|
1694
|
-
index
|
|
1695
|
-
});
|
|
1696
|
-
});
|
|
1697
|
-
return out;
|
|
1933
|
+
snap.current = {
|
|
1934
|
+
horizontal,
|
|
1935
|
+
pagingEnabled: pagingEnabled === true,
|
|
1936
|
+
snapToInterval,
|
|
1937
|
+
snapToOffsets,
|
|
1938
|
+
snapToAlignment,
|
|
1939
|
+
snapToStart,
|
|
1940
|
+
snapToEnd,
|
|
1941
|
+
keyboardDismissMode,
|
|
1942
|
+
stickyHeaderHiddenOnScroll: stickyHeaderHiddenOnScroll === true
|
|
1698
1943
|
};
|
|
1699
|
-
const offset = isHorizontal ? element.scrollLeft : element.scrollTop;
|
|
1700
|
-
const viewport = isHorizontal ? element.clientWidth : element.clientHeight;
|
|
1701
|
-
for (const entry of trackers) {
|
|
1702
|
-
const handler = entry.callback(current);
|
|
1703
|
-
if (handler == null) continue;
|
|
1704
|
-
entry.tracker.onUpdate(count, metricsAt, offset, viewport, createToken, (info) => {
|
|
1705
|
-
handler({
|
|
1706
|
-
viewableItems: expand(info.viewableItems),
|
|
1707
|
-
changed: expand(info.changed)
|
|
1708
|
-
});
|
|
1709
|
-
});
|
|
1710
|
-
}
|
|
1711
|
-
}, [metricsAt, trackers]);
|
|
1712
|
-
const handleScroll = useCallback((event) => {
|
|
1713
|
-
latest.current.onScroll?.(event);
|
|
1714
|
-
maybeCallOnEdgeReached();
|
|
1715
|
-
updateViewability();
|
|
1716
|
-
}, [maybeCallOnEdgeReached, updateViewability]);
|
|
1717
|
-
const handleContentSizeChange = useCallback((width, height) => {
|
|
1718
|
-
latest.current.onContentSizeChange?.(width, height);
|
|
1719
|
-
maybeCallOnEdgeReached();
|
|
1720
|
-
updateViewability();
|
|
1721
|
-
}, [maybeCallOnEdgeReached, updateViewability]);
|
|
1722
|
-
const handleLayout = useCallback((event) => {
|
|
1723
|
-
latest.current.onLayout?.(event);
|
|
1724
|
-
maybeCallOnEdgeReached();
|
|
1725
|
-
updateViewability();
|
|
1726
|
-
}, [maybeCallOnEdgeReached, updateViewability]);
|
|
1727
|
-
useEffect(() => {
|
|
1728
|
-
updateViewability();
|
|
1729
1944
|
});
|
|
1730
|
-
const
|
|
1945
|
+
const sequence = useRef({
|
|
1946
|
+
phase: "idle",
|
|
1947
|
+
pointerDown: false,
|
|
1948
|
+
lastEvent: null,
|
|
1949
|
+
lastOffset: 0,
|
|
1950
|
+
timer: void 0,
|
|
1951
|
+
snapping: false
|
|
1952
|
+
});
|
|
1953
|
+
const stickyHeaders = useRef([]);
|
|
1954
|
+
const refreshEvent = useCallback(() => {
|
|
1955
|
+
const state = sequence.current;
|
|
1731
1956
|
const element = scroller.current;
|
|
1732
|
-
if (element === null) return;
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
animated
|
|
1736
|
-
} : {
|
|
1737
|
-
y: offset,
|
|
1738
|
-
animated
|
|
1739
|
-
});
|
|
1957
|
+
if (state.lastEvent === null || element === null) return null;
|
|
1958
|
+
Object.assign(state.lastEvent.nativeEvent, describe(element));
|
|
1959
|
+
return state.lastEvent;
|
|
1740
1960
|
}, []);
|
|
1741
|
-
const
|
|
1742
|
-
const
|
|
1743
|
-
const columns = current.numColumns ?? 1;
|
|
1744
|
-
const currentItems = isArrayLike(current.data) ? current.data : [];
|
|
1745
|
-
const count = columns > 1 ? Math.ceil(currentItems.length / columns) : currentItems.length;
|
|
1746
|
-
const { animated, index, viewOffset, viewPosition } = params;
|
|
1747
|
-
if (index < 0) throw new Error(`scrollToIndex out of range: requested index ${index} but minimum is 0`);
|
|
1748
|
-
if (count < 1) throw new Error(`scrollToIndex out of range: item length ${count} but minimum is 1`);
|
|
1749
|
-
if (index >= count) throw new Error(`scrollToIndex out of range: requested index ${index} is out of 0 to ${count - 1}`);
|
|
1750
|
-
const frame = metricsAt(Math.floor(index));
|
|
1961
|
+
const settle = useCallback(() => {
|
|
1962
|
+
const state = sequence.current;
|
|
1751
1963
|
const element = scroller.current;
|
|
1752
|
-
if (
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1964
|
+
if (element === null) return;
|
|
1965
|
+
if (state.pointerDown && state.phase === "drag") return;
|
|
1966
|
+
if (state.phase === "momentum") {
|
|
1967
|
+
const event = refreshEvent();
|
|
1968
|
+
if (event !== null) handlers.current.onMomentumScrollEnd?.(event);
|
|
1969
|
+
}
|
|
1970
|
+
state.phase = "idle";
|
|
1971
|
+
if (state.snapping) {
|
|
1972
|
+
state.snapping = false;
|
|
1760
1973
|
return;
|
|
1761
1974
|
}
|
|
1762
|
-
const
|
|
1763
|
-
const
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1975
|
+
const config = snap.current;
|
|
1976
|
+
const axis = config.horizontal;
|
|
1977
|
+
const viewport = axis ? element.clientWidth : element.clientHeight;
|
|
1978
|
+
const target = snapTarget(axis ? element.scrollLeft : element.scrollTop, viewport, axis ? element.scrollWidth : element.scrollHeight, {
|
|
1979
|
+
offsets: config.snapToOffsets,
|
|
1980
|
+
interval: config.pagingEnabled ? viewport : config.snapToInterval,
|
|
1981
|
+
alignment: config.snapToAlignment,
|
|
1982
|
+
snapToStart: config.snapToStart,
|
|
1983
|
+
snapToEnd: config.snapToEnd
|
|
1984
|
+
});
|
|
1985
|
+
if (target === void 0) return;
|
|
1986
|
+
state.snapping = true;
|
|
1987
|
+
domScrollTo(element, axis ? { x: target } : { y: target });
|
|
1988
|
+
}, [refreshEvent]);
|
|
1989
|
+
const handleScroll = (event) => {
|
|
1990
|
+
const element = event.currentTarget;
|
|
1991
|
+
if (event.target !== element) return;
|
|
1992
|
+
const state = sequence.current;
|
|
1993
|
+
const scrollEvent = event;
|
|
1994
|
+
Object.assign(scrollEvent.nativeEvent, describe(element));
|
|
1995
|
+
state.lastEvent = scrollEvent;
|
|
1996
|
+
const config = snap.current;
|
|
1997
|
+
const offset = config.horizontal ? element.scrollLeft : element.scrollTop;
|
|
1998
|
+
const delta = offset - state.lastOffset;
|
|
1999
|
+
state.lastOffset = offset;
|
|
2000
|
+
if (state.phase === "idle") {
|
|
2001
|
+
if (state.pointerDown) {
|
|
2002
|
+
state.phase = "drag";
|
|
2003
|
+
handlers.current.onScrollBeginDrag?.(scrollEvent);
|
|
2004
|
+
if (config.keyboardDismissMode === "on-drag") {
|
|
2005
|
+
const active = document.activeElement;
|
|
2006
|
+
if (active instanceof HTMLElement && active !== document.body) active.blur();
|
|
2007
|
+
}
|
|
2008
|
+
} else {
|
|
2009
|
+
state.phase = "momentum";
|
|
2010
|
+
handlers.current.onMomentumScrollBegin?.(scrollEvent);
|
|
1780
2011
|
}
|
|
1781
|
-
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
useLayoutEffect(() => {
|
|
1798
|
-
const index = latest.current.initialScrollIndex;
|
|
1799
|
-
const element = scroller.current;
|
|
1800
|
-
if (index == null || element === null) return;
|
|
1801
|
-
const frame = metricsAt(index);
|
|
1802
|
-
if (frame === void 0) return;
|
|
1803
|
-
if (latest.current.horizontal === true) element.scrollLeft = frame.offset;
|
|
1804
|
-
else element.scrollTop = frame.offset;
|
|
1805
|
-
}, [metricsAt]);
|
|
1806
|
-
const inversionStyle = inverted ? horizontal ? horizontallyInvertedStyle : verticallyInvertedStyle : void 0;
|
|
1807
|
-
const cellStyle = inversionStyle ? horizontal ? [rowReverseStyle, inversionStyle] : [columnReverseStyle, inversionStyle] : horizontal ? rowStyle : void 0;
|
|
1808
|
-
const renderOne = (info) => {
|
|
1809
|
-
if (ListItemComponent !== void 0) return /* @__PURE__ */ jsx(ListItemComponent, { ...info });
|
|
1810
|
-
if (renderItem != null) return renderItem(info);
|
|
1811
|
-
throw new Error("FlatList: Either ListItemComponent or renderItem props are required but none were found.");
|
|
2012
|
+
} else if (state.phase === "released") {
|
|
2013
|
+
state.phase = "momentum";
|
|
2014
|
+
handlers.current.onMomentumScrollBegin?.(scrollEvent);
|
|
2015
|
+
}
|
|
2016
|
+
if (config.stickyHeaderHiddenOnScroll && !config.horizontal && delta !== 0) {
|
|
2017
|
+
const hidden = delta > 0;
|
|
2018
|
+
for (const header of stickyHeaders.current) {
|
|
2019
|
+
header.style.transition = "transform 150ms";
|
|
2020
|
+
header.style.transform = hidden ? "translateY(-100%)" : "";
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
handlers.current.onScroll?.(scrollEvent);
|
|
2024
|
+
if (!supportsScrollEnd) {
|
|
2025
|
+
if (state.timer !== void 0) clearTimeout(state.timer);
|
|
2026
|
+
state.timer = setTimeout(settle, SCROLL_END_DELAY);
|
|
2027
|
+
}
|
|
1812
2028
|
};
|
|
1813
|
-
const
|
|
1814
|
-
if (
|
|
1815
|
-
|
|
1816
|
-
index,
|
|
1817
|
-
separators
|
|
1818
|
-
});
|
|
1819
|
-
return /* @__PURE__ */ jsx(View, {
|
|
1820
|
-
style: [rowStyle, columnWrapperStyle],
|
|
1821
|
-
children: row.map((item, column) => {
|
|
1822
|
-
const element = renderOne({
|
|
1823
|
-
item,
|
|
1824
|
-
index: index * numColumns + column,
|
|
1825
|
-
separators
|
|
1826
|
-
});
|
|
1827
|
-
return element == null ? null : /* @__PURE__ */ jsx(Fragment, { children: element }, column);
|
|
1828
|
-
})
|
|
1829
|
-
});
|
|
2029
|
+
const handleScrollEnd = (event) => {
|
|
2030
|
+
if (event.target !== event.currentTarget) return;
|
|
2031
|
+
settle();
|
|
1830
2032
|
};
|
|
1831
|
-
const
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
prevCellKey,
|
|
1849
|
-
index,
|
|
1850
|
-
item: row,
|
|
1851
|
-
style: cellStyle,
|
|
1852
|
-
renderCell,
|
|
1853
|
-
ItemSeparatorComponent: index < rowCount - 1 ? ItemSeparatorComponent : void 0,
|
|
1854
|
-
CellRendererComponent,
|
|
1855
|
-
separatorUpdaters,
|
|
1856
|
-
onElement
|
|
1857
|
-
}, cellKey));
|
|
1858
|
-
prevCellKey = cellKey;
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
if (ListFooterComponent != null) children.push(/* @__PURE__ */ jsx(View, {
|
|
1862
|
-
style: [inversionStyle, ListFooterComponentStyle],
|
|
1863
|
-
children: renderListComponent(ListFooterComponent)
|
|
1864
|
-
}, "$footer"));
|
|
1865
|
-
const scrollProps = {
|
|
1866
|
-
...scrollViewProps,
|
|
1867
|
-
horizontal,
|
|
1868
|
-
style: [inversionStyle, style],
|
|
1869
|
-
onScroll: handleScroll,
|
|
1870
|
-
onContentSizeChange: handleContentSizeChange,
|
|
1871
|
-
onLayout: handleLayout,
|
|
1872
|
-
children
|
|
2033
|
+
const handlePointerDown = (event) => {
|
|
2034
|
+
onPointerDown?.(event);
|
|
2035
|
+
const state = sequence.current;
|
|
2036
|
+
if (state.pointerDown) return;
|
|
2037
|
+
state.pointerDown = true;
|
|
2038
|
+
const release = () => {
|
|
2039
|
+
window.removeEventListener("pointerup", release);
|
|
2040
|
+
window.removeEventListener("pointercancel", release);
|
|
2041
|
+
state.pointerDown = false;
|
|
2042
|
+
if (state.phase === "drag") {
|
|
2043
|
+
state.phase = "released";
|
|
2044
|
+
const scrollEvent = refreshEvent();
|
|
2045
|
+
if (scrollEvent !== null) handlers.current.onScrollEndDrag?.(scrollEvent);
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
window.addEventListener("pointerup", release);
|
|
2049
|
+
window.addEventListener("pointercancel", release);
|
|
1873
2050
|
};
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
2051
|
+
useEffect(() => {
|
|
2052
|
+
const state = sequence.current;
|
|
2053
|
+
return () => {
|
|
2054
|
+
if (state.timer !== void 0) clearTimeout(state.timer);
|
|
2055
|
+
};
|
|
2056
|
+
}, []);
|
|
2057
|
+
const onContentLayout = onContentSizeChange === void 0 ? void 0 : (event) => onContentSizeChange(event.nativeEvent.layout.width, event.nativeEvent.layout.height);
|
|
2058
|
+
const stickySet = stickyHeaderIndices !== void 0 && stickyHeaderIndices.length > 0 && !horizontal ? new Set(stickyHeaderIndices) : void 0;
|
|
2059
|
+
const setStickyHeader = useCallback((node) => {
|
|
2060
|
+
const list = stickyHeaders.current;
|
|
2061
|
+
if (node === null) return;
|
|
2062
|
+
if (!list.includes(node)) list.push(node);
|
|
2063
|
+
return () => {
|
|
2064
|
+
const index = list.indexOf(node);
|
|
2065
|
+
if (index !== -1) list.splice(index, 1);
|
|
2066
|
+
};
|
|
2067
|
+
}, []);
|
|
2068
|
+
let items = children;
|
|
2069
|
+
if (stickySet !== void 0) items = Children.toArray(children).map((child, index) => stickySet.has(index) ? /* @__PURE__ */ jsx(View, {
|
|
2070
|
+
ref: setStickyHeader,
|
|
2071
|
+
style: invertStickyHeaders === true ? invertedStickyStyle : stickyStyle,
|
|
2072
|
+
children: child
|
|
2073
|
+
}, isValidElement(child) && child.key !== null ? child.key : `sticky-${index}`) : child);
|
|
2074
|
+
const contentElement = /* @__PURE__ */ jsx(View, {
|
|
2075
|
+
ref: content,
|
|
2076
|
+
onLayout: onContentLayout,
|
|
2077
|
+
style: [
|
|
2078
|
+
horizontal && horizontalContentStyle,
|
|
2079
|
+
centerContent === true && centerContentStyle,
|
|
2080
|
+
contentContainerStyle
|
|
2081
|
+
],
|
|
2082
|
+
children: items
|
|
1882
2083
|
});
|
|
2084
|
+
const hideScrollbar = horizontal ? !showsHorizontalScrollIndicator : !showsVerticalScrollIndicator;
|
|
2085
|
+
const scrollerElement = useViewElement({
|
|
2086
|
+
...rest,
|
|
2087
|
+
ref: scroller,
|
|
2088
|
+
style: [
|
|
2089
|
+
scrollerStyle,
|
|
2090
|
+
horizontal && horizontalScrollerStyle,
|
|
2091
|
+
!scrollEnabled && disabledScrollerStyle,
|
|
2092
|
+
style
|
|
2093
|
+
],
|
|
2094
|
+
onScroll: handleScroll,
|
|
2095
|
+
onScrollEnd: handleScrollEnd,
|
|
2096
|
+
onPointerDown: handlePointerDown,
|
|
2097
|
+
children: contentElement
|
|
2098
|
+
}, hideScrollbar ? hiddenScrollbarClass(registry) : void 0);
|
|
2099
|
+
const offsetX = contentOffset?.x;
|
|
2100
|
+
const offsetY = contentOffset?.y;
|
|
2101
|
+
useLayoutEffect(() => {
|
|
2102
|
+
const element = scroller.current;
|
|
2103
|
+
if (element === null || offsetX === void 0 && offsetY === void 0) return;
|
|
2104
|
+
if (offsetX !== void 0) element.scrollLeft = offsetX;
|
|
2105
|
+
if (offsetY !== void 0) element.scrollTop = offsetY;
|
|
2106
|
+
sequence.current.lastOffset = horizontal ? element.scrollLeft : element.scrollTop;
|
|
2107
|
+
}, [
|
|
2108
|
+
offsetX,
|
|
2109
|
+
offsetY,
|
|
2110
|
+
horizontal
|
|
2111
|
+
]);
|
|
2112
|
+
useImperativeHandle(ref, () => {
|
|
2113
|
+
const element = scroller.current;
|
|
2114
|
+
const nativeScrollTo = element.scrollTo.bind(element);
|
|
2115
|
+
const instance = element;
|
|
2116
|
+
return Object.assign(instance, {
|
|
2117
|
+
scrollTo: ((first, second) => {
|
|
2118
|
+
if (isReactNativeScrollTo(first)) domScrollTo(element, first);
|
|
2119
|
+
else if (typeof first === "number" && typeof second === "number") nativeScrollTo(first, second);
|
|
2120
|
+
else nativeScrollTo(first);
|
|
2121
|
+
}),
|
|
2122
|
+
scrollToEnd: (options) => {
|
|
2123
|
+
const animated = options?.animated;
|
|
2124
|
+
domScrollTo(element, horizontal ? {
|
|
2125
|
+
x: element.scrollWidth,
|
|
2126
|
+
animated
|
|
2127
|
+
} : {
|
|
2128
|
+
y: element.scrollHeight,
|
|
2129
|
+
animated
|
|
2130
|
+
});
|
|
2131
|
+
},
|
|
2132
|
+
flashScrollIndicators: () => {},
|
|
2133
|
+
getScrollResponder: () => instance,
|
|
2134
|
+
getScrollableNode: () => element,
|
|
2135
|
+
getInnerViewNode: () => content.current,
|
|
2136
|
+
getInnerViewRef: () => content.current,
|
|
2137
|
+
getNativeScrollRef: () => element
|
|
2138
|
+
});
|
|
2139
|
+
}, [horizontal]);
|
|
2140
|
+
return refreshControl === void 0 ? scrollerElement : cloneElement(refreshControl, void 0, scrollerElement);
|
|
1883
2141
|
}
|
|
1884
|
-
// src/
|
|
1885
|
-
const
|
|
1886
|
-
const
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
// src/components/Image/source.ts
|
|
1892
|
-
const none = Object.freeze({
|
|
1893
|
-
src: void 0,
|
|
1894
|
-
srcSet: void 0,
|
|
1895
|
-
sizes: void 0,
|
|
1896
|
-
width: void 0,
|
|
1897
|
-
height: void 0,
|
|
1898
|
-
request: void 0
|
|
1899
|
-
});
|
|
1900
|
-
const ASSET_ID_WARNING = "Image: a numeric source is a Metro asset id, which has no meaning here. Import the image file and pass its URL.";
|
|
1901
|
-
const hasURI = (source) => typeof source.uri === "string" && source.uri.length > 0;
|
|
1902
|
-
const requestOf = (source) => {
|
|
1903
|
-
if (source.headers === void 0 && source.method === void 0 && source.body === void 0) return;
|
|
1904
|
-
return {
|
|
1905
|
-
method: source.method ?? "GET",
|
|
1906
|
-
headers: source.headers,
|
|
1907
|
-
body: source.body
|
|
1908
|
-
};
|
|
2142
|
+
// src/components/FlatList/viewability.ts
|
|
2143
|
+
const pixelsVisible = (top, bottom, viewport) => Math.max(0, Math.min(bottom, viewport) - Math.max(top, 0));
|
|
2144
|
+
const isEntirelyVisible = (top, bottom, viewport) => top >= 0 && bottom <= viewport && bottom > top;
|
|
2145
|
+
const isViewable = (viewAreaMode, threshold, top, bottom, viewport, length) => {
|
|
2146
|
+
if (isEntirelyVisible(top, bottom, viewport)) return true;
|
|
2147
|
+
const pixels = pixelsVisible(top, bottom, viewport);
|
|
2148
|
+
return 100 * (viewAreaMode ? pixels / viewport : pixels / length) >= threshold;
|
|
1909
2149
|
};
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
const
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
width: void 0,
|
|
1927
|
-
height: void 0,
|
|
1928
|
-
request: void 0
|
|
1929
|
-
};
|
|
1930
|
-
if (sources.every((s) => typeof s.scale === "number")) {
|
|
1931
|
-
const base = sources.find((s) => s.scale === 1) ?? first;
|
|
1932
|
-
return {
|
|
1933
|
-
src: base.uri,
|
|
1934
|
-
srcSet: sources.map((s) => `${s.uri} ${s.scale}x`).join(", "),
|
|
1935
|
-
sizes: void 0,
|
|
1936
|
-
width: base.width,
|
|
1937
|
-
height: base.height,
|
|
1938
|
-
request: void 0
|
|
1939
|
-
};
|
|
2150
|
+
const computeViewableIndices = (itemCount, metricsAt, scrollOffset, viewport, config) => {
|
|
2151
|
+
const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = config;
|
|
2152
|
+
const viewAreaMode = viewAreaCoveragePercentThreshold != null;
|
|
2153
|
+
const threshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
|
|
2154
|
+
if (threshold == null || viewAreaMode === (itemVisiblePercentThreshold != null)) throw new Error("Must set exactly one of itemVisiblePercentThreshold or viewAreaCoveragePercentThreshold");
|
|
2155
|
+
const viewable = [];
|
|
2156
|
+
let firstVisible = -1;
|
|
2157
|
+
for (let index = 0; index < itemCount; index++) {
|
|
2158
|
+
const metrics = metricsAt(index);
|
|
2159
|
+
if (metrics === void 0) continue;
|
|
2160
|
+
const top = Math.floor(metrics.offset - scrollOffset);
|
|
2161
|
+
const bottom = Math.floor(top + metrics.length);
|
|
2162
|
+
if (top < viewport && bottom > 0) {
|
|
2163
|
+
firstVisible = index;
|
|
2164
|
+
if (isViewable(viewAreaMode, threshold, top, bottom, viewport, metrics.length)) viewable.push(index);
|
|
2165
|
+
} else if (firstVisible >= 0) break;
|
|
1940
2166
|
}
|
|
1941
|
-
return
|
|
2167
|
+
return viewable;
|
|
1942
2168
|
};
|
|
1943
|
-
const
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
if (typeof source === "string") return {
|
|
1952
|
-
...none,
|
|
1953
|
-
src: source
|
|
1954
|
-
};
|
|
1955
|
-
if (typeof source === "number") {
|
|
1956
|
-
warnOnce("image-asset-id", ASSET_ID_WARNING);
|
|
1957
|
-
return none;
|
|
2169
|
+
const sameIndices = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
|
|
2170
|
+
var ViewabilityTracker = class {
|
|
2171
|
+
constructor(config = { viewAreaCoveragePercentThreshold: 0 }) {
|
|
2172
|
+
this.interacted = false;
|
|
2173
|
+
this.timers = /* @__PURE__ */ new Set();
|
|
2174
|
+
this.viewableIndices = [];
|
|
2175
|
+
this.viewableItems = /* @__PURE__ */ new Map();
|
|
2176
|
+
this.config = config;
|
|
1958
2177
|
}
|
|
1959
|
-
|
|
1960
|
-
const
|
|
1961
|
-
|
|
2178
|
+
dispose() {
|
|
2179
|
+
for (const timer of this.timers) clearTimeout(timer);
|
|
2180
|
+
this.timers.clear();
|
|
1962
2181
|
}
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
2182
|
+
recordInteraction() {
|
|
2183
|
+
this.interacted = true;
|
|
2184
|
+
}
|
|
2185
|
+
resetViewableIndices() {
|
|
2186
|
+
this.viewableIndices = [];
|
|
2187
|
+
}
|
|
2188
|
+
onUpdate(itemCount, metricsAt, scrollOffset, viewport, createViewToken, onViewableItemsChanged) {
|
|
2189
|
+
if (this.config.waitForInteraction === true && !this.interacted || itemCount === 0) return;
|
|
2190
|
+
if (metricsAt(0) === void 0) return;
|
|
2191
|
+
const next = computeViewableIndices(itemCount, metricsAt, scrollOffset, viewport, this.config);
|
|
2192
|
+
if (sameIndices(this.viewableIndices, next)) return;
|
|
2193
|
+
this.viewableIndices = next;
|
|
2194
|
+
const { minimumViewTime } = this.config;
|
|
2195
|
+
if (minimumViewTime !== void 0 && minimumViewTime > 0) {
|
|
2196
|
+
const timer = setTimeout(() => {
|
|
2197
|
+
this.timers.delete(timer);
|
|
2198
|
+
if (this.viewableIndices !== next) return;
|
|
2199
|
+
this.report(next, createViewToken, onViewableItemsChanged);
|
|
2200
|
+
}, minimumViewTime);
|
|
2201
|
+
this.timers.add(timer);
|
|
2202
|
+
} else this.report(next, createViewToken, onViewableItemsChanged);
|
|
2203
|
+
}
|
|
2204
|
+
report(indices, createViewToken, onViewableItemsChanged) {
|
|
2205
|
+
const previous = this.viewableItems;
|
|
2206
|
+
const next = /* @__PURE__ */ new Map();
|
|
2207
|
+
for (const index of indices) {
|
|
2208
|
+
const token = createViewToken(index, true);
|
|
2209
|
+
next.set(token.key, token);
|
|
2210
|
+
}
|
|
2211
|
+
const changed = [];
|
|
2212
|
+
for (const [key, token] of next) if (!previous.has(key)) changed.push(token);
|
|
2213
|
+
for (const [key, token] of previous) if (!next.has(key)) changed.push({
|
|
2214
|
+
...token,
|
|
2215
|
+
isViewable: false
|
|
2216
|
+
});
|
|
2217
|
+
if (changed.length === 0) return;
|
|
2218
|
+
this.viewableItems = next;
|
|
2219
|
+
onViewableItemsChanged({
|
|
2220
|
+
viewableItems: Array.from(next.values()),
|
|
2221
|
+
changed
|
|
2222
|
+
});
|
|
1973
2223
|
}
|
|
1974
|
-
const first = Array.isArray(source) ? source[0] : source;
|
|
1975
|
-
if (first === void 0 || first === null || !hasURI(first)) return null;
|
|
1976
|
-
const { uri, width, height, scale } = first;
|
|
1977
|
-
return {
|
|
1978
|
-
uri,
|
|
1979
|
-
width,
|
|
1980
|
-
height,
|
|
1981
|
-
scale: scale ?? 1
|
|
1982
|
-
};
|
|
1983
|
-
};
|
|
1984
|
-
// src/components/Image/index.tsx
|
|
1985
|
-
const boxStyle = Object.freeze({
|
|
1986
|
-
backgroundColor: "transparent",
|
|
1987
|
-
border: "0 solid black",
|
|
1988
|
-
boxSizing: "border-box",
|
|
1989
|
-
display: "flex",
|
|
1990
|
-
flexBasis: "auto",
|
|
1991
|
-
flexDirection: "column",
|
|
1992
|
-
flexShrink: 0,
|
|
1993
|
-
margin: 0,
|
|
1994
|
-
minHeight: 0,
|
|
1995
|
-
minWidth: 0,
|
|
1996
|
-
overflow: "hidden",
|
|
1997
|
-
padding: 0,
|
|
1998
|
-
position: "relative",
|
|
1999
|
-
zIndex: 0
|
|
2000
|
-
});
|
|
2001
|
-
const fillStyle = Object.freeze({
|
|
2002
|
-
position: "absolute",
|
|
2003
|
-
left: 0,
|
|
2004
|
-
top: 0,
|
|
2005
|
-
width: "100%",
|
|
2006
|
-
height: "100%",
|
|
2007
|
-
display: "block",
|
|
2008
|
-
border: 0,
|
|
2009
|
-
margin: 0,
|
|
2010
|
-
padding: 0
|
|
2011
|
-
});
|
|
2012
|
-
const hiddenStyle = Object.freeze({ visibility: "hidden" });
|
|
2013
|
-
const objectFitOf = {
|
|
2014
|
-
cover: "cover",
|
|
2015
|
-
contain: "contain",
|
|
2016
|
-
stretch: "fill",
|
|
2017
|
-
center: "none",
|
|
2018
|
-
repeat: "none"
|
|
2019
|
-
};
|
|
2020
|
-
const resizeModeOfObjectFit = {
|
|
2021
|
-
cover: "cover",
|
|
2022
|
-
contain: "contain",
|
|
2023
|
-
fill: "stretch",
|
|
2024
|
-
"scale-down": "contain",
|
|
2025
|
-
none: "center"
|
|
2026
2224
|
};
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2225
|
+
// src/components/FlatList/index.tsx
|
|
2226
|
+
const rowStyle = Object.freeze({ flexDirection: "row" });
|
|
2227
|
+
const rowReverseStyle = Object.freeze({ flexDirection: "row-reverse" });
|
|
2228
|
+
const columnReverseStyle = Object.freeze({ flexDirection: "column-reverse" });
|
|
2229
|
+
const verticallyInvertedStyle = Object.freeze({ transform: [{ scaleY: -1 }] });
|
|
2230
|
+
const horizontallyInvertedStyle = Object.freeze({ transform: [{ scaleX: -1 }] });
|
|
2231
|
+
const ON_EDGE_REACHED_EPSILON = .001;
|
|
2232
|
+
const DEFAULT_EDGE_THRESHOLD_PX = 2;
|
|
2233
|
+
const defaultKeyExtractor = (item, index) => {
|
|
2234
|
+
if (typeof item === "object" && item !== null) {
|
|
2235
|
+
const record = item;
|
|
2236
|
+
if (record.key != null) return String(record.key);
|
|
2237
|
+
if (record.id != null) return String(record.id);
|
|
2238
|
+
}
|
|
2239
|
+
return String(index);
|
|
2033
2240
|
};
|
|
2034
|
-
const
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
});
|
|
2040
|
-
const placeholderURI = (source) => {
|
|
2041
|
-
if (typeof source === "string") return source;
|
|
2042
|
-
if (typeof source === "object" && source !== null) return source.uri;
|
|
2241
|
+
const isArrayLike = (data) => data != null && typeof data.length === "number";
|
|
2242
|
+
const renderListComponent = (component) => {
|
|
2243
|
+
if (component == null) return null;
|
|
2244
|
+
if (isValidElement(component)) return component;
|
|
2245
|
+
return /* @__PURE__ */ jsx(component, {});
|
|
2043
2246
|
};
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2247
|
+
function CustomScroller({ render, ref, ...props }) {
|
|
2248
|
+
return cloneElement(render(props), { ref }, props.children);
|
|
2249
|
+
}
|
|
2250
|
+
function Cell(props) {
|
|
2251
|
+
const { cellKey, prevCellKey, index, item, style, renderCell, ItemSeparatorComponent, CellRendererComponent, separatorUpdaters, onElement } = props;
|
|
2252
|
+
const [separatorProps, setSeparatorProps] = useState({
|
|
2253
|
+
highlighted: false,
|
|
2254
|
+
leadingItem: item
|
|
2049
2255
|
});
|
|
2050
|
-
const
|
|
2256
|
+
const shown = separatorProps.leadingItem === item ? separatorProps : {
|
|
2257
|
+
...separatorProps,
|
|
2258
|
+
leadingItem: item
|
|
2259
|
+
};
|
|
2051
2260
|
useEffect(() => {
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2261
|
+
separatorUpdaters.set(cellKey, (next) => {
|
|
2262
|
+
setSeparatorProps((current) => ({
|
|
2263
|
+
...current,
|
|
2264
|
+
...next
|
|
2265
|
+
}));
|
|
2266
|
+
});
|
|
2267
|
+
return () => {
|
|
2268
|
+
separatorUpdaters.delete(cellKey);
|
|
2059
2269
|
};
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2270
|
+
}, [cellKey, separatorUpdaters]);
|
|
2271
|
+
const separators = useMemo(() => {
|
|
2272
|
+
const update = (keys, next) => {
|
|
2273
|
+
for (const key of keys) if (key !== void 0) separatorUpdaters.get(key)?.(next);
|
|
2274
|
+
};
|
|
2275
|
+
return {
|
|
2276
|
+
highlight: () => update([cellKey, prevCellKey], { highlighted: true }),
|
|
2277
|
+
unhighlight: () => update([cellKey, prevCellKey], { highlighted: false }),
|
|
2278
|
+
updateProps: (select, next) => update([select === "leading" ? prevCellKey : cellKey], next)
|
|
2279
|
+
};
|
|
2280
|
+
}, [
|
|
2281
|
+
cellKey,
|
|
2282
|
+
prevCellKey,
|
|
2283
|
+
separatorUpdaters
|
|
2284
|
+
]);
|
|
2285
|
+
const setElement = useCallback((node) => {
|
|
2286
|
+
if (node === null) return;
|
|
2287
|
+
onElement(index, node);
|
|
2288
|
+
return () => onElement(index, null);
|
|
2289
|
+
}, [index, onElement]);
|
|
2290
|
+
let separator = null;
|
|
2291
|
+
if (ItemSeparatorComponent != null) {
|
|
2292
|
+
if (isValidElement(ItemSeparatorComponent)) separator = ItemSeparatorComponent;
|
|
2293
|
+
else separator = /* @__PURE__ */ jsx(ItemSeparatorComponent, { ...shown });
|
|
2294
|
+
}
|
|
2295
|
+
const element = renderCell(item, index, separators);
|
|
2296
|
+
if (CellRendererComponent != null) return /* @__PURE__ */ jsx(View, {
|
|
2297
|
+
ref: setElement,
|
|
2298
|
+
children: /* @__PURE__ */ jsxs(CellRendererComponent, {
|
|
2299
|
+
cellKey,
|
|
2300
|
+
index,
|
|
2301
|
+
item,
|
|
2302
|
+
style,
|
|
2303
|
+
children: [element, separator]
|
|
2304
|
+
})
|
|
2305
|
+
});
|
|
2306
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
2307
|
+
ref: setElement,
|
|
2308
|
+
style,
|
|
2309
|
+
children: [element, separator]
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
const createTrackers = (props) => {
|
|
2313
|
+
if (props.viewabilityConfigCallbackPairs !== void 0) return props.viewabilityConfigCallbackPairs.map((pair) => ({
|
|
2314
|
+
tracker: new ViewabilityTracker(pair.viewabilityConfig),
|
|
2315
|
+
callback: () => pair.onViewableItemsChanged
|
|
2316
|
+
}));
|
|
2317
|
+
if (props.onViewableItemsChanged != null) return [{
|
|
2318
|
+
tracker: new ViewabilityTracker(props.viewabilityConfig),
|
|
2319
|
+
callback: (latest) => latest.onViewableItemsChanged
|
|
2320
|
+
}];
|
|
2321
|
+
return [];
|
|
2322
|
+
};
|
|
2323
|
+
function FlatList(props) {
|
|
2324
|
+
const { data, renderItem, ListItemComponent, keyExtractor = defaultKeyExtractor, getItemLayout: _getItemLayout, numColumns = 1, columnWrapperStyle, inverted, initialScrollIndex: _initialScrollIndex, ItemSeparatorComponent, ListEmptyComponent, ListHeaderComponent, ListHeaderComponentStyle, ListFooterComponent, ListFooterComponentStyle, CellRendererComponent, renderScrollComponent, horizontal = false, style, ref, onScroll: _onScroll, onContentSizeChange: _onContentSizeChange, onLayout: _onLayout, onEndReached: _onEndReached, onEndReachedThreshold: _onEndReachedThreshold, onStartReached: _onStartReached, onStartReachedThreshold: _onStartReachedThreshold, onViewableItemsChanged: _onViewableItemsChanged, viewabilityConfig: _viewabilityConfig, viewabilityConfigCallbackPairs: _viewabilityConfigCallbackPairs, onScrollToIndexFailed: _onScrollToIndexFailed, extraData: _extraData, onRefresh: _onRefresh, refreshing: _refreshing, debug: _debug, disableVirtualization: _disableVirtualization, initialNumToRender: _initialNumToRender, maxToRenderPerBatch: _maxToRenderPerBatch, progressViewOffset: _progressViewOffset, strictMode: _strictMode, updateCellsBatchingPeriod: _updateCellsBatchingPeriod, windowSize: _windowSize, legacyImplementation: _legacyImplementation, ...scrollViewProps } = props;
|
|
2325
|
+
if (numColumns > 1 && horizontal) throw new Error("numColumns does not support horizontal.");
|
|
2326
|
+
const latest = useRef(props);
|
|
2327
|
+
useEffect(() => {
|
|
2328
|
+
latest.current = props;
|
|
2329
|
+
});
|
|
2330
|
+
const scroller = useRef(null);
|
|
2331
|
+
const [cells] = useState(() => /* @__PURE__ */ new Map());
|
|
2332
|
+
const [separatorUpdaters] = useState(() => /* @__PURE__ */ new Map());
|
|
2333
|
+
const [trackers] = useState(() => createTrackers(props));
|
|
2334
|
+
const edge = useRef({
|
|
2335
|
+
sentEndForContentLength: 0,
|
|
2336
|
+
sentStartForContentLength: 0
|
|
2337
|
+
});
|
|
2338
|
+
useEffect(() => {
|
|
2339
|
+
return () => {
|
|
2340
|
+
for (const entry of trackers) entry.tracker.dispose();
|
|
2341
|
+
};
|
|
2342
|
+
}, [trackers]);
|
|
2343
|
+
const onElement = useCallback((index, node) => {
|
|
2344
|
+
if (node === null) cells.delete(index);
|
|
2345
|
+
else cells.set(index, node);
|
|
2346
|
+
}, [cells]);
|
|
2347
|
+
const items = isArrayLike(data) ? data : [];
|
|
2348
|
+
const rowCount = numColumns > 1 ? Math.ceil(items.length / numColumns) : items.length;
|
|
2349
|
+
const rowAt = (index) => {
|
|
2350
|
+
if (numColumns === 1) return items[index];
|
|
2351
|
+
const row = [];
|
|
2352
|
+
for (let column = 0; column < numColumns; column++) {
|
|
2353
|
+
const itemIndex = index * numColumns + column;
|
|
2354
|
+
if (itemIndex < items.length) row.push(items[itemIndex]);
|
|
2355
|
+
}
|
|
2356
|
+
return row;
|
|
2357
|
+
};
|
|
2358
|
+
const rowKey = (row, index) => {
|
|
2359
|
+
if (numColumns === 1) return keyExtractor(row, index);
|
|
2360
|
+
return row.map((item, column) => keyExtractor(item, index * numColumns + column)).join(":");
|
|
2361
|
+
};
|
|
2362
|
+
const metricsAt = useCallback((index) => {
|
|
2363
|
+
const element = cells.get(index);
|
|
2364
|
+
const { horizontal: isHorizontal = false, getItemLayout, data: currentData } = latest.current;
|
|
2365
|
+
if (element !== void 0) return isHorizontal ? {
|
|
2366
|
+
offset: element.offsetLeft,
|
|
2367
|
+
length: element.offsetWidth
|
|
2368
|
+
} : {
|
|
2369
|
+
offset: element.offsetTop,
|
|
2370
|
+
length: element.offsetHeight
|
|
2371
|
+
};
|
|
2372
|
+
const layout = getItemLayout?.(currentData, index);
|
|
2373
|
+
return layout === void 0 ? void 0 : {
|
|
2374
|
+
offset: layout.offset,
|
|
2375
|
+
length: layout.length
|
|
2376
|
+
};
|
|
2377
|
+
}, [cells]);
|
|
2378
|
+
const maybeCallOnEdgeReached = useCallback(() => {
|
|
2379
|
+
const element = scroller.current;
|
|
2380
|
+
if (element === null) return;
|
|
2381
|
+
const { horizontal: isHorizontal = false, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold } = latest.current;
|
|
2382
|
+
const visibleLength = isHorizontal ? element.clientWidth : element.clientHeight;
|
|
2383
|
+
const contentLength = isHorizontal ? element.scrollWidth : element.scrollHeight;
|
|
2384
|
+
if (visibleLength === 0 || contentLength === 0) return;
|
|
2385
|
+
const offset = isHorizontal ? element.scrollLeft : element.scrollTop;
|
|
2386
|
+
let distanceFromStart = offset;
|
|
2387
|
+
let distanceFromEnd = contentLength - visibleLength - offset;
|
|
2388
|
+
if (distanceFromStart < ON_EDGE_REACHED_EPSILON) distanceFromStart = 0;
|
|
2389
|
+
if (distanceFromEnd < ON_EDGE_REACHED_EPSILON) distanceFromEnd = 0;
|
|
2390
|
+
const startThreshold = onStartReachedThreshold != null ? onStartReachedThreshold * visibleLength : DEFAULT_EDGE_THRESHOLD_PX;
|
|
2391
|
+
const endThreshold = onEndReachedThreshold != null ? onEndReachedThreshold * visibleLength : DEFAULT_EDGE_THRESHOLD_PX;
|
|
2392
|
+
const withinStart = distanceFromStart <= startThreshold;
|
|
2393
|
+
const withinEnd = distanceFromEnd <= endThreshold;
|
|
2394
|
+
const state = edge.current;
|
|
2395
|
+
if (onEndReached != null && withinEnd && contentLength !== state.sentEndForContentLength) {
|
|
2396
|
+
state.sentEndForContentLength = contentLength;
|
|
2397
|
+
onEndReached({ distanceFromEnd });
|
|
2398
|
+
}
|
|
2399
|
+
if (onStartReached != null && withinStart && contentLength !== state.sentStartForContentLength) {
|
|
2400
|
+
state.sentStartForContentLength = contentLength;
|
|
2401
|
+
onStartReached({ distanceFromStart });
|
|
2402
|
+
}
|
|
2403
|
+
if (!withinStart) state.sentStartForContentLength = 0;
|
|
2404
|
+
if (!withinEnd) state.sentEndForContentLength = 0;
|
|
2405
|
+
}, []);
|
|
2406
|
+
const updateViewability = useCallback(() => {
|
|
2407
|
+
const element = scroller.current;
|
|
2408
|
+
if (element === null || trackers.length === 0) return;
|
|
2409
|
+
const current = latest.current;
|
|
2410
|
+
const isHorizontal = current.horizontal === true;
|
|
2411
|
+
const columns = current.numColumns ?? 1;
|
|
2412
|
+
const extract = current.keyExtractor ?? defaultKeyExtractor;
|
|
2413
|
+
const currentItems = isArrayLike(current.data) ? current.data : [];
|
|
2414
|
+
const count = columns > 1 ? Math.ceil(currentItems.length / columns) : currentItems.length;
|
|
2415
|
+
const createToken = (index, isViewable) => {
|
|
2416
|
+
if (columns === 1) {
|
|
2417
|
+
const item = currentItems[index];
|
|
2418
|
+
return {
|
|
2419
|
+
item,
|
|
2420
|
+
key: extract(item, index),
|
|
2421
|
+
index,
|
|
2422
|
+
isViewable
|
|
2423
|
+
};
|
|
2424
|
+
}
|
|
2425
|
+
const row = [];
|
|
2426
|
+
for (let column = 0; column < columns; column++) {
|
|
2427
|
+
const itemIndex = index * columns + column;
|
|
2428
|
+
if (itemIndex < currentItems.length) row.push(currentItems[itemIndex]);
|
|
2429
|
+
}
|
|
2430
|
+
return {
|
|
2431
|
+
item: row,
|
|
2432
|
+
key: row.map((item, column) => extract(item, index * columns + column)).join(":"),
|
|
2433
|
+
index,
|
|
2434
|
+
isViewable
|
|
2435
|
+
};
|
|
2436
|
+
};
|
|
2437
|
+
const expand = (tokens) => {
|
|
2438
|
+
if (columns === 1) return tokens;
|
|
2439
|
+
const out = [];
|
|
2440
|
+
for (const token of tokens) token.item.forEach((item, column) => {
|
|
2441
|
+
const index = (token.index ?? 0) * columns + column;
|
|
2442
|
+
out.push({
|
|
2443
|
+
...token,
|
|
2444
|
+
item,
|
|
2445
|
+
key: extract(item, index),
|
|
2446
|
+
index
|
|
2447
|
+
});
|
|
2071
2448
|
});
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2449
|
+
return out;
|
|
2450
|
+
};
|
|
2451
|
+
const offset = isHorizontal ? element.scrollLeft : element.scrollTop;
|
|
2452
|
+
const viewport = isHorizontal ? element.clientWidth : element.clientHeight;
|
|
2453
|
+
for (const entry of trackers) {
|
|
2454
|
+
const handler = entry.callback(current);
|
|
2455
|
+
if (handler == null) continue;
|
|
2456
|
+
entry.tracker.onUpdate(count, metricsAt, offset, viewport, createToken, (info) => {
|
|
2457
|
+
handler({
|
|
2458
|
+
viewableItems: expand(info.viewableItems),
|
|
2459
|
+
changed: expand(info.changed)
|
|
2460
|
+
});
|
|
2079
2461
|
});
|
|
2080
|
-
}
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
const registry = useStyleRegistry();
|
|
2098
|
-
const { resizeMode: styleResizeMode, objectFit, tintColor: styleTintColor, overlayColor: _overlayColor, ...userBoxStyle } = flattenStyle(style) ?? {};
|
|
2099
|
-
const resizeMode = (typeof objectFit === "string" ? resizeModeOfObjectFit[objectFit] : void 0) ?? resizeModeProp ?? styleResizeMode ?? "cover";
|
|
2100
|
-
const tintColor = tintColorProp ?? styleTintColor;
|
|
2101
|
-
const painted = resizeMode === "repeat" || tintColor !== void 0;
|
|
2102
|
-
const styleWidth = userBoxStyle["width"] ?? width;
|
|
2103
|
-
const resolved = resolveSource(source, src, srcSet, typeof styleWidth === "number" ? styleWidth : void 0);
|
|
2104
|
-
const requested = useRequestURL(resolved.src, resolved.request);
|
|
2105
|
-
const currentSrc = resolved.request === void 0 ? resolved.src : requested.url;
|
|
2106
|
-
const handlers = useRef({
|
|
2107
|
-
onLoad,
|
|
2108
|
-
onLoadStart,
|
|
2109
|
-
onLoadEnd,
|
|
2110
|
-
onError
|
|
2111
|
-
});
|
|
2462
|
+
}
|
|
2463
|
+
}, [metricsAt, trackers]);
|
|
2464
|
+
const handleScroll = useCallback((event) => {
|
|
2465
|
+
latest.current.onScroll?.(event);
|
|
2466
|
+
maybeCallOnEdgeReached();
|
|
2467
|
+
updateViewability();
|
|
2468
|
+
}, [maybeCallOnEdgeReached, updateViewability]);
|
|
2469
|
+
const handleContentSizeChange = useCallback((width, height) => {
|
|
2470
|
+
latest.current.onContentSizeChange?.(width, height);
|
|
2471
|
+
maybeCallOnEdgeReached();
|
|
2472
|
+
updateViewability();
|
|
2473
|
+
}, [maybeCallOnEdgeReached, updateViewability]);
|
|
2474
|
+
const handleLayout = useCallback((event) => {
|
|
2475
|
+
latest.current.onLayout?.(event);
|
|
2476
|
+
maybeCallOnEdgeReached();
|
|
2477
|
+
updateViewability();
|
|
2478
|
+
}, [maybeCallOnEdgeReached, updateViewability]);
|
|
2112
2479
|
useEffect(() => {
|
|
2113
|
-
|
|
2114
|
-
onLoad,
|
|
2115
|
-
onLoadStart,
|
|
2116
|
-
onLoadEnd,
|
|
2117
|
-
onError
|
|
2118
|
-
};
|
|
2480
|
+
updateViewability();
|
|
2119
2481
|
});
|
|
2120
|
-
const
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
firedFor.current = uri;
|
|
2131
|
-
setLoadedSrc(target.src);
|
|
2132
|
-
const { width: naturalWidth, height: naturalHeight } = sizeOf(target);
|
|
2133
|
-
handlers.current.onLoad?.({ nativeEvent: { source: {
|
|
2134
|
-
uri,
|
|
2135
|
-
width: naturalWidth,
|
|
2136
|
-
height: naturalHeight
|
|
2137
|
-
} } });
|
|
2138
|
-
handlers.current.onLoadEnd?.();
|
|
2139
|
-
}, []);
|
|
2140
|
-
const fireError = useCallback((target) => {
|
|
2141
|
-
const uri = target.currentSrc || target.src;
|
|
2142
|
-
if (firedFor.current === uri) return;
|
|
2143
|
-
firedFor.current = uri;
|
|
2144
|
-
handlers.current.onError?.({ nativeEvent: { error: loadError(uri) } });
|
|
2145
|
-
handlers.current.onLoadEnd?.();
|
|
2482
|
+
const scrollToOffset = useCallback((offset, animated) => {
|
|
2483
|
+
const element = scroller.current;
|
|
2484
|
+
if (element === null) return;
|
|
2485
|
+
element.scrollTo(latest.current.horizontal === true ? {
|
|
2486
|
+
x: offset,
|
|
2487
|
+
animated
|
|
2488
|
+
} : {
|
|
2489
|
+
y: offset,
|
|
2490
|
+
animated
|
|
2491
|
+
});
|
|
2146
2492
|
}, []);
|
|
2147
|
-
const
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
const
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
if (
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2493
|
+
const scrollToIndex = useCallback((params) => {
|
|
2494
|
+
const current = latest.current;
|
|
2495
|
+
const columns = current.numColumns ?? 1;
|
|
2496
|
+
const currentItems = isArrayLike(current.data) ? current.data : [];
|
|
2497
|
+
const count = columns > 1 ? Math.ceil(currentItems.length / columns) : currentItems.length;
|
|
2498
|
+
const { animated, index, viewOffset, viewPosition } = params;
|
|
2499
|
+
if (index < 0) throw new Error(`scrollToIndex out of range: requested index ${index} but minimum is 0`);
|
|
2500
|
+
if (count < 1) throw new Error(`scrollToIndex out of range: item length ${count} but minimum is 1`);
|
|
2501
|
+
if (index >= count) throw new Error(`scrollToIndex out of range: requested index ${index} is out of 0 to ${count - 1}`);
|
|
2502
|
+
const frame = metricsAt(Math.floor(index));
|
|
2503
|
+
const element = scroller.current;
|
|
2504
|
+
if (frame === void 0 || element === null) {
|
|
2505
|
+
const { onScrollToIndexFailed } = current;
|
|
2506
|
+
if (onScrollToIndexFailed === void 0) throw new Error("scrollToIndex should be used in conjunction with getItemLayout or onScrollToIndexFailed, otherwise there is no way to know the location of offscreen indices or handle failures.");
|
|
2507
|
+
onScrollToIndexFailed({
|
|
2508
|
+
index,
|
|
2509
|
+
highestMeasuredFrameIndex: -1,
|
|
2510
|
+
averageItemLength: 0
|
|
2511
|
+
});
|
|
2512
|
+
return;
|
|
2513
|
+
}
|
|
2514
|
+
const visibleLength = current.horizontal === true ? element.clientWidth : element.clientHeight;
|
|
2515
|
+
const offset = Math.max(0, frame.offset - (viewPosition ?? 0) * (visibleLength - frame.length)) - (viewOffset ?? 0);
|
|
2516
|
+
scrollToOffset(offset, animated);
|
|
2517
|
+
}, [metricsAt, scrollToOffset]);
|
|
2518
|
+
useImperativeHandle(ref, () => ({
|
|
2519
|
+
scrollToOffset: (params) => scrollToOffset(params.offset, params.animated),
|
|
2520
|
+
scrollToEnd: (params) => scroller.current?.scrollToEnd({ animated: params?.animated }),
|
|
2521
|
+
scrollToIndex,
|
|
2522
|
+
scrollToItem: ({ item, ...rest }) => {
|
|
2523
|
+
const current = latest.current;
|
|
2524
|
+
const columns = current.numColumns ?? 1;
|
|
2525
|
+
const currentItems = isArrayLike(current.data) ? current.data : [];
|
|
2526
|
+
for (let index = 0; index < currentItems.length; index++) if (currentItems[index] === item) {
|
|
2527
|
+
scrollToIndex({
|
|
2528
|
+
...rest,
|
|
2529
|
+
index: Math.floor(index / columns)
|
|
2530
|
+
});
|
|
2531
|
+
return;
|
|
2532
|
+
}
|
|
2533
|
+
},
|
|
2534
|
+
recordInteraction: () => {
|
|
2535
|
+
for (const entry of trackers) entry.tracker.recordInteraction();
|
|
2536
|
+
updateViewability();
|
|
2537
|
+
},
|
|
2538
|
+
flashScrollIndicators: () => {},
|
|
2539
|
+
getScrollResponder: () => scroller.current,
|
|
2540
|
+
getNativeScrollRef: () => scroller.current,
|
|
2541
|
+
getScrollableNode: () => scroller.current,
|
|
2542
|
+
setNativeProps: () => {}
|
|
2543
|
+
}), [
|
|
2544
|
+
scrollToIndex,
|
|
2545
|
+
scrollToOffset,
|
|
2546
|
+
trackers,
|
|
2547
|
+
updateViewability
|
|
2548
|
+
]);
|
|
2549
|
+
useLayoutEffect(() => {
|
|
2550
|
+
const index = latest.current.initialScrollIndex;
|
|
2551
|
+
const element = scroller.current;
|
|
2552
|
+
if (index == null || element === null) return;
|
|
2553
|
+
const frame = metricsAt(index);
|
|
2554
|
+
if (frame === void 0) return;
|
|
2555
|
+
if (latest.current.horizontal === true) element.scrollLeft = frame.offset;
|
|
2556
|
+
else element.scrollTop = frame.offset;
|
|
2557
|
+
}, [metricsAt]);
|
|
2558
|
+
const inversionStyle = inverted ? horizontal ? horizontallyInvertedStyle : verticallyInvertedStyle : void 0;
|
|
2559
|
+
const cellStyle = inversionStyle ? horizontal ? [rowReverseStyle, inversionStyle] : [columnReverseStyle, inversionStyle] : horizontal ? rowStyle : void 0;
|
|
2560
|
+
const renderOne = (info) => {
|
|
2561
|
+
if (ListItemComponent !== void 0) return /* @__PURE__ */ jsx(ListItemComponent, { ...info });
|
|
2562
|
+
if (renderItem != null) return renderItem(info);
|
|
2563
|
+
throw new Error("FlatList: Either ListItemComponent or renderItem props are required but none were found.");
|
|
2167
2564
|
};
|
|
2168
|
-
const
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2565
|
+
const renderCell = (row, index, separators) => {
|
|
2566
|
+
if (numColumns === 1) return renderOne({
|
|
2567
|
+
item: row,
|
|
2568
|
+
index,
|
|
2569
|
+
separators
|
|
2570
|
+
});
|
|
2571
|
+
return /* @__PURE__ */ jsx(View, {
|
|
2572
|
+
style: [rowStyle, columnWrapperStyle],
|
|
2573
|
+
children: row.map((item, column) => {
|
|
2574
|
+
const element = renderOne({
|
|
2575
|
+
item,
|
|
2576
|
+
index: index * numColumns + column,
|
|
2577
|
+
separators
|
|
2578
|
+
});
|
|
2579
|
+
return element == null ? null : /* @__PURE__ */ jsx(Fragment, { children: element }, column);
|
|
2580
|
+
})
|
|
2581
|
+
});
|
|
2185
2582
|
};
|
|
2186
|
-
const
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2583
|
+
const children = [];
|
|
2584
|
+
if (ListHeaderComponent != null) children.push(/* @__PURE__ */ jsx(View, {
|
|
2585
|
+
style: [inversionStyle, ListHeaderComponentStyle],
|
|
2586
|
+
children: renderListComponent(ListHeaderComponent)
|
|
2587
|
+
}, "$header"));
|
|
2588
|
+
if (rowCount === 0) {
|
|
2589
|
+
if (ListEmptyComponent != null) children.push(/* @__PURE__ */ jsx(View, {
|
|
2590
|
+
style: inversionStyle,
|
|
2591
|
+
children: renderListComponent(ListEmptyComponent)
|
|
2592
|
+
}, "$empty"));
|
|
2593
|
+
} else {
|
|
2594
|
+
let prevCellKey;
|
|
2595
|
+
for (let index = 0; index < rowCount; index++) {
|
|
2596
|
+
const row = rowAt(index);
|
|
2597
|
+
const cellKey = rowKey(row, index);
|
|
2598
|
+
children.push(/* @__PURE__ */ jsx(Cell, {
|
|
2599
|
+
cellKey,
|
|
2600
|
+
prevCellKey,
|
|
2601
|
+
index,
|
|
2602
|
+
item: row,
|
|
2603
|
+
style: cellStyle,
|
|
2604
|
+
renderCell,
|
|
2605
|
+
ItemSeparatorComponent: index < rowCount - 1 ? ItemSeparatorComponent : void 0,
|
|
2606
|
+
CellRendererComponent,
|
|
2607
|
+
separatorUpdaters,
|
|
2608
|
+
onElement
|
|
2609
|
+
}, cellKey));
|
|
2610
|
+
prevCellKey = cellKey;
|
|
2611
|
+
}
|
|
2208
2612
|
}
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
src: placeholder,
|
|
2232
|
-
alt: "",
|
|
2233
|
-
"aria-hidden": true,
|
|
2234
|
-
draggable: false,
|
|
2235
|
-
className: compileStyle([fillStyle, imgStyle], registry)
|
|
2236
|
-
}, "placeholder"));
|
|
2237
|
-
if (paintStyle !== void 0) children.push(/* @__PURE__ */ jsx("div", {
|
|
2238
|
-
"aria-hidden": true,
|
|
2239
|
-
className: compileStyle([fillStyle, paintStyle], registry)
|
|
2240
|
-
}, "paint"));
|
|
2241
|
-
return createElement(tag, domProps, ...children);
|
|
2613
|
+
if (ListFooterComponent != null) children.push(/* @__PURE__ */ jsx(View, {
|
|
2614
|
+
style: [inversionStyle, ListFooterComponentStyle],
|
|
2615
|
+
children: renderListComponent(ListFooterComponent)
|
|
2616
|
+
}, "$footer"));
|
|
2617
|
+
const scrollProps = {
|
|
2618
|
+
...scrollViewProps,
|
|
2619
|
+
horizontal,
|
|
2620
|
+
style: [inversionStyle, style],
|
|
2621
|
+
onScroll: handleScroll,
|
|
2622
|
+
onContentSizeChange: handleContentSizeChange,
|
|
2623
|
+
onLayout: handleLayout,
|
|
2624
|
+
children
|
|
2625
|
+
};
|
|
2626
|
+
if (renderScrollComponent !== void 0) return /* @__PURE__ */ jsx(CustomScroller, {
|
|
2627
|
+
...scrollProps,
|
|
2628
|
+
ref: scroller,
|
|
2629
|
+
render: renderScrollComponent
|
|
2630
|
+
});
|
|
2631
|
+
return /* @__PURE__ */ jsx(ScrollView, {
|
|
2632
|
+
...scrollProps,
|
|
2633
|
+
ref: scroller
|
|
2634
|
+
});
|
|
2242
2635
|
}
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
probe.addEventListener("load", () => resolve(sizeOf(probe)), { once: true });
|
|
2250
|
-
probe.addEventListener("error", () => reject(new Error(loadError(uri))), { once: true });
|
|
2251
|
-
probe.src = uri;
|
|
2252
|
-
});
|
|
2253
|
-
const fetchObjectURL = async (uri, headers) => {
|
|
2254
|
-
const response = await fetch(uri, { headers });
|
|
2255
|
-
if (!response.ok) throw new Error(`${loadError(uri)} (HTTP ${response.status})`);
|
|
2256
|
-
return URL.createObjectURL(await response.blob());
|
|
2257
|
-
};
|
|
2258
|
-
const withCallbacks = (promise, success, failure) => {
|
|
2259
|
-
if (success === void 0) return promise;
|
|
2260
|
-
promise.then((size) => success(size.width, size.height), (error) => failure?.(error));
|
|
2636
|
+
// src/utils/warn.ts
|
|
2637
|
+
const warned = /* @__PURE__ */ new Set();
|
|
2638
|
+
const warnOnce = (key, message) => {
|
|
2639
|
+
if (isProductionEnv() || warned.has(key)) return;
|
|
2640
|
+
warned.add(key);
|
|
2641
|
+
console.warn(`[@rootnative/web] ${message}`);
|
|
2261
2642
|
};
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
getSize,
|
|
2271
|
-
getSizeWithHeaders,
|
|
2272
|
-
prefetch: (url) => loadSize(url).then(() => true),
|
|
2273
|
-
queryCache: () => Promise.resolve({}),
|
|
2274
|
-
resolveAssetSource
|
|
2643
|
+
// src/components/Image/source.ts
|
|
2644
|
+
const none = Object.freeze({
|
|
2645
|
+
src: void 0,
|
|
2646
|
+
srcSet: void 0,
|
|
2647
|
+
sizes: void 0,
|
|
2648
|
+
width: void 0,
|
|
2649
|
+
height: void 0,
|
|
2650
|
+
request: void 0
|
|
2275
2651
|
});
|
|
2276
|
-
|
|
2277
|
-
const
|
|
2278
|
-
const
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
if (key in target) continue;
|
|
2286
|
-
Object.defineProperty(target, key, {
|
|
2287
|
-
value: fields[key],
|
|
2288
|
-
configurable: true
|
|
2289
|
-
});
|
|
2290
|
-
}
|
|
2652
|
+
const ASSET_ID_WARNING = "Image: a numeric source is a Metro asset id, which has no meaning here. Import the image file and pass its URL.";
|
|
2653
|
+
const hasURI = (source) => typeof source.uri === "string" && source.uri.length > 0;
|
|
2654
|
+
const requestOf = (source) => {
|
|
2655
|
+
if (source.headers === void 0 && source.method === void 0 && source.body === void 0) return;
|
|
2656
|
+
return {
|
|
2657
|
+
method: source.method ?? "GET",
|
|
2658
|
+
headers: source.headers,
|
|
2659
|
+
body: source.body
|
|
2660
|
+
};
|
|
2291
2661
|
};
|
|
2292
|
-
const
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2662
|
+
const single = (source) => ({
|
|
2663
|
+
src: source.uri,
|
|
2664
|
+
srcSet: void 0,
|
|
2665
|
+
sizes: void 0,
|
|
2666
|
+
width: source.width,
|
|
2667
|
+
height: source.height,
|
|
2668
|
+
request: requestOf(source)
|
|
2669
|
+
});
|
|
2670
|
+
const firstCandidate = (srcSet) => srcSet.split(",")[0]?.trim().split(/\s+/)[0];
|
|
2671
|
+
const list = (sources, layoutWidth) => {
|
|
2672
|
+
const first = sources[0];
|
|
2673
|
+
if (sources.length === 1) return single(first);
|
|
2674
|
+
if (sources.every((s) => typeof s.width === "number")) return {
|
|
2675
|
+
src: first.uri,
|
|
2676
|
+
srcSet: sources.map((s) => `${s.uri} ${s.width}w`).join(", "),
|
|
2677
|
+
sizes: layoutWidth === void 0 ? "100vw" : `${layoutWidth}px`,
|
|
2678
|
+
width: void 0,
|
|
2679
|
+
height: void 0,
|
|
2680
|
+
request: void 0
|
|
2681
|
+
};
|
|
2682
|
+
if (sources.every((s) => typeof s.scale === "number")) {
|
|
2683
|
+
const base = sources.find((s) => s.scale === 1) ?? first;
|
|
2684
|
+
return {
|
|
2685
|
+
src: base.uri,
|
|
2686
|
+
srcSet: sources.map((s) => `${s.uri} ${s.scale}x`).join(", "),
|
|
2687
|
+
sizes: void 0,
|
|
2688
|
+
width: base.width,
|
|
2689
|
+
height: base.height,
|
|
2690
|
+
request: void 0
|
|
2310
2691
|
};
|
|
2311
|
-
define(native, {
|
|
2312
|
-
...touch,
|
|
2313
|
-
changedTouches: [touch],
|
|
2314
|
-
touches: activeTypes.has(native.type) ? [touch] : []
|
|
2315
|
-
});
|
|
2316
2692
|
}
|
|
2317
|
-
return
|
|
2693
|
+
return single(first);
|
|
2318
2694
|
};
|
|
2319
|
-
const
|
|
2320
|
-
|
|
2321
|
-
|
|
2695
|
+
const resolveSource = (source, src, srcSet, layoutWidth) => {
|
|
2696
|
+
if (src !== void 0 || srcSet !== void 0) return {
|
|
2697
|
+
...none,
|
|
2698
|
+
src: src ?? (srcSet === void 0 ? void 0 : firstCandidate(srcSet)),
|
|
2699
|
+
srcSet,
|
|
2700
|
+
sizes: srcSet !== void 0 && /\d+w/.test(srcSet) ? "100vw" : void 0
|
|
2701
|
+
};
|
|
2702
|
+
if (source === void 0 || source === null) return none;
|
|
2703
|
+
if (typeof source === "string") return {
|
|
2704
|
+
...none,
|
|
2705
|
+
src: source
|
|
2706
|
+
};
|
|
2707
|
+
if (typeof source === "number") {
|
|
2708
|
+
warnOnce("image-asset-id", ASSET_ID_WARNING);
|
|
2709
|
+
return none;
|
|
2710
|
+
}
|
|
2711
|
+
if (Array.isArray(source)) {
|
|
2712
|
+
const sources = source.filter(hasURI);
|
|
2713
|
+
return sources.length === 0 ? none : list(sources, layoutWidth);
|
|
2714
|
+
}
|
|
2715
|
+
return hasURI(source) ? single(source) : none;
|
|
2322
2716
|
};
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT"
|
|
2332
|
-
},
|
|
2333
|
-
RESPONDER_INACTIVE_PRESS_OUT: {
|
|
2334
|
-
DELAY: "RESPONDER_ACTIVE_PRESS_OUT",
|
|
2335
|
-
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
2336
|
-
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
2337
|
-
ENTER_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_IN",
|
|
2338
|
-
LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT"
|
|
2339
|
-
},
|
|
2340
|
-
RESPONDER_ACTIVE_PRESS_IN: {
|
|
2341
|
-
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
2342
|
-
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
2343
|
-
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
|
|
2344
|
-
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT",
|
|
2345
|
-
LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
|
|
2346
|
-
},
|
|
2347
|
-
RESPONDER_ACTIVE_PRESS_OUT: {
|
|
2348
|
-
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
2349
|
-
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
2350
|
-
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
|
|
2351
|
-
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT"
|
|
2352
|
-
},
|
|
2353
|
-
RESPONDER_ACTIVE_LONG_PRESS_IN: {
|
|
2354
|
-
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
2355
|
-
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
2356
|
-
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
|
|
2357
|
-
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_OUT",
|
|
2358
|
-
LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
|
|
2359
|
-
},
|
|
2360
|
-
RESPONDER_ACTIVE_LONG_PRESS_OUT: {
|
|
2361
|
-
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
2362
|
-
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
2363
|
-
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
|
|
2364
|
-
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_OUT"
|
|
2717
|
+
const resolveAssetSource = (source) => {
|
|
2718
|
+
if (typeof source === "string") return {
|
|
2719
|
+
uri: source,
|
|
2720
|
+
scale: 1
|
|
2721
|
+
};
|
|
2722
|
+
if (typeof source === "number") {
|
|
2723
|
+
warnOnce("image-asset-id", ASSET_ID_WARNING);
|
|
2724
|
+
return null;
|
|
2365
2725
|
}
|
|
2726
|
+
const first = Array.isArray(source) ? source[0] : source;
|
|
2727
|
+
if (first === void 0 || first === null || !hasURI(first)) return null;
|
|
2728
|
+
const { uri, width, height, scale } = first;
|
|
2729
|
+
return {
|
|
2730
|
+
uri,
|
|
2731
|
+
width,
|
|
2732
|
+
height,
|
|
2733
|
+
scale: scale ?? 1
|
|
2734
|
+
};
|
|
2366
2735
|
};
|
|
2367
|
-
|
|
2368
|
-
const
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2736
|
+
// src/components/Image/index.tsx
|
|
2737
|
+
const boxStyle = Object.freeze({
|
|
2738
|
+
backgroundColor: "transparent",
|
|
2739
|
+
border: "0 solid black",
|
|
2740
|
+
boxSizing: "border-box",
|
|
2741
|
+
display: "flex",
|
|
2742
|
+
flexBasis: "auto",
|
|
2743
|
+
flexDirection: "column",
|
|
2744
|
+
flexShrink: 0,
|
|
2745
|
+
margin: 0,
|
|
2746
|
+
minHeight: 0,
|
|
2747
|
+
minWidth: 0,
|
|
2748
|
+
overflow: "hidden",
|
|
2749
|
+
padding: 0,
|
|
2750
|
+
position: "relative",
|
|
2751
|
+
zIndex: 0
|
|
2752
|
+
});
|
|
2753
|
+
const fillStyle = Object.freeze({
|
|
2754
|
+
position: "absolute",
|
|
2755
|
+
left: 0,
|
|
2756
|
+
top: 0,
|
|
2757
|
+
width: "100%",
|
|
2758
|
+
height: "100%",
|
|
2759
|
+
display: "block",
|
|
2760
|
+
border: 0,
|
|
2761
|
+
margin: 0,
|
|
2762
|
+
padding: 0
|
|
2763
|
+
});
|
|
2764
|
+
const hiddenStyle = Object.freeze({ visibility: "hidden" });
|
|
2765
|
+
const objectFitOf = {
|
|
2766
|
+
cover: "cover",
|
|
2767
|
+
contain: "contain",
|
|
2768
|
+
stretch: "fill",
|
|
2769
|
+
center: "none",
|
|
2770
|
+
repeat: "none"
|
|
2378
2771
|
};
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
top: rect
|
|
2386
|
-
} : rect;
|
|
2387
|
-
const claimed = /* @__PURE__ */ new WeakSet();
|
|
2388
|
-
const isActivationKey = (key) => key === "Enter" || key === " ";
|
|
2389
|
-
const hasNativeActivation = (element) => {
|
|
2390
|
-
switch (element.tagName) {
|
|
2391
|
-
case "BUTTON":
|
|
2392
|
-
case "INPUT":
|
|
2393
|
-
case "SELECT":
|
|
2394
|
-
case "SUMMARY":
|
|
2395
|
-
case "TEXTAREA": return true;
|
|
2396
|
-
case "A":
|
|
2397
|
-
case "AREA": return element.hasAttribute("href");
|
|
2398
|
-
default: return element.isContentEditable;
|
|
2399
|
-
}
|
|
2772
|
+
const resizeModeOfObjectFit = {
|
|
2773
|
+
cover: "cover",
|
|
2774
|
+
contain: "contain",
|
|
2775
|
+
fill: "stretch",
|
|
2776
|
+
"scale-down": "contain",
|
|
2777
|
+
none: "center"
|
|
2400
2778
|
};
|
|
2401
|
-
const
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2779
|
+
const maskSizeOf = {
|
|
2780
|
+
cover: "cover",
|
|
2781
|
+
contain: "contain",
|
|
2782
|
+
stretch: "100% 100%",
|
|
2783
|
+
center: "auto",
|
|
2784
|
+
repeat: "auto"
|
|
2407
2785
|
};
|
|
2408
|
-
const
|
|
2409
|
-
|
|
2410
|
-
|
|
2786
|
+
const cssURL = (url) => `url("${url.replace(/["\\]/g, "\\$&")}")`;
|
|
2787
|
+
const loadError = (uri) => `Failed to load image: ${uri ?? ""}`;
|
|
2788
|
+
const sizeOf = (img) => ({
|
|
2789
|
+
width: img.naturalWidth,
|
|
2790
|
+
height: img.naturalHeight
|
|
2791
|
+
});
|
|
2792
|
+
const placeholderURI = (source) => {
|
|
2793
|
+
if (typeof source === "string") return source;
|
|
2794
|
+
if (typeof source === "object" && source !== null) return source.uri;
|
|
2411
2795
|
};
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
this.pressDelayTimer = null;
|
|
2428
|
-
this.pressOutTimer = null;
|
|
2429
|
-
this.config = config;
|
|
2430
|
-
this.handlers = this.createEventHandlers();
|
|
2431
|
-
}
|
|
2432
|
-
configure(config) {
|
|
2433
|
-
this.config = config;
|
|
2434
|
-
}
|
|
2435
|
-
reset() {
|
|
2436
|
-
this.hoverInTimer = clear(this.hoverInTimer);
|
|
2437
|
-
this.hoverOutTimer = clear(this.hoverOutTimer);
|
|
2438
|
-
this.longPressTimer = clear(this.longPressTimer);
|
|
2439
|
-
this.pressDelayTimer = clear(this.pressDelayTimer);
|
|
2440
|
-
this.pressOutTimer = clear(this.pressOutTimer);
|
|
2441
|
-
this.config = Object.freeze({});
|
|
2442
|
-
}
|
|
2443
|
-
getEventHandlers() {
|
|
2444
|
-
return this.handlers;
|
|
2445
|
-
}
|
|
2446
|
-
static setLongPressDeactivationDistance(distance) {
|
|
2447
|
-
longPressDeactivationDistance = distance;
|
|
2448
|
-
}
|
|
2449
|
-
createEventHandlers() {
|
|
2450
|
-
return {
|
|
2451
|
-
onPointerDown: (event) => {
|
|
2452
|
-
const native = event.nativeEvent;
|
|
2453
|
-
if (event.button !== 0 || claimed.has(native) || this.config.disabled === true) return;
|
|
2454
|
-
if (startsInNativeControl(event)) return;
|
|
2455
|
-
claimed.add(native);
|
|
2456
|
-
if (this.pointerId !== null || this.key !== null) return;
|
|
2457
|
-
const element = event.currentTarget;
|
|
2458
|
-
this.pointerId = event.pointerId;
|
|
2459
|
-
this.pointerClickPending = true;
|
|
2460
|
-
try {
|
|
2461
|
-
element.setPointerCapture(event.pointerId);
|
|
2462
|
-
} catch {}
|
|
2463
|
-
this.grant(element, toGestureResponderEvent(event, element));
|
|
2464
|
-
},
|
|
2465
|
-
onPointerMove: (event) => {
|
|
2466
|
-
const element = this.element;
|
|
2467
|
-
if (event.pointerId !== this.pointerId || element === null) return;
|
|
2468
|
-
const pressEvent = toGestureResponderEvent(event, element);
|
|
2469
|
-
this.config.onPressMove?.(pressEvent);
|
|
2470
|
-
const region = this.region;
|
|
2471
|
-
if (region === null) return;
|
|
2472
|
-
const { pageX, pageY } = pressEvent.nativeEvent;
|
|
2473
|
-
const start = this.activatePosition;
|
|
2474
|
-
if (start !== null && Math.hypot(start.pageX - pageX, start.pageY - pageY) > longPressDeactivationDistance) this.longPressTimer = clear(this.longPressTimer);
|
|
2475
|
-
if (this.isWithinRegion(pageX, pageY, region)) this.receiveSignal("ENTER_PRESS_RECT", pressEvent);
|
|
2476
|
-
else {
|
|
2477
|
-
this.longPressTimer = clear(this.longPressTimer);
|
|
2478
|
-
this.receiveSignal("LEAVE_PRESS_RECT", pressEvent);
|
|
2479
|
-
}
|
|
2480
|
-
},
|
|
2481
|
-
onPointerUp: (event) => {
|
|
2482
|
-
const element = this.element;
|
|
2483
|
-
if (event.pointerId !== this.pointerId || element === null) return;
|
|
2484
|
-
this.pointerId = null;
|
|
2485
|
-
this.receiveSignal("RESPONDER_RELEASE", toGestureResponderEvent(event, element));
|
|
2486
|
-
},
|
|
2487
|
-
onPointerCancel: (event) => {
|
|
2488
|
-
const element = this.element;
|
|
2489
|
-
if (event.pointerId !== this.pointerId || element === null) return;
|
|
2490
|
-
this.pointerId = null;
|
|
2491
|
-
this.pointerClickPending = false;
|
|
2492
|
-
this.receiveSignal("RESPONDER_TERMINATED", toGestureResponderEvent(event, element));
|
|
2493
|
-
},
|
|
2494
|
-
onClick: (event) => {
|
|
2495
|
-
const native = event.nativeEvent;
|
|
2496
|
-
if (claimed.has(native) || startsInNativeControl(event)) return;
|
|
2497
|
-
if (this.pointerClickPending && event.detail > 0) {
|
|
2498
|
-
this.pointerClickPending = false;
|
|
2499
|
-
claimed.add(native);
|
|
2500
|
-
if (this.cancelClick) event.preventDefault();
|
|
2501
|
-
return;
|
|
2502
|
-
}
|
|
2503
|
-
if (this.config.disabled === true) return;
|
|
2504
|
-
claimed.add(native);
|
|
2505
|
-
this.config.onPress?.(toGestureResponderEvent(event, event.currentTarget));
|
|
2506
|
-
},
|
|
2507
|
-
onKeyDown: (event) => {
|
|
2508
|
-
if (!isActivationKey(event.key) || event.repeat || event.nativeEvent.isComposing) return;
|
|
2509
|
-
const element = event.currentTarget;
|
|
2510
|
-
if (event.target !== element || this.config.disabled === true) return;
|
|
2511
|
-
if (hasNativeActivation(element)) return;
|
|
2512
|
-
if (event.key === " ") event.preventDefault();
|
|
2513
|
-
if (this.pointerId !== null || this.key !== null) return;
|
|
2514
|
-
this.key = event.key;
|
|
2515
|
-
this.grant(element, toGestureResponderEvent(event, element));
|
|
2516
|
-
},
|
|
2517
|
-
onKeyUp: (event) => {
|
|
2518
|
-
const element = this.element;
|
|
2519
|
-
if (event.key !== this.key || element === null) return;
|
|
2520
|
-
this.key = null;
|
|
2521
|
-
this.receiveSignal("RESPONDER_RELEASE", toGestureResponderEvent(event, element));
|
|
2522
|
-
},
|
|
2523
|
-
onFocus: (event) => {
|
|
2524
|
-
this.config.onFocus?.(event);
|
|
2525
|
-
},
|
|
2526
|
-
onBlur: (event) => {
|
|
2527
|
-
const element = this.element;
|
|
2528
|
-
if (this.key !== null && element !== null && event.target === event.currentTarget) {
|
|
2529
|
-
this.key = null;
|
|
2530
|
-
this.receiveSignal("RESPONDER_TERMINATED", toGestureResponderEvent(event, element));
|
|
2531
|
-
}
|
|
2532
|
-
this.config.onBlur?.(event);
|
|
2533
|
-
},
|
|
2534
|
-
onPointerEnter: (event) => {
|
|
2535
|
-
if (event.pointerType === "touch") return;
|
|
2536
|
-
this.hovered = true;
|
|
2537
|
-
this.hoverOutTimer = clear(this.hoverOutTimer);
|
|
2538
|
-
this.hover(event, this.config.onHoverIn, this.config.delayHoverIn, "in");
|
|
2539
|
-
},
|
|
2540
|
-
onPointerLeave: (event) => {
|
|
2541
|
-
if (!this.hovered) return;
|
|
2542
|
-
this.hovered = false;
|
|
2543
|
-
this.hoverInTimer = clear(this.hoverInTimer);
|
|
2544
|
-
this.hover(event, this.config.onHoverOut, this.config.delayHoverOut, "out");
|
|
2545
|
-
},
|
|
2546
|
-
onContextMenu: (event) => {
|
|
2547
|
-
if (this.pointerId !== null && this.config.onLongPress != null) event.preventDefault();
|
|
2548
|
-
}
|
|
2796
|
+
const useRequestURL = (uri, request) => {
|
|
2797
|
+
const [state, setState] = useState({
|
|
2798
|
+
uri: void 0,
|
|
2799
|
+
url: void 0,
|
|
2800
|
+
error: void 0
|
|
2801
|
+
});
|
|
2802
|
+
const requestKey = request === void 0 ? void 0 : JSON.stringify(request);
|
|
2803
|
+
useEffect(() => {
|
|
2804
|
+
if (uri === void 0 || requestKey === void 0) return;
|
|
2805
|
+
const { method, headers, body } = JSON.parse(requestKey);
|
|
2806
|
+
const controller = new AbortController();
|
|
2807
|
+
let objectURL;
|
|
2808
|
+
const init = {
|
|
2809
|
+
method,
|
|
2810
|
+
signal: controller.signal
|
|
2549
2811
|
};
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
if (this.state === "RESPONDER_ACTIVE_PRESS_IN" || this.state === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.receiveSignal("LONG_PRESS_DETECTED", event);
|
|
2575
|
-
}, delayLongPress + delayPressIn);
|
|
2576
|
-
}
|
|
2577
|
-
receiveSignal(signal, event) {
|
|
2578
|
-
const prevState = this.state;
|
|
2579
|
-
const nextState = transitions[prevState][signal];
|
|
2580
|
-
if (nextState === void 0 || nextState === prevState) return;
|
|
2581
|
-
this.performTransitionSideEffects(prevState, nextState, signal, event);
|
|
2582
|
-
this.state = nextState;
|
|
2583
|
-
}
|
|
2584
|
-
performTransitionSideEffects(prevState, nextState, signal, event) {
|
|
2585
|
-
if (isTerminal(signal)) {
|
|
2586
|
-
this.activatePosition = null;
|
|
2587
|
-
this.longPressTimer = clear(this.longPressTimer);
|
|
2588
|
-
}
|
|
2589
|
-
const isInitialTransition = prevState === "NOT_RESPONDER" && nextState === "RESPONDER_INACTIVE_PRESS_IN";
|
|
2590
|
-
const isActivationTransition = !isActivation(prevState) && isActivation(nextState);
|
|
2591
|
-
if (isInitialTransition || isActivationTransition) this.measureRegion();
|
|
2592
|
-
if (isPressIn(prevState) && signal === "LONG_PRESS_DETECTED") this.config.onLongPress?.(event);
|
|
2593
|
-
const isPrevActive = isActive(prevState);
|
|
2594
|
-
const isNextActive = isActive(nextState);
|
|
2595
|
-
if (!isPrevActive && isNextActive) this.activate(event);
|
|
2596
|
-
else if (isPrevActive && !isNextActive) this.deactivate(event);
|
|
2597
|
-
if (isPressIn(prevState) && signal === "RESPONDER_RELEASE") {
|
|
2598
|
-
if (!isNextActive && !isPrevActive) {
|
|
2599
|
-
this.activate(event);
|
|
2600
|
-
this.deactivate(event);
|
|
2601
|
-
}
|
|
2602
|
-
const { onLongPress, onPress } = this.config;
|
|
2603
|
-
if (onLongPress != null && prevState === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.cancelClick = true;
|
|
2604
|
-
else if (onPress != null) {
|
|
2605
|
-
onPress(event);
|
|
2606
|
-
if (event.isDefaultPrevented()) this.cancelClick = true;
|
|
2607
|
-
}
|
|
2608
|
-
}
|
|
2609
|
-
this.pressDelayTimer = clear(this.pressDelayTimer);
|
|
2610
|
-
}
|
|
2611
|
-
activate(event) {
|
|
2612
|
-
const { pageX, pageY } = event.nativeEvent;
|
|
2613
|
-
this.activatePosition = {
|
|
2614
|
-
pageX,
|
|
2615
|
-
pageY
|
|
2812
|
+
if (headers !== void 0) init.headers = headers;
|
|
2813
|
+
if (body !== void 0) init.body = body;
|
|
2814
|
+
fetch(uri, init).then((response) => {
|
|
2815
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
2816
|
+
return response.blob();
|
|
2817
|
+
}).then((blob) => {
|
|
2818
|
+
objectURL = URL.createObjectURL(blob);
|
|
2819
|
+
setState({
|
|
2820
|
+
uri,
|
|
2821
|
+
url: objectURL,
|
|
2822
|
+
error: void 0
|
|
2823
|
+
});
|
|
2824
|
+
}).catch((error) => {
|
|
2825
|
+
if (controller.signal.aborted) return;
|
|
2826
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2827
|
+
setState({
|
|
2828
|
+
uri,
|
|
2829
|
+
url: void 0,
|
|
2830
|
+
error: `${loadError(uri)} (${message})`
|
|
2831
|
+
});
|
|
2832
|
+
});
|
|
2833
|
+
return () => {
|
|
2834
|
+
controller.abort();
|
|
2835
|
+
if (objectURL !== void 0) URL.revokeObjectURL(objectURL);
|
|
2616
2836
|
};
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2837
|
+
}, [uri, requestKey]);
|
|
2838
|
+
return state.uri === uri ? state : {
|
|
2839
|
+
url: void 0,
|
|
2840
|
+
error: void 0
|
|
2841
|
+
};
|
|
2842
|
+
};
|
|
2843
|
+
function ImageComponent(props) {
|
|
2844
|
+
const { alt, blurRadius, crossOrigin, decoding, defaultSource, fetchPriority, height, loading, onError, onLayout, onLoad, onLoadEnd, onLoadStart, ref, referrerPolicy, resizeMode: resizeModeProp, source, src, srcSet, style, tintColor: tintColorProp, width, fadeDuration: _fadeDuration, loadingIndicatorSource: _loadingIndicatorSource, onProgress: _onProgress, progressiveRenderingEnabled: _progressiveRenderingEnabled, resizeMethod: _resizeMethod, ...rest } = props;
|
|
2845
|
+
const element = useRef(null);
|
|
2846
|
+
const img = useRef(null);
|
|
2847
|
+
useImperativeHandle(ref, () => element.current, []);
|
|
2848
|
+
useElementLayout(element, onLayout);
|
|
2849
|
+
const registry = useStyleRegistry();
|
|
2850
|
+
const { resizeMode: styleResizeMode, objectFit, tintColor: styleTintColor, overlayColor: _overlayColor, ...userBoxStyle } = flattenStyle(style) ?? {};
|
|
2851
|
+
const resizeMode = (typeof objectFit === "string" ? resizeModeOfObjectFit[objectFit] : void 0) ?? resizeModeProp ?? styleResizeMode ?? "cover";
|
|
2852
|
+
const tintColor = tintColorProp ?? styleTintColor;
|
|
2853
|
+
const painted = resizeMode === "repeat" || tintColor !== void 0;
|
|
2854
|
+
const styleWidth = userBoxStyle["width"] ?? width;
|
|
2855
|
+
const resolved = resolveSource(source, src, srcSet, typeof styleWidth === "number" ? styleWidth : void 0);
|
|
2856
|
+
const requested = useRequestURL(resolved.src, resolved.request);
|
|
2857
|
+
const currentSrc = resolved.request === void 0 ? resolved.src : requested.url;
|
|
2858
|
+
const handlers = useRef({
|
|
2859
|
+
onLoad,
|
|
2860
|
+
onLoadStart,
|
|
2861
|
+
onLoadEnd,
|
|
2862
|
+
onError
|
|
2863
|
+
});
|
|
2864
|
+
useEffect(() => {
|
|
2865
|
+
handlers.current = {
|
|
2866
|
+
onLoad,
|
|
2867
|
+
onLoadStart,
|
|
2868
|
+
onLoadEnd,
|
|
2869
|
+
onError
|
|
2870
|
+
};
|
|
2871
|
+
});
|
|
2872
|
+
const [loadedSrc, setLoadedSrc] = useState(void 0);
|
|
2873
|
+
const firedFor = useRef(void 0);
|
|
2874
|
+
useEffect(() => {
|
|
2875
|
+
if (resolved.src === void 0) return;
|
|
2876
|
+
firedFor.current = void 0;
|
|
2877
|
+
handlers.current.onLoadStart?.();
|
|
2878
|
+
}, [resolved.src]);
|
|
2879
|
+
const fireLoad = useCallback((target) => {
|
|
2880
|
+
const uri = target.currentSrc || target.src;
|
|
2881
|
+
if (firedFor.current === uri) return;
|
|
2882
|
+
firedFor.current = uri;
|
|
2883
|
+
setLoadedSrc(target.src);
|
|
2884
|
+
const { width: naturalWidth, height: naturalHeight } = sizeOf(target);
|
|
2885
|
+
handlers.current.onLoad?.({ nativeEvent: { source: {
|
|
2886
|
+
uri,
|
|
2887
|
+
width: naturalWidth,
|
|
2888
|
+
height: naturalHeight
|
|
2889
|
+
} } });
|
|
2890
|
+
handlers.current.onLoadEnd?.();
|
|
2891
|
+
}, []);
|
|
2892
|
+
const fireError = useCallback((target) => {
|
|
2893
|
+
const uri = target.currentSrc || target.src;
|
|
2894
|
+
if (firedFor.current === uri) return;
|
|
2895
|
+
firedFor.current = uri;
|
|
2896
|
+
handlers.current.onError?.({ nativeEvent: { error: loadError(uri) } });
|
|
2897
|
+
handlers.current.onLoadEnd?.();
|
|
2898
|
+
}, []);
|
|
2899
|
+
const handleLoad = useCallback((event) => fireLoad(event.currentTarget), [fireLoad]);
|
|
2900
|
+
const handleError = useCallback((event) => fireError(event.currentTarget), [fireError]);
|
|
2901
|
+
useEffect(() => {
|
|
2902
|
+
const target = img.current;
|
|
2903
|
+
if (target === null || currentSrc === void 0 || !target.complete) return;
|
|
2904
|
+
if (target.naturalWidth > 0) fireLoad(target);
|
|
2905
|
+
else fireError(target);
|
|
2906
|
+
});
|
|
2907
|
+
const requestError = requested.error;
|
|
2908
|
+
useEffect(() => {
|
|
2909
|
+
if (requestError === void 0) return;
|
|
2910
|
+
if (firedFor.current === resolved.src) return;
|
|
2911
|
+
firedFor.current = resolved.src;
|
|
2912
|
+
handlers.current.onError?.({ nativeEvent: { error: requestError } });
|
|
2913
|
+
handlers.current.onLoadEnd?.();
|
|
2914
|
+
}, [requestError, resolved.src]);
|
|
2915
|
+
const { tag, role } = resolveTag(rest, "div", true);
|
|
2916
|
+
const sizeStyle = {
|
|
2917
|
+
width: userBoxStyle["width"] ?? width ?? resolved.width,
|
|
2918
|
+
height: userBoxStyle["height"] ?? height ?? resolved.height
|
|
2919
|
+
};
|
|
2920
|
+
const boxClassName = compileStyle([
|
|
2921
|
+
boxStyle,
|
|
2922
|
+
sizeStyle,
|
|
2923
|
+
userBoxStyle
|
|
2924
|
+
], registry);
|
|
2925
|
+
const label = alt ?? rest.accessibilityLabel ?? rest["aria-label"];
|
|
2926
|
+
const domProps = toDOMProps(rest);
|
|
2927
|
+
domProps["className"] = boxClassName;
|
|
2928
|
+
domProps["ref"] = element;
|
|
2929
|
+
if (role !== void 0) domProps["role"] = role;
|
|
2930
|
+
else if (painted && label !== void 0 && label !== "") {
|
|
2931
|
+
domProps["role"] = "img";
|
|
2932
|
+
domProps["aria-label"] = label;
|
|
2630
2933
|
}
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2934
|
+
const imgStyle = {
|
|
2935
|
+
objectFit: objectFitOf[resizeMode],
|
|
2936
|
+
filter: blurRadius !== void 0 && blurRadius > 0 ? `blur(${blurRadius}px)` : void 0
|
|
2937
|
+
};
|
|
2938
|
+
const placeholder = placeholderURI(defaultSource);
|
|
2939
|
+
const showPlaceholder = placeholder !== void 0 && (currentSrc === void 0 || loadedSrc !== currentSrc);
|
|
2940
|
+
let paintStyle;
|
|
2941
|
+
if (painted && currentSrc !== void 0) {
|
|
2942
|
+
const url = cssURL(currentSrc);
|
|
2943
|
+
const repeat = resizeMode === "repeat" ? "repeat" : "no-repeat";
|
|
2944
|
+
paintStyle = tintColor === void 0 ? {
|
|
2945
|
+
backgroundImage: url,
|
|
2946
|
+
backgroundRepeat: repeat,
|
|
2947
|
+
backgroundPosition: "center",
|
|
2948
|
+
backgroundSize: "auto"
|
|
2949
|
+
} : {
|
|
2950
|
+
backgroundColor: tintColor,
|
|
2951
|
+
WebkitMaskImage: url,
|
|
2952
|
+
maskImage: url,
|
|
2953
|
+
WebkitMaskRepeat: repeat,
|
|
2954
|
+
maskRepeat: repeat,
|
|
2955
|
+
WebkitMaskPosition: "center",
|
|
2956
|
+
maskPosition: "center",
|
|
2957
|
+
WebkitMaskSize: maskSizeOf[resizeMode],
|
|
2958
|
+
maskSize: maskSizeOf[resizeMode]
|
|
2640
2959
|
};
|
|
2641
2960
|
}
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2961
|
+
const children = [/* @__PURE__ */ jsx("img", {
|
|
2962
|
+
ref: img,
|
|
2963
|
+
src: currentSrc,
|
|
2964
|
+
srcSet: resolved.srcSet,
|
|
2965
|
+
sizes: resolved.sizes,
|
|
2966
|
+
alt: painted ? "" : label ?? "",
|
|
2967
|
+
"aria-hidden": painted ? true : void 0,
|
|
2968
|
+
draggable: false,
|
|
2969
|
+
crossOrigin,
|
|
2970
|
+
referrerPolicy,
|
|
2971
|
+
loading,
|
|
2972
|
+
fetchPriority,
|
|
2973
|
+
decoding,
|
|
2974
|
+
onLoad: handleLoad,
|
|
2975
|
+
onError: handleError,
|
|
2976
|
+
className: compileStyle([
|
|
2977
|
+
fillStyle,
|
|
2978
|
+
imgStyle,
|
|
2979
|
+
painted && hiddenStyle
|
|
2980
|
+
], registry)
|
|
2981
|
+
}, "img")];
|
|
2982
|
+
if (showPlaceholder) children.unshift(/* @__PURE__ */ jsx("img", {
|
|
2983
|
+
src: placeholder,
|
|
2984
|
+
alt: "",
|
|
2985
|
+
"aria-hidden": true,
|
|
2986
|
+
draggable: false,
|
|
2987
|
+
className: compileStyle([fillStyle, imgStyle], registry)
|
|
2988
|
+
}, "placeholder"));
|
|
2989
|
+
if (paintStyle !== void 0) children.push(/* @__PURE__ */ jsx("div", {
|
|
2990
|
+
"aria-hidden": true,
|
|
2991
|
+
className: compileStyle([fillStyle, paintStyle], registry)
|
|
2992
|
+
}, "paint"));
|
|
2993
|
+
return createElement(tag, domProps, ...children);
|
|
2994
|
+
}
|
|
2995
|
+
const loadSize = (uri) => new Promise((resolve, reject) => {
|
|
2996
|
+
if (!hasDOM()) {
|
|
2997
|
+
reject(/* @__PURE__ */ new Error("Image.getSize needs a DOM"));
|
|
2998
|
+
return;
|
|
2650
2999
|
}
|
|
3000
|
+
const probe = document.createElement("img");
|
|
3001
|
+
probe.addEventListener("load", () => resolve(sizeOf(probe)), { once: true });
|
|
3002
|
+
probe.addEventListener("error", () => reject(new Error(loadError(uri))), { once: true });
|
|
3003
|
+
probe.src = uri;
|
|
3004
|
+
});
|
|
3005
|
+
const fetchObjectURL = async (uri, headers) => {
|
|
3006
|
+
const response = await fetch(uri, { headers });
|
|
3007
|
+
if (!response.ok) throw new Error(`${loadError(uri)} (HTTP ${response.status})`);
|
|
3008
|
+
return URL.createObjectURL(await response.blob());
|
|
2651
3009
|
};
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
}, [pressability]);
|
|
2663
|
-
return pressability === null ? null : pressability.getEventHandlers();
|
|
3010
|
+
const withCallbacks = (promise, success, failure) => {
|
|
3011
|
+
if (success === void 0) return promise;
|
|
3012
|
+
promise.then((size) => success(size.width, size.height), (error) => failure?.(error));
|
|
3013
|
+
};
|
|
3014
|
+
function getSize(uri, success, failure) {
|
|
3015
|
+
return withCallbacks(loadSize(uri), success, failure);
|
|
3016
|
+
}
|
|
3017
|
+
function getSizeWithHeaders(uri, headers, success, failure) {
|
|
3018
|
+
const promise = fetchObjectURL(uri, headers).then((url) => loadSize(url).finally(() => URL.revokeObjectURL(url)));
|
|
3019
|
+
return withCallbacks(promise, success, failure);
|
|
2664
3020
|
}
|
|
3021
|
+
const Image = Object.assign(ImageComponent, {
|
|
3022
|
+
getSize,
|
|
3023
|
+
getSizeWithHeaders,
|
|
3024
|
+
prefetch: (url) => loadSize(url).then(() => true),
|
|
3025
|
+
queryCache: () => Promise.resolve({}),
|
|
3026
|
+
resolveAssetSource
|
|
3027
|
+
});
|
|
2665
3028
|
// src/components/Pressable/index.tsx
|
|
2666
|
-
const notCancelableStyle = Object.freeze({ touchAction: "none" });
|
|
2667
|
-
const hitSlopClass = (registry, hitSlop) => {
|
|
2668
|
-
if (hitSlop === void 0) return void 0;
|
|
2669
|
-
const { top = 0, right = 0, bottom = 0, left = 0 } = typeof hitSlop === "number" ? {
|
|
2670
|
-
top: hitSlop,
|
|
2671
|
-
right: hitSlop,
|
|
2672
|
-
bottom: hitSlop,
|
|
2673
|
-
left: hitSlop
|
|
2674
|
-
} : hitSlop;
|
|
2675
|
-
if (top === 0 && right === 0 && bottom === 0 && left === 0) return void 0;
|
|
2676
|
-
const name = `rn-hs-${[
|
|
2677
|
-
top,
|
|
2678
|
-
right,
|
|
2679
|
-
bottom,
|
|
2680
|
-
left
|
|
2681
|
-
].map((n) => String(n).replace(/[^0-9]/g, "_")).join("-")}`;
|
|
2682
|
-
return registry.staticClass(name, [`.${name}::before{content:"";position:absolute;top:${-top}px;right:${-right}px;bottom:${-bottom}px;left:${-left}px;z-index:-1}`]);
|
|
2683
|
-
};
|
|
3029
|
+
const notCancelableStyle$1 = Object.freeze({ touchAction: "none" });
|
|
2684
3030
|
const isFocusVisible = (element) => {
|
|
2685
3031
|
try {
|
|
2686
3032
|
return element.matches(":focus-visible");
|
|
@@ -2688,31 +3034,6 @@ const isFocusVisible = (element) => {
|
|
|
2688
3034
|
return true;
|
|
2689
3035
|
}
|
|
2690
3036
|
};
|
|
2691
|
-
const sharedHandlers = [
|
|
2692
|
-
"onClick",
|
|
2693
|
-
"onContextMenu",
|
|
2694
|
-
"onKeyDown",
|
|
2695
|
-
"onKeyUp",
|
|
2696
|
-
"onPointerCancel",
|
|
2697
|
-
"onPointerDown",
|
|
2698
|
-
"onPointerEnter",
|
|
2699
|
-
"onPointerLeave",
|
|
2700
|
-
"onPointerMove",
|
|
2701
|
-
"onPointerUp"
|
|
2702
|
-
];
|
|
2703
|
-
const mergeHandlers = (app, own) => {
|
|
2704
|
-
const merged = { ...own };
|
|
2705
|
-
for (const key of sharedHandlers) {
|
|
2706
|
-
const first = app[key];
|
|
2707
|
-
if (first === void 0) continue;
|
|
2708
|
-
const second = own[key];
|
|
2709
|
-
merged[key] = (event) => {
|
|
2710
|
-
first(event);
|
|
2711
|
-
second(event);
|
|
2712
|
-
};
|
|
2713
|
-
}
|
|
2714
|
-
return merged;
|
|
2715
|
-
};
|
|
2716
3037
|
const Pressable = memo(function Pressable(props) {
|
|
2717
3038
|
const { android_disableSound, android_ripple: _androidRipple, blockNativeResponder, cancelable, children, delayHoverIn, delayHoverOut, delayLongPress, disabled, focusable, hitSlop, onBlur, onFocus, onHoverIn, onHoverOut, onLongPress, onPress, onPressIn, onPressMove, onPressOut, pressRetentionOffset, style, testOnly_pressed, unstable_pressDelay, ...rest } = props;
|
|
2718
3039
|
const [pressed, setPressed] = useState(false);
|
|
@@ -2789,7 +3110,7 @@ const Pressable = memo(function Pressable(props) {
|
|
|
2789
3110
|
...rest,
|
|
2790
3111
|
...mergeHandlers(rest, handlers),
|
|
2791
3112
|
focusable: disabled !== true && focusable !== false,
|
|
2792
|
-
style: [typeof style === "function" ? style(state) : style, cancelable === false && notCancelableStyle],
|
|
3113
|
+
style: [typeof style === "function" ? style(state) : style, cancelable === false && notCancelableStyle$1],
|
|
2793
3114
|
children: typeof children === "function" ? children(state) : children
|
|
2794
3115
|
};
|
|
2795
3116
|
if (disabled === true) viewProps["aria-disabled"] = true;
|
|
@@ -2902,91 +3223,86 @@ const StatusBar = Object.assign(StatusBarComponent, {
|
|
|
2902
3223
|
popStackEntry,
|
|
2903
3224
|
replaceStackEntry
|
|
2904
3225
|
});
|
|
2905
|
-
// src/components/
|
|
2906
|
-
const
|
|
2907
|
-
|
|
2908
|
-
const
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
const
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
const
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
}
|
|
2937
|
-
const
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
const
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
}
|
|
2975
|
-
disabled,
|
|
2976
|
-
onClick,
|
|
2977
|
-
onPress
|
|
2978
|
-
]);
|
|
2979
|
-
const domProps = toDOMProps(rest);
|
|
2980
|
-
if (role !== void 0) domProps["role"] = role;
|
|
2981
|
-
if (tag.length === 2 && tag[0] === "h") delete domProps["aria-level"];
|
|
2982
|
-
if (tag === "button") domProps["type"] = "button";
|
|
2983
|
-
if (disabled === true) domProps["aria-disabled"] = true;
|
|
2984
|
-
if (onPress !== void 0 || onClick !== void 0) domProps["onClick"] = handleClick;
|
|
2985
|
-
domProps["className"] = className;
|
|
2986
|
-
domProps["ref"] = element;
|
|
2987
|
-
const content = nested ? children : createElement(TextAncestorContext.Provider, { value: true }, children);
|
|
2988
|
-
return createElement(tag, domProps, content);
|
|
3226
|
+
// src/components/Switch/index.tsx
|
|
3227
|
+
const TRACK_OFF = "#939393";
|
|
3228
|
+
const TRACK_ON = "#A3D3CF";
|
|
3229
|
+
const THUMB_OFF = "#FAFAFA";
|
|
3230
|
+
const THUMB_ON = "#009688";
|
|
3231
|
+
const INPUT_CLASS = "rn-switch-input";
|
|
3232
|
+
const RULES = [
|
|
3233
|
+
`.${INPUT_CLASS}{position:absolute;inset:0;width:100%;height:100%;margin:0;padding:0;opacity:0;cursor:pointer;z-index:1}`,
|
|
3234
|
+
`.${INPUT_CLASS}:disabled{cursor:default}`,
|
|
3235
|
+
".rn-switch-track{height:70%;border-radius:9999px;transition:background-color .15s}",
|
|
3236
|
+
".rn-switch-row{position:absolute;inset:0;display:flex;border-radius:9999px}",
|
|
3237
|
+
".rn-switch-spacer{flex-grow:0;transition:flex-grow .15s}",
|
|
3238
|
+
".rn-switch-thumb{height:100%;aspect-ratio:1;border-radius:50%;box-shadow:0 1px 3px rgba(0,0,0,.5);transition:background-color .15s}",
|
|
3239
|
+
`.${INPUT_CLASS}:checked~.rn-switch-row>.rn-switch-spacer{flex-grow:1}`,
|
|
3240
|
+
`.${INPUT_CLASS}:focus-visible~.rn-switch-row{outline:auto;outline-offset:2px}`,
|
|
3241
|
+
"@media (prefers-reduced-motion:reduce){.rn-switch-track,.rn-switch-spacer,.rn-switch-thumb{transition:none}}"
|
|
3242
|
+
];
|
|
3243
|
+
function Switch(props) {
|
|
3244
|
+
const { accessibilityRole, accessibilityState, disabled, ios_backgroundColor: _iosBackgroundColor, onChange, onLayout, onTintColor: _onTintColor, onValueChange, pointerEvents, ref, role, style, thumbColor, thumbTintColor: _thumbTintColor, tintColor: _tintColor, trackColor, value, ...rest } = props;
|
|
3245
|
+
const inputClass = useStyleRegistry().staticClass(INPUT_CLASS, RULES);
|
|
3246
|
+
const on = value === true;
|
|
3247
|
+
const resolvedDisabled = disabled ?? accessibilityState?.disabled;
|
|
3248
|
+
const state = resolvedDisabled === accessibilityState?.disabled ? accessibilityState : {
|
|
3249
|
+
...accessibilityState,
|
|
3250
|
+
disabled: resolvedDisabled
|
|
3251
|
+
};
|
|
3252
|
+
const handleChange = (event) => {
|
|
3253
|
+
const next = event.target.checked;
|
|
3254
|
+
Object.assign(event.nativeEvent, { value: next });
|
|
3255
|
+
onChange?.(event);
|
|
3256
|
+
onValueChange?.(next);
|
|
3257
|
+
};
|
|
3258
|
+
const inputProps = toDOMProps({
|
|
3259
|
+
...rest,
|
|
3260
|
+
accessibilityState: state
|
|
3261
|
+
});
|
|
3262
|
+
inputProps["role"] = role ?? accessibilityRole ?? "switch";
|
|
3263
|
+
const track = toCSSColor(on ? trackColor?.true : trackColor?.false) ?? (on ? TRACK_ON : TRACK_OFF);
|
|
3264
|
+
const thumb = toCSSColor(thumbColor) ?? (on ? THUMB_ON : THUMB_OFF);
|
|
3265
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
3266
|
+
onLayout,
|
|
3267
|
+
pointerEvents,
|
|
3268
|
+
style: [
|
|
3269
|
+
styles.root,
|
|
3270
|
+
style,
|
|
3271
|
+
resolvedDisabled === true && styles.disabled
|
|
3272
|
+
],
|
|
3273
|
+
children: [
|
|
3274
|
+
/* @__PURE__ */ jsx("input", {
|
|
3275
|
+
...inputProps,
|
|
3276
|
+
checked: on,
|
|
3277
|
+
className: inputClass,
|
|
3278
|
+
disabled: resolvedDisabled === true,
|
|
3279
|
+
onChange: handleChange,
|
|
3280
|
+
ref,
|
|
3281
|
+
type: "checkbox"
|
|
3282
|
+
}),
|
|
3283
|
+
/* @__PURE__ */ jsx("div", {
|
|
3284
|
+
className: "rn-switch-track",
|
|
3285
|
+
style: { backgroundColor: track }
|
|
3286
|
+
}),
|
|
3287
|
+
/* @__PURE__ */ jsxs("div", {
|
|
3288
|
+
className: "rn-switch-row",
|
|
3289
|
+
children: [/* @__PURE__ */ jsx("div", { className: "rn-switch-spacer" }), /* @__PURE__ */ jsx("div", {
|
|
3290
|
+
className: "rn-switch-thumb",
|
|
3291
|
+
style: { backgroundColor: thumb }
|
|
3292
|
+
})]
|
|
3293
|
+
})
|
|
3294
|
+
]
|
|
3295
|
+
});
|
|
2989
3296
|
}
|
|
3297
|
+
const styles = StyleSheet.create({
|
|
3298
|
+
root: {
|
|
3299
|
+
alignSelf: "flex-start",
|
|
3300
|
+
width: 40,
|
|
3301
|
+
height: 20,
|
|
3302
|
+
justifyContent: "center"
|
|
3303
|
+
},
|
|
3304
|
+
disabled: { opacity: .5 }
|
|
3305
|
+
});
|
|
2990
3306
|
// src/components/TextInput/autocomplete.ts
|
|
2991
3307
|
const reactNativeToHTML = {
|
|
2992
3308
|
"address-line1": "address-line1",
|
|
@@ -3369,6 +3685,188 @@ const TextInput = Object.assign(TextInputComponent, { State: {
|
|
|
3369
3685
|
focusTextInput: (input) => input?.focus(),
|
|
3370
3686
|
blurTextInput: (input) => input?.blur()
|
|
3371
3687
|
} });
|
|
3372
|
-
|
|
3688
|
+
// src/components/TouchableHighlight/index.tsx
|
|
3689
|
+
const DEFAULT_ACTIVE_OPACITY = .85;
|
|
3690
|
+
const DEFAULT_UNDERLAY_COLOR = "black";
|
|
3691
|
+
const notCancelableStyle = Object.freeze({ touchAction: "none" });
|
|
3692
|
+
function TouchableHighlight(props) {
|
|
3693
|
+
const { activeOpacity, children, delayLongPress, delayPressIn, delayPressOut, disabled, focusable, hasTVPreferredFocus: _hasTVPreferredFocus, hitSlop, nextFocusDown: _nextFocusDown, nextFocusForward: _nextFocusForward, nextFocusLeft: _nextFocusLeft, nextFocusRight: _nextFocusRight, nextFocusUp: _nextFocusUp, onBlur, onFocus, onHideUnderlay, onLongPress, onPress, onPressIn, onPressOut, onShowUnderlay, pressRetentionOffset, rejectResponderTermination, style, testOnly_pressed, touchSoundDisabled, underlayColor, ...rest } = props;
|
|
3694
|
+
const [underlay, setUnderlay] = useState(false);
|
|
3695
|
+
const hideTimer = useRef(null);
|
|
3696
|
+
const resolvedDisabled = disabled ?? props.accessibilityState?.disabled;
|
|
3697
|
+
const hasPressHandler = onPress != null || onPressIn != null || onPressOut != null || onLongPress != null;
|
|
3698
|
+
const handlers = usePressability(useMemo(() => {
|
|
3699
|
+
const clearHideTimer = () => {
|
|
3700
|
+
if (hideTimer.current !== null) clearTimeout(hideTimer.current);
|
|
3701
|
+
hideTimer.current = null;
|
|
3702
|
+
};
|
|
3703
|
+
const show = () => {
|
|
3704
|
+
if (!hasPressHandler) return;
|
|
3705
|
+
setUnderlay(true);
|
|
3706
|
+
onShowUnderlay?.();
|
|
3707
|
+
};
|
|
3708
|
+
const hide = () => {
|
|
3709
|
+
clearHideTimer();
|
|
3710
|
+
if (testOnly_pressed === true || !hasPressHandler) return;
|
|
3711
|
+
setUnderlay(false);
|
|
3712
|
+
onHideUnderlay?.();
|
|
3713
|
+
};
|
|
3714
|
+
return {
|
|
3715
|
+
cancelable: rejectResponderTermination !== true,
|
|
3716
|
+
disabled: resolvedDisabled,
|
|
3717
|
+
hitSlop,
|
|
3718
|
+
delayLongPress,
|
|
3719
|
+
delayPressIn,
|
|
3720
|
+
delayPressOut,
|
|
3721
|
+
minPressDuration: 0,
|
|
3722
|
+
pressRectOffset: pressRetentionOffset,
|
|
3723
|
+
android_disableSound: touchSoundDisabled,
|
|
3724
|
+
onBlur,
|
|
3725
|
+
onFocus,
|
|
3726
|
+
onLongPress,
|
|
3727
|
+
onPress: (event) => {
|
|
3728
|
+
clearHideTimer();
|
|
3729
|
+
show();
|
|
3730
|
+
hideTimer.current = setTimeout(hide, delayPressOut ?? 0);
|
|
3731
|
+
onPress?.(event);
|
|
3732
|
+
},
|
|
3733
|
+
onPressIn: (event) => {
|
|
3734
|
+
clearHideTimer();
|
|
3735
|
+
show();
|
|
3736
|
+
onPressIn?.(event);
|
|
3737
|
+
},
|
|
3738
|
+
onPressOut: (event) => {
|
|
3739
|
+
if (hideTimer.current === null) hide();
|
|
3740
|
+
onPressOut?.(event);
|
|
3741
|
+
}
|
|
3742
|
+
};
|
|
3743
|
+
}, [
|
|
3744
|
+
delayLongPress,
|
|
3745
|
+
delayPressIn,
|
|
3746
|
+
delayPressOut,
|
|
3747
|
+
hasPressHandler,
|
|
3748
|
+
hitSlop,
|
|
3749
|
+
onBlur,
|
|
3750
|
+
onFocus,
|
|
3751
|
+
onHideUnderlay,
|
|
3752
|
+
onLongPress,
|
|
3753
|
+
onPress,
|
|
3754
|
+
onPressIn,
|
|
3755
|
+
onPressOut,
|
|
3756
|
+
onShowUnderlay,
|
|
3757
|
+
pressRetentionOffset,
|
|
3758
|
+
rejectResponderTermination,
|
|
3759
|
+
resolvedDisabled,
|
|
3760
|
+
testOnly_pressed,
|
|
3761
|
+
touchSoundDisabled
|
|
3762
|
+
]));
|
|
3763
|
+
const registry = useStyleRegistry();
|
|
3764
|
+
useEffect(() => () => {
|
|
3765
|
+
if (hideTimer.current !== null) clearTimeout(hideTimer.current);
|
|
3766
|
+
}, []);
|
|
3767
|
+
const pressed = underlay || testOnly_pressed === true;
|
|
3768
|
+
const child = Children.only(children);
|
|
3769
|
+
if (child.type === Fragment) warnOnce("TouchableHighlight-fragment", "TouchableHighlight does not support a Fragment as its child. Wrap the children in one View.");
|
|
3770
|
+
const content = child.type === Fragment ? child : cloneElement(child, { style: [child.props.style, pressed && { opacity: activeOpacity ?? DEFAULT_ACTIVE_OPACITY }] });
|
|
3771
|
+
return useViewElement({
|
|
3772
|
+
...rest,
|
|
3773
|
+
...mergeHandlers(rest, handlers),
|
|
3774
|
+
focusable: focusable !== false && onPress !== void 0 && disabled !== true,
|
|
3775
|
+
style: [
|
|
3776
|
+
style,
|
|
3777
|
+
pressed && { backgroundColor: underlayColor ?? DEFAULT_UNDERLAY_COLOR },
|
|
3778
|
+
rejectResponderTermination === true && notCancelableStyle
|
|
3779
|
+
],
|
|
3780
|
+
children: content,
|
|
3781
|
+
...resolvedDisabled === true && { "aria-disabled": true }
|
|
3782
|
+
}, hitSlopClass(registry, hitSlop));
|
|
3783
|
+
}
|
|
3784
|
+
// src/components/TouchableWithoutFeedback/index.tsx
|
|
3785
|
+
const isTrue = (value) => value === void 0 ? void 0 : value === true || value === "true";
|
|
3786
|
+
function TouchableWithoutFeedback(props) {
|
|
3787
|
+
const { children, delayLongPress, delayPressIn, delayPressOut, disabled, focusable, hitSlop, onBlur, onFocus, onLongPress, onPress, onPressIn, onPressOut, pressRetentionOffset, rejectResponderTermination, style: _style, touchSoundDisabled, ...rest } = props;
|
|
3788
|
+
const resolvedDisabled = disabled ?? isTrue(props["aria-disabled"]) ?? props.accessibilityState?.disabled;
|
|
3789
|
+
const handlers = usePressability(useMemo(() => ({
|
|
3790
|
+
cancelable: rejectResponderTermination !== true,
|
|
3791
|
+
disabled: resolvedDisabled,
|
|
3792
|
+
hitSlop,
|
|
3793
|
+
delayLongPress,
|
|
3794
|
+
delayPressIn,
|
|
3795
|
+
delayPressOut,
|
|
3796
|
+
minPressDuration: 0,
|
|
3797
|
+
pressRectOffset: pressRetentionOffset,
|
|
3798
|
+
android_disableSound: touchSoundDisabled,
|
|
3799
|
+
onBlur,
|
|
3800
|
+
onFocus,
|
|
3801
|
+
onLongPress,
|
|
3802
|
+
onPress,
|
|
3803
|
+
onPressIn,
|
|
3804
|
+
onPressOut
|
|
3805
|
+
}), [
|
|
3806
|
+
delayLongPress,
|
|
3807
|
+
delayPressIn,
|
|
3808
|
+
delayPressOut,
|
|
3809
|
+
hitSlop,
|
|
3810
|
+
onBlur,
|
|
3811
|
+
onFocus,
|
|
3812
|
+
onLongPress,
|
|
3813
|
+
onPress,
|
|
3814
|
+
onPressIn,
|
|
3815
|
+
onPressOut,
|
|
3816
|
+
pressRetentionOffset,
|
|
3817
|
+
rejectResponderTermination,
|
|
3818
|
+
resolvedDisabled,
|
|
3819
|
+
touchSoundDisabled
|
|
3820
|
+
]));
|
|
3821
|
+
const element = Children.only(children);
|
|
3822
|
+
const passed = {};
|
|
3823
|
+
for (const [name, value] of Object.entries(rest)) if (value !== void 0) passed[name] = value;
|
|
3824
|
+
if (hitSlop !== void 0) passed["hitSlop"] = hitSlop;
|
|
3825
|
+
if (disabled != null) passed["accessibilityState"] = {
|
|
3826
|
+
...rest.accessibilityState,
|
|
3827
|
+
disabled
|
|
3828
|
+
};
|
|
3829
|
+
const merged = mergeHandlers(element.props, handlers);
|
|
3830
|
+
const childFocus = onFocus === void 0 ? element.props.onFocus : void 0;
|
|
3831
|
+
const childBlur = onBlur === void 0 ? element.props.onBlur : void 0;
|
|
3832
|
+
return cloneElement(element, {
|
|
3833
|
+
...passed,
|
|
3834
|
+
...merged,
|
|
3835
|
+
onFocus: childFocus === void 0 ? merged.onFocus : (event) => {
|
|
3836
|
+
merged.onFocus(event);
|
|
3837
|
+
childFocus(event);
|
|
3838
|
+
},
|
|
3839
|
+
onBlur: childBlur === void 0 ? merged.onBlur : (event) => {
|
|
3840
|
+
merged.onBlur(event);
|
|
3841
|
+
childBlur(event);
|
|
3842
|
+
},
|
|
3843
|
+
accessible: rest.accessible !== false,
|
|
3844
|
+
focusable: focusable !== false && onPress !== void 0 && disabled !== true
|
|
3845
|
+
});
|
|
3846
|
+
}
|
|
3847
|
+
// src/components/TouchableNativeFeedback/index.tsx
|
|
3848
|
+
const TouchableNativeFeedback = Object.assign(function TouchableNativeFeedback(props) {
|
|
3849
|
+
const { background: _background, hasTVPreferredFocus: _hasTVPreferredFocus, nextFocusDown: _nextFocusDown, nextFocusForward: _nextFocusForward, nextFocusLeft: _nextFocusLeft, nextFocusRight: _nextFocusRight, nextFocusUp: _nextFocusUp, useForeground: _useForeground, ...rest } = props;
|
|
3850
|
+
return createElement(TouchableWithoutFeedback, rest);
|
|
3851
|
+
}, {
|
|
3852
|
+
SelectableBackground: (rippleRadius) => ({
|
|
3853
|
+
type: "ThemeAttrAndroid",
|
|
3854
|
+
attribute: "selectableItemBackground",
|
|
3855
|
+
rippleRadius
|
|
3856
|
+
}),
|
|
3857
|
+
SelectableBackgroundBorderless: (rippleRadius) => ({
|
|
3858
|
+
type: "ThemeAttrAndroid",
|
|
3859
|
+
attribute: "selectableItemBackgroundBorderless",
|
|
3860
|
+
rippleRadius
|
|
3861
|
+
}),
|
|
3862
|
+
Ripple: (color, borderless, rippleRadius) => ({
|
|
3863
|
+
type: "RippleAndroid",
|
|
3864
|
+
color: processColor(color),
|
|
3865
|
+
borderless,
|
|
3866
|
+
rippleRadius
|
|
3867
|
+
}),
|
|
3868
|
+
canUseNativeForeground: () => false
|
|
3869
|
+
});
|
|
3870
|
+
export { AccessibilityInfo, ActivityIndicator, Appearance, BackHandler, Button, Dimensions, FlatList, I18nManager, Image, PanResponder, PixelRatio, Platform, Pressable, ScrollView, StatusBar, StyleSheet, Switch, Text, TextAncestorContext, TextInput, TouchableHighlight, TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback, View, processColor, useColorScheme, usePressability, useWindowDimensions };
|
|
3373
3871
|
|
|
3374
3872
|
//# sourceMappingURL=index.js.map
|