@rootnative/web 0.0.0-alpha.1 → 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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i as matchesMedia, n as isProductionEnv, r as isTestEnv, t as hasDOM } from "./env-BQE0B2yw.js";
2
- import { n as useStyleRegistry, o as getStyleRegistry } from "./StyleRegistryContext-D6yDrZk0.js";
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";
3
3
  import normalizeColor from "@react-native/normalize-colors";
4
4
  import { Children, Fragment, cloneElement, createContext, createElement, isValidElement, memo, useCallback, useContext, useEffect, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1053,1635 +1053,1980 @@ function useViewElement(props, extraClassName) {
1053
1053
  domProps["ref"] = element;
1054
1054
  return createElement(tag, domProps, children);
1055
1055
  }
1056
- // src/components/ScrollView/snap.ts
1057
- const nearest = (offset, candidates) => {
1058
- let best;
1059
- let distance = Infinity;
1060
- for (const candidate of candidates) {
1061
- const d = Math.abs(candidate - offset);
1062
- if (d < distance) {
1063
- distance = d;
1064
- best = candidate;
1065
- }
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
+ });
1066
1135
  }
1067
- return best;
1068
1136
  };
1069
- const snapTarget = (offset, viewport, contentSize, config) => {
1070
- const max = Math.max(0, contentSize - viewport);
1071
- let target;
1072
- if (config.offsets !== void 0) {
1073
- if (config.offsets.length === 0) return void 0;
1074
- const first = Math.min(...config.offsets);
1075
- const last = Math.max(...config.offsets);
1076
- if (!config.snapToStart && offset < first) return void 0;
1077
- if (!config.snapToEnd && offset > last) return void 0;
1078
- const candidates = [...config.offsets];
1079
- if (config.snapToStart) candidates.push(0);
1080
- if (config.snapToEnd) candidates.push(max);
1081
- target = nearest(offset, candidates);
1082
- } else if (config.interval !== void 0 && config.interval > 0) {
1083
- const { interval, alignment } = config;
1084
- const shift = alignment === "center" ? (viewport - interval) / 2 : alignment === "end" ? viewport - interval : 0;
1085
- target = Math.round((offset + shift) / interval) * interval - shift;
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
+ });
1086
1161
  }
1087
- if (target === void 0) return void 0;
1088
- target = Math.min(max, Math.max(0, target));
1089
- return Math.abs(target - offset) < .5 ? void 0 : target;
1162
+ return event;
1090
1163
  };
1091
- // src/components/ScrollView/index.tsx
1092
- const scrollerStyle = Object.freeze({
1093
- flexGrow: 1,
1094
- flexShrink: 1,
1095
- overflowX: "hidden",
1096
- overflowY: "auto",
1097
- WebkitOverflowScrolling: "touch"
1098
- });
1099
- const horizontalScrollerStyle = Object.freeze({
1100
- flexDirection: "row",
1101
- overflowX: "auto",
1102
- overflowY: "hidden"
1103
- });
1104
- const disabledScrollerStyle = Object.freeze({
1105
- overflowX: "hidden",
1106
- overflowY: "hidden"
1107
- });
1108
- const horizontalContentStyle = Object.freeze({ flexDirection: "row" });
1109
- const centerContentStyle = Object.freeze({
1110
- flexGrow: 1,
1111
- justifyContent: "center"
1112
- });
1113
- const stickyStyle = Object.freeze({
1114
- position: "sticky",
1115
- top: 0,
1116
- zIndex: 10
1117
- });
1118
- const invertedStickyStyle = Object.freeze({
1119
- position: "sticky",
1120
- bottom: 0,
1121
- zIndex: 10
1122
- });
1123
- 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}"]);
1124
- const supportsScrollEnd = hasDOM() && "onscrollend" in window;
1125
- const SCROLL_END_DELAY = 150;
1126
- const behaviorFor = (animated) => animated !== false && !Platform.isDisableAnimations ? "smooth" : "auto";
1127
- const describe = (element) => ({
1128
- contentInset: {
1129
- top: 0,
1130
- left: 0,
1131
- bottom: 0,
1132
- 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"
1133
1177
  },
1134
- contentOffset: {
1135
- x: element.scrollLeft,
1136
- y: element.scrollTop
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"
1137
1184
  },
1138
- contentSize: {
1139
- width: element.scrollWidth,
1140
- height: element.scrollHeight
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"
1141
1191
  },
1142
- layoutMeasurement: {
1143
- width: element.clientWidth,
1144
- height: element.clientHeight
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"
1145
1197
  },
1146
- zoomScale: 1
1147
- });
1148
- const isReactNativeScrollTo = (value) => typeof value === "object" && value !== null && ("x" in value || "y" in value || "animated" in value);
1149
- const domScrollTo = (element, options) => {
1150
- const init = { behavior: behaviorFor(options.animated) };
1151
- if (options.x !== void 0) init.left = options.x;
1152
- if (options.y !== void 0) init.top = options.y;
1153
- element.scrollTo(init);
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
+ }
1154
1211
  };
1155
- function ScrollView(props) {
1156
- 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;
1157
- const registry = useStyleRegistry();
1158
- const scroller = useRef(null);
1159
- const content = useRef(null);
1160
- const handlers = useRef({});
1161
- useEffect(() => {
1162
- handlers.current = {
1163
- onScroll,
1164
- onScrollBeginDrag,
1165
- onScrollEndDrag,
1166
- onMomentumScrollBegin,
1167
- onMomentumScrollEnd
1168
- };
1169
- });
1170
- const snap = useRef({
1171
- horizontal,
1172
- pagingEnabled: pagingEnabled === true,
1173
- snapToInterval,
1174
- snapToOffsets,
1175
- snapToAlignment,
1176
- snapToStart,
1177
- snapToEnd,
1178
- keyboardDismissMode,
1179
- stickyHeaderHiddenOnScroll: stickyHeaderHiddenOnScroll === true
1180
- });
1181
- useEffect(() => {
1182
- snap.current = {
1183
- horizontal,
1184
- pagingEnabled: pagingEnabled === true,
1185
- snapToInterval,
1186
- snapToOffsets,
1187
- snapToAlignment,
1188
- snapToStart,
1189
- snapToEnd,
1190
- keyboardDismissMode,
1191
- stickyHeaderHiddenOnScroll: stickyHeaderHiddenOnScroll === true
1192
- };
1193
- });
1194
- const sequence = useRef({
1195
- phase: "idle",
1196
- pointerDown: false,
1197
- lastEvent: null,
1198
- lastOffset: 0,
1199
- timer: void 0,
1200
- snapping: false
1201
- });
1202
- const stickyHeaders = useRef([]);
1203
- const refreshEvent = useCallback(() => {
1204
- const state = sequence.current;
1205
- const element = scroller.current;
1206
- if (state.lastEvent === null || element === null) return null;
1207
- Object.assign(state.lastEvent.nativeEvent, describe(element));
1208
- return state.lastEvent;
1209
- }, []);
1210
- const settle = useCallback(() => {
1211
- const state = sequence.current;
1212
- const element = scroller.current;
1213
- if (element === null) return;
1214
- if (state.pointerDown && state.phase === "drag") return;
1215
- if (state.phase === "momentum") {
1216
- const event = refreshEvent();
1217
- if (event !== null) handlers.current.onMomentumScrollEnd?.(event);
1218
- }
1219
- state.phase = "idle";
1220
- if (state.snapping) {
1221
- state.snapping = false;
1222
- return;
1223
- }
1224
- const config = snap.current;
1225
- const axis = config.horizontal;
1226
- const viewport = axis ? element.clientWidth : element.clientHeight;
1227
- const target = snapTarget(axis ? element.scrollLeft : element.scrollTop, viewport, axis ? element.scrollWidth : element.scrollHeight, {
1228
- offsets: config.snapToOffsets,
1229
- interval: config.pagingEnabled ? viewport : config.snapToInterval,
1230
- alignment: config.snapToAlignment,
1231
- snapToStart: config.snapToStart,
1232
- snapToEnd: config.snapToEnd
1233
- });
1234
- if (target === void 0) return;
1235
- state.snapping = true;
1236
- domScrollTo(element, axis ? { x: target } : { y: target });
1237
- }, [refreshEvent]);
1238
- const handleScroll = (event) => {
1239
- const element = event.currentTarget;
1240
- if (event.target !== element) return;
1241
- const state = sequence.current;
1242
- const scrollEvent = event;
1243
- Object.assign(scrollEvent.nativeEvent, describe(element));
1244
- state.lastEvent = scrollEvent;
1245
- const config = snap.current;
1246
- const offset = config.horizontal ? element.scrollLeft : element.scrollTop;
1247
- const delta = offset - state.lastOffset;
1248
- state.lastOffset = offset;
1249
- if (state.phase === "idle") {
1250
- if (state.pointerDown) {
1251
- state.phase = "drag";
1252
- handlers.current.onScrollBeginDrag?.(scrollEvent);
1253
- if (config.keyboardDismissMode === "on-drag") {
1254
- const active = document.activeElement;
1255
- if (active instanceof HTMLElement && active !== document.body) active.blur();
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);
1256
1324
  }
1257
- } else {
1258
- state.phase = "momentum";
1259
- handlers.current.onMomentumScrollBegin?.(scrollEvent);
1260
- }
1261
- } else if (state.phase === "released") {
1262
- state.phase = "momentum";
1263
- handlers.current.onMomentumScrollBegin?.(scrollEvent);
1264
- }
1265
- if (config.stickyHeaderHiddenOnScroll && !config.horizontal && delta !== 0) {
1266
- const hidden = delta > 0;
1267
- for (const header of stickyHeaders.current) {
1268
- header.style.transition = "transform 150ms";
1269
- header.style.transform = hidden ? "translateY(-100%)" : "";
1270
- }
1271
- }
1272
- handlers.current.onScroll?.(scrollEvent);
1273
- if (!supportsScrollEnd) {
1274
- if (state.timer !== void 0) clearTimeout(state.timer);
1275
- state.timer = setTimeout(settle, SCROLL_END_DELAY);
1276
- }
1277
- };
1278
- const handleScrollEnd = (event) => {
1279
- if (event.target !== event.currentTarget) return;
1280
- settle();
1281
- };
1282
- const handlePointerDown = (event) => {
1283
- onPointerDown?.(event);
1284
- const state = sequence.current;
1285
- if (state.pointerDown) return;
1286
- state.pointerDown = true;
1287
- const release = () => {
1288
- window.removeEventListener("pointerup", release);
1289
- window.removeEventListener("pointercancel", release);
1290
- state.pointerDown = false;
1291
- if (state.phase === "drag") {
1292
- state.phase = "released";
1293
- const scrollEvent = refreshEvent();
1294
- if (scrollEvent !== null) handlers.current.onScrollEndDrag?.(scrollEvent);
1295
- }
1296
- };
1297
- window.addEventListener("pointerup", release);
1298
- window.addEventListener("pointercancel", release);
1299
- };
1300
- useEffect(() => {
1301
- const state = sequence.current;
1302
- return () => {
1303
- if (state.timer !== void 0) clearTimeout(state.timer);
1304
- };
1305
- }, []);
1306
- const onContentLayout = onContentSizeChange === void 0 ? void 0 : (event) => onContentSizeChange(event.nativeEvent.layout.width, event.nativeEvent.layout.height);
1307
- const stickySet = stickyHeaderIndices !== void 0 && stickyHeaderIndices.length > 0 && !horizontal ? new Set(stickyHeaderIndices) : void 0;
1308
- const setStickyHeader = useCallback((node) => {
1309
- const list = stickyHeaders.current;
1310
- if (node === null) return;
1311
- if (!list.includes(node)) list.push(node);
1312
- return () => {
1313
- const index = list.indexOf(node);
1314
- if (index !== -1) list.splice(index, 1);
1315
- };
1316
- }, []);
1317
- let items = children;
1318
- if (stickySet !== void 0) items = Children.toArray(children).map((child, index) => stickySet.has(index) ? /* @__PURE__ */ jsx(View, {
1319
- ref: setStickyHeader,
1320
- style: invertStickyHeaders === true ? invertedStickyStyle : stickyStyle,
1321
- children: child
1322
- }, isValidElement(child) && child.key !== null ? child.key : `sticky-${index}`) : child);
1323
- const contentElement = /* @__PURE__ */ jsx(View, {
1324
- ref: content,
1325
- onLayout: onContentLayout,
1326
- style: [
1327
- horizontal && horizontalContentStyle,
1328
- centerContent === true && centerContentStyle,
1329
- contentContainerStyle
1330
- ],
1331
- children: items
1332
- });
1333
- const hideScrollbar = horizontal ? !showsHorizontalScrollIndicator : !showsVerticalScrollIndicator;
1334
- const scrollerElement = useViewElement({
1335
- ...rest,
1336
- ref: scroller,
1337
- style: [
1338
- scrollerStyle,
1339
- horizontal && horizontalScrollerStyle,
1340
- !scrollEnabled && disabledScrollerStyle,
1341
- style
1342
- ],
1343
- onScroll: handleScroll,
1344
- onScrollEnd: handleScrollEnd,
1345
- onPointerDown: handlePointerDown,
1346
- children: contentElement
1347
- }, hideScrollbar ? hiddenScrollbarClass(registry) : void 0);
1348
- const offsetX = contentOffset?.x;
1349
- const offsetY = contentOffset?.y;
1350
- useLayoutEffect(() => {
1351
- const element = scroller.current;
1352
- if (element === null || offsetX === void 0 && offsetY === void 0) return;
1353
- if (offsetX !== void 0) element.scrollLeft = offsetX;
1354
- if (offsetY !== void 0) element.scrollTop = offsetY;
1355
- sequence.current.lastOffset = horizontal ? element.scrollLeft : element.scrollTop;
1356
- }, [
1357
- offsetX,
1358
- offsetY,
1359
- horizontal
1360
- ]);
1361
- useImperativeHandle(ref, () => {
1362
- const element = scroller.current;
1363
- const nativeScrollTo = element.scrollTo.bind(element);
1364
- const instance = element;
1365
- return Object.assign(instance, {
1366
- scrollTo: ((first, second) => {
1367
- if (isReactNativeScrollTo(first)) domScrollTo(element, first);
1368
- else if (typeof first === "number" && typeof second === "number") nativeScrollTo(first, second);
1369
- else nativeScrollTo(first);
1370
- }),
1371
- scrollToEnd: (options) => {
1372
- const animated = options?.animated;
1373
- domScrollTo(element, horizontal ? {
1374
- x: element.scrollWidth,
1375
- animated
1376
- } : {
1377
- y: element.scrollHeight,
1378
- animated
1379
- });
1380
1325
  },
1381
- flashScrollIndicators: () => {},
1382
- getScrollResponder: () => instance,
1383
- getScrollableNode: () => element,
1384
- getInnerViewNode: () => content.current,
1385
- getInnerViewRef: () => content.current,
1386
- getNativeScrollRef: () => element
1387
- });
1388
- }, [horizontal]);
1389
- return refreshControl === void 0 ? scrollerElement : cloneElement(refreshControl, void 0, scrollerElement);
1390
- }
1391
- // src/components/FlatList/viewability.ts
1392
- const pixelsVisible = (top, bottom, viewport) => Math.max(0, Math.min(bottom, viewport) - Math.max(top, 0));
1393
- const isEntirelyVisible = (top, bottom, viewport) => top >= 0 && bottom <= viewport && bottom > top;
1394
- const isViewable = (viewAreaMode, threshold, top, bottom, viewport, length) => {
1395
- if (isEntirelyVisible(top, bottom, viewport)) return true;
1396
- const pixels = pixelsVisible(top, bottom, viewport);
1397
- return 100 * (viewAreaMode ? pixels / viewport : pixels / length) >= threshold;
1398
- };
1399
- const computeViewableIndices = (itemCount, metricsAt, scrollOffset, viewport, config) => {
1400
- const { itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold } = config;
1401
- const viewAreaMode = viewAreaCoveragePercentThreshold != null;
1402
- const threshold = viewAreaMode ? viewAreaCoveragePercentThreshold : itemVisiblePercentThreshold;
1403
- if (threshold == null || viewAreaMode === (itemVisiblePercentThreshold != null)) throw new Error("Must set exactly one of itemVisiblePercentThreshold or viewAreaCoveragePercentThreshold");
1404
- const viewable = [];
1405
- let firstVisible = -1;
1406
- for (let index = 0; index < itemCount; index++) {
1407
- const metrics = metricsAt(index);
1408
- if (metrics === void 0) continue;
1409
- const top = Math.floor(metrics.offset - scrollOffset);
1410
- const bottom = Math.floor(top + metrics.length);
1411
- if (top < viewport && bottom > 0) {
1412
- firstVisible = index;
1413
- if (isViewable(viewAreaMode, threshold, top, bottom, viewport, metrics.length)) viewable.push(index);
1414
- } else if (firstVisible >= 0) break;
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
+ };
1415
1395
  }
1416
- return viewable;
1417
- };
1418
- const sameIndices = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
1419
- var ViewabilityTracker = class {
1420
- constructor(config = { viewAreaCoveragePercentThreshold: 0 }) {
1421
- this.interacted = false;
1422
- this.timers = /* @__PURE__ */ new Set();
1423
- this.viewableIndices = [];
1424
- this.viewableItems = /* @__PURE__ */ new Map();
1425
- this.config = config;
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;
1426
1407
  }
1427
- dispose() {
1428
- for (const timer of this.timers) clearTimeout(timer);
1429
- this.timers.clear();
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);
1430
1421
  }
1431
- recordInteraction() {
1432
- this.interacted = true;
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;
1433
1428
  }
1434
- resetViewableIndices() {
1435
- this.viewableIndices = [];
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);
1436
1455
  }
1437
- onUpdate(itemCount, metricsAt, scrollOffset, viewport, createViewToken, onViewableItemsChanged) {
1438
- if (this.config.waitForInteraction === true && !this.interacted || itemCount === 0) return;
1439
- if (metricsAt(0) === void 0) return;
1440
- const next = computeViewableIndices(itemCount, metricsAt, scrollOffset, viewport, this.config);
1441
- if (sameIndices(this.viewableIndices, next)) return;
1442
- this.viewableIndices = next;
1443
- const { minimumViewTime } = this.config;
1444
- if (minimumViewTime !== void 0 && minimumViewTime > 0) {
1445
- const timer = setTimeout(() => {
1446
- this.timers.delete(timer);
1447
- if (this.viewableIndices !== next) return;
1448
- this.report(next, createViewToken, onViewableItemsChanged);
1449
- }, minimumViewTime);
1450
- this.timers.add(timer);
1451
- } 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);
1452
1464
  }
1453
- report(indices, createViewToken, onViewableItemsChanged) {
1454
- const previous = this.viewableItems;
1455
- const next = /* @__PURE__ */ new Map();
1456
- for (const index of indices) {
1457
- const token = createViewToken(index, true);
1458
- next.set(token.key, token);
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);
1459
1473
  }
1460
- const changed = [];
1461
- for (const [key, token] of next) if (!previous.has(key)) changed.push(token);
1462
- for (const [key, token] of previous) if (!next.has(key)) changed.push({
1463
- ...token,
1464
- isViewable: false
1465
- });
1466
- if (changed.length === 0) return;
1467
- this.viewableItems = next;
1468
- onViewableItemsChanged({
1469
- viewableItems: Array.from(next.values()),
1470
- changed
1471
- });
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}`;
1472
1624
  }
1473
- };
1474
- // src/components/FlatList/index.tsx
1475
- const rowStyle = Object.freeze({ flexDirection: "row" });
1476
- const rowReverseStyle = Object.freeze({ flexDirection: "row-reverse" });
1477
- const columnReverseStyle = Object.freeze({ flexDirection: "column-reverse" });
1478
- const verticallyInvertedStyle = Object.freeze({ transform: [{ scaleY: -1 }] });
1479
- const horizontallyInvertedStyle = Object.freeze({ transform: [{ scaleX: -1 }] });
1480
- const ON_EDGE_REACHED_EPSILON = .001;
1481
- const DEFAULT_EDGE_THRESHOLD_PX = 2;
1482
- const defaultKeyExtractor = (item, index) => {
1483
- if (typeof item === "object" && item !== null) {
1484
- const record = item;
1485
- if (record.key != null) return String(record.key);
1486
- 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;
1487
1636
  }
1488
- return String(index);
1489
- };
1490
- const isArrayLike = (data) => data != null && typeof data.length === "number";
1491
- const renderListComponent = (component) => {
1492
- if (component == null) return null;
1493
- if (isValidElement(component)) return component;
1494
- return /* @__PURE__ */ jsx(component, {});
1495
- };
1496
- function CustomScroller({ render, ref, ...props }) {
1497
- 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);
1498
1641
  }
1499
- function Cell(props) {
1500
- const { cellKey, prevCellKey, index, item, style, renderCell, ItemSeparatorComponent, CellRendererComponent, separatorUpdaters, onElement } = props;
1501
- const [separatorProps, setSeparatorProps] = useState({
1502
- highlighted: false,
1503
- leadingItem: item
1504
- });
1505
- const shown = separatorProps.leadingItem === item ? separatorProps : {
1506
- ...separatorProps,
1507
- leadingItem: item
1508
- };
1509
- useEffect(() => {
1510
- separatorUpdaters.set(cellKey, (next) => {
1511
- setSeparatorProps((current) => ({
1512
- ...current,
1513
- ...next
1514
- }));
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"
1515
1684
  });
1516
- return () => {
1517
- separatorUpdaters.delete(cellKey);
1518
- };
1519
- }, [cellKey, separatorUpdaters]);
1520
- const separators = useMemo(() => {
1521
- const update = (keys, next) => {
1522
- 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;
1523
1690
  };
1524
- return {
1525
- highlight: () => update([cellKey, prevCellKey], { highlighted: true }),
1526
- unhighlight: () => update([cellKey, prevCellKey], { highlighted: false }),
1527
- updateProps: (select, next) => update([select === "leading" ? prevCellKey : cellKey], next)
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
1528
1744
  };
1745
+ fadeTo(resting, 250, true);
1529
1746
  }, [
1530
- cellKey,
1531
- prevCellKey,
1532
- separatorUpdaters
1747
+ disabled,
1748
+ fadeTo,
1749
+ resting
1533
1750
  ]);
1534
- const setElement = useCallback((node) => {
1535
- if (node === null) return;
1536
- onElement(index, node);
1537
- return () => onElement(index, null);
1538
- }, [index, onElement]);
1539
- let separator = null;
1540
- if (ItemSeparatorComponent != null) {
1541
- if (isValidElement(ItemSeparatorComponent)) separator = ItemSeparatorComponent;
1542
- else separator = /* @__PURE__ */ jsx(ItemSeparatorComponent, { ...shown });
1543
- }
1544
- const element = renderCell(item, index, separators);
1545
- if (CellRendererComponent != null) return /* @__PURE__ */ jsx(View, {
1546
- ref: setElement,
1547
- children: /* @__PURE__ */ jsxs(CellRendererComponent, {
1548
- cellKey,
1549
- index,
1550
- item,
1551
- style,
1552
- children: [element, separator]
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
1553
1790
  })
1554
1791
  });
1555
- return /* @__PURE__ */ jsxs(View, {
1556
- ref: setElement,
1557
- style,
1558
- children: [element, separator]
1559
- });
1560
1792
  }
1561
- const createTrackers = (props) => {
1562
- if (props.viewabilityConfigCallbackPairs !== void 0) return props.viewabilityConfigCallbackPairs.map((pair) => ({
1563
- tracker: new ViewabilityTracker(pair.viewabilityConfig),
1564
- callback: () => pair.onViewableItemsChanged
1565
- }));
1566
- if (props.onViewableItemsChanged != null) return [{
1567
- tracker: new ViewabilityTracker(props.viewabilityConfig),
1568
- callback: (latest) => latest.onViewableItemsChanged
1569
- }];
1570
- return [];
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);
1571
1905
  };
1572
- function FlatList(props) {
1573
- 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;
1574
- if (numColumns > 1 && horizontal) throw new Error("numColumns does not support horizontal.");
1575
- const latest = useRef(props);
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({});
1576
1912
  useEffect(() => {
1577
- latest.current = props;
1913
+ handlers.current = {
1914
+ onScroll,
1915
+ onScrollBeginDrag,
1916
+ onScrollEndDrag,
1917
+ onMomentumScrollBegin,
1918
+ onMomentumScrollEnd
1919
+ };
1578
1920
  });
1579
- const scroller = useRef(null);
1580
- const [cells] = useState(() => /* @__PURE__ */ new Map());
1581
- const [separatorUpdaters] = useState(() => /* @__PURE__ */ new Map());
1582
- const [trackers] = useState(() => createTrackers(props));
1583
- const edge = useRef({
1584
- sentEndForContentLength: 0,
1585
- sentStartForContentLength: 0
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
1586
1931
  });
1587
1932
  useEffect(() => {
1588
- return () => {
1589
- for (const entry of trackers) entry.tracker.dispose();
1590
- };
1591
- }, [trackers]);
1592
- const onElement = useCallback((index, node) => {
1593
- if (node === null) cells.delete(index);
1594
- else cells.set(index, node);
1595
- }, [cells]);
1596
- const items = isArrayLike(data) ? data : [];
1597
- const rowCount = numColumns > 1 ? Math.ceil(items.length / numColumns) : items.length;
1598
- const rowAt = (index) => {
1599
- if (numColumns === 1) return items[index];
1600
- const row = [];
1601
- for (let column = 0; column < numColumns; column++) {
1602
- const itemIndex = index * numColumns + column;
1603
- if (itemIndex < items.length) row.push(items[itemIndex]);
1604
- }
1605
- return row;
1606
- };
1607
- const rowKey = (row, index) => {
1608
- if (numColumns === 1) return keyExtractor(row, index);
1609
- return row.map((item, column) => keyExtractor(item, index * numColumns + column)).join(":");
1610
- };
1611
- const metricsAt = useCallback((index) => {
1612
- const element = cells.get(index);
1613
- const { horizontal: isHorizontal = false, getItemLayout, data: currentData } = latest.current;
1614
- if (element !== void 0) return isHorizontal ? {
1615
- offset: element.offsetLeft,
1616
- length: element.offsetWidth
1617
- } : {
1618
- offset: element.offsetTop,
1619
- length: element.offsetHeight
1620
- };
1621
- const layout = getItemLayout?.(currentData, index);
1622
- return layout === void 0 ? void 0 : {
1623
- offset: layout.offset,
1624
- length: layout.length
1625
- };
1626
- }, [cells]);
1627
- const maybeCallOnEdgeReached = useCallback(() => {
1628
- const element = scroller.current;
1629
- if (element === null) return;
1630
- const { horizontal: isHorizontal = false, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold } = latest.current;
1631
- const visibleLength = isHorizontal ? element.clientWidth : element.clientHeight;
1632
- const contentLength = isHorizontal ? element.scrollWidth : element.scrollHeight;
1633
- if (visibleLength === 0 || contentLength === 0) return;
1634
- const offset = isHorizontal ? element.scrollLeft : element.scrollTop;
1635
- let distanceFromStart = offset;
1636
- let distanceFromEnd = contentLength - visibleLength - offset;
1637
- if (distanceFromStart < ON_EDGE_REACHED_EPSILON) distanceFromStart = 0;
1638
- if (distanceFromEnd < ON_EDGE_REACHED_EPSILON) distanceFromEnd = 0;
1639
- const startThreshold = onStartReachedThreshold != null ? onStartReachedThreshold * visibleLength : DEFAULT_EDGE_THRESHOLD_PX;
1640
- const endThreshold = onEndReachedThreshold != null ? onEndReachedThreshold * visibleLength : DEFAULT_EDGE_THRESHOLD_PX;
1641
- const withinStart = distanceFromStart <= startThreshold;
1642
- const withinEnd = distanceFromEnd <= endThreshold;
1643
- const state = edge.current;
1644
- if (onEndReached != null && withinEnd && contentLength !== state.sentEndForContentLength) {
1645
- state.sentEndForContentLength = contentLength;
1646
- onEndReached({ distanceFromEnd });
1647
- }
1648
- if (onStartReached != null && withinStart && contentLength !== state.sentStartForContentLength) {
1649
- state.sentStartForContentLength = contentLength;
1650
- onStartReached({ distanceFromStart });
1651
- }
1652
- if (!withinStart) state.sentStartForContentLength = 0;
1653
- if (!withinEnd) state.sentEndForContentLength = 0;
1654
- }, []);
1655
- const updateViewability = useCallback(() => {
1656
- const element = scroller.current;
1657
- if (element === null || trackers.length === 0) return;
1658
- const current = latest.current;
1659
- const isHorizontal = current.horizontal === true;
1660
- const columns = current.numColumns ?? 1;
1661
- const extract = current.keyExtractor ?? defaultKeyExtractor;
1662
- const currentItems = isArrayLike(current.data) ? current.data : [];
1663
- const count = columns > 1 ? Math.ceil(currentItems.length / columns) : currentItems.length;
1664
- const createToken = (index, isViewable) => {
1665
- if (columns === 1) {
1666
- const item = currentItems[index];
1667
- return {
1668
- item,
1669
- key: extract(item, index),
1670
- index,
1671
- isViewable
1672
- };
1673
- }
1674
- const row = [];
1675
- for (let column = 0; column < columns; column++) {
1676
- const itemIndex = index * columns + column;
1677
- if (itemIndex < currentItems.length) row.push(currentItems[itemIndex]);
1678
- }
1679
- return {
1680
- item: row,
1681
- key: row.map((item, column) => extract(item, index * columns + column)).join(":"),
1682
- index,
1683
- isViewable
1684
- };
1685
- };
1686
- const expand = (tokens) => {
1687
- if (columns === 1) return tokens;
1688
- const out = [];
1689
- for (const token of tokens) token.item.forEach((item, column) => {
1690
- const index = (token.index ?? 0) * columns + column;
1691
- out.push({
1692
- ...token,
1693
- item,
1694
- key: extract(item, index),
1695
- index
1696
- });
1697
- });
1698
- 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
1699
1943
  };
1700
- const offset = isHorizontal ? element.scrollLeft : element.scrollTop;
1701
- const viewport = isHorizontal ? element.clientWidth : element.clientHeight;
1702
- for (const entry of trackers) {
1703
- const handler = entry.callback(current);
1704
- if (handler == null) continue;
1705
- entry.tracker.onUpdate(count, metricsAt, offset, viewport, createToken, (info) => {
1706
- handler({
1707
- viewableItems: expand(info.viewableItems),
1708
- changed: expand(info.changed)
1709
- });
1710
- });
1711
- }
1712
- }, [metricsAt, trackers]);
1713
- const handleScroll = useCallback((event) => {
1714
- latest.current.onScroll?.(event);
1715
- maybeCallOnEdgeReached();
1716
- updateViewability();
1717
- }, [maybeCallOnEdgeReached, updateViewability]);
1718
- const handleContentSizeChange = useCallback((width, height) => {
1719
- latest.current.onContentSizeChange?.(width, height);
1720
- maybeCallOnEdgeReached();
1721
- updateViewability();
1722
- }, [maybeCallOnEdgeReached, updateViewability]);
1723
- const handleLayout = useCallback((event) => {
1724
- latest.current.onLayout?.(event);
1725
- maybeCallOnEdgeReached();
1726
- updateViewability();
1727
- }, [maybeCallOnEdgeReached, updateViewability]);
1728
- useEffect(() => {
1729
- updateViewability();
1730
1944
  });
1731
- const scrollToOffset = useCallback((offset, animated) => {
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;
1732
1956
  const element = scroller.current;
1733
- if (element === null) return;
1734
- element.scrollTo(latest.current.horizontal === true ? {
1735
- x: offset,
1736
- animated
1737
- } : {
1738
- y: offset,
1739
- animated
1740
- });
1957
+ if (state.lastEvent === null || element === null) return null;
1958
+ Object.assign(state.lastEvent.nativeEvent, describe(element));
1959
+ return state.lastEvent;
1741
1960
  }, []);
1742
- const scrollToIndex = useCallback((params) => {
1743
- const current = latest.current;
1744
- const columns = current.numColumns ?? 1;
1745
- const currentItems = isArrayLike(current.data) ? current.data : [];
1746
- const count = columns > 1 ? Math.ceil(currentItems.length / columns) : currentItems.length;
1747
- const { animated, index, viewOffset, viewPosition } = params;
1748
- if (index < 0) throw new Error(`scrollToIndex out of range: requested index ${index} but minimum is 0`);
1749
- if (count < 1) throw new Error(`scrollToIndex out of range: item length ${count} but minimum is 1`);
1750
- if (index >= count) throw new Error(`scrollToIndex out of range: requested index ${index} is out of 0 to ${count - 1}`);
1751
- const frame = metricsAt(Math.floor(index));
1961
+ const settle = useCallback(() => {
1962
+ const state = sequence.current;
1752
1963
  const element = scroller.current;
1753
- if (frame === void 0 || element === null) {
1754
- const { onScrollToIndexFailed } = current;
1755
- 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.");
1756
- onScrollToIndexFailed({
1757
- index,
1758
- highestMeasuredFrameIndex: -1,
1759
- averageItemLength: 0
1760
- });
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;
1761
1973
  return;
1762
1974
  }
1763
- const visibleLength = current.horizontal === true ? element.clientWidth : element.clientHeight;
1764
- const offset = Math.max(0, frame.offset - (viewPosition ?? 0) * (visibleLength - frame.length)) - (viewOffset ?? 0);
1765
- scrollToOffset(offset, animated);
1766
- }, [metricsAt, scrollToOffset]);
1767
- useImperativeHandle(ref, () => ({
1768
- scrollToOffset: (params) => scrollToOffset(params.offset, params.animated),
1769
- scrollToEnd: (params) => scroller.current?.scrollToEnd({ animated: params?.animated }),
1770
- scrollToIndex,
1771
- scrollToItem: ({ item, ...rest }) => {
1772
- const current = latest.current;
1773
- const columns = current.numColumns ?? 1;
1774
- const currentItems = isArrayLike(current.data) ? current.data : [];
1775
- for (let index = 0; index < currentItems.length; index++) if (currentItems[index] === item) {
1776
- scrollToIndex({
1777
- ...rest,
1778
- index: Math.floor(index / columns)
1779
- });
1780
- return;
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);
1781
2011
  }
1782
- },
1783
- recordInteraction: () => {
1784
- for (const entry of trackers) entry.tracker.recordInteraction();
1785
- updateViewability();
1786
- },
1787
- flashScrollIndicators: () => {},
1788
- getScrollResponder: () => scroller.current,
1789
- getNativeScrollRef: () => scroller.current,
1790
- getScrollableNode: () => scroller.current,
1791
- setNativeProps: () => {}
1792
- }), [
1793
- scrollToIndex,
1794
- scrollToOffset,
1795
- trackers,
1796
- updateViewability
1797
- ]);
1798
- useLayoutEffect(() => {
1799
- const index = latest.current.initialScrollIndex;
1800
- const element = scroller.current;
1801
- if (index == null || element === null) return;
1802
- const frame = metricsAt(index);
1803
- if (frame === void 0) return;
1804
- if (latest.current.horizontal === true) element.scrollLeft = frame.offset;
1805
- else element.scrollTop = frame.offset;
1806
- }, [metricsAt]);
1807
- const inversionStyle = inverted ? horizontal ? horizontallyInvertedStyle : verticallyInvertedStyle : void 0;
1808
- const cellStyle = inversionStyle ? horizontal ? [rowReverseStyle, inversionStyle] : [columnReverseStyle, inversionStyle] : horizontal ? rowStyle : void 0;
1809
- const renderOne = (info) => {
1810
- if (ListItemComponent !== void 0) return /* @__PURE__ */ jsx(ListItemComponent, { ...info });
1811
- if (renderItem != null) return renderItem(info);
1812
- 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
+ }
1813
2028
  };
1814
- const renderCell = (row, index, separators) => {
1815
- if (numColumns === 1) return renderOne({
1816
- item: row,
1817
- index,
1818
- separators
1819
- });
1820
- return /* @__PURE__ */ jsx(View, {
1821
- style: [rowStyle, columnWrapperStyle],
1822
- children: row.map((item, column) => {
1823
- const element = renderOne({
1824
- item,
1825
- index: index * numColumns + column,
1826
- separators
1827
- });
1828
- return element == null ? null : /* @__PURE__ */ jsx(Fragment, { children: element }, column);
1829
- })
1830
- });
2029
+ const handleScrollEnd = (event) => {
2030
+ if (event.target !== event.currentTarget) return;
2031
+ settle();
1831
2032
  };
1832
- const children = [];
1833
- if (ListHeaderComponent != null) children.push(/* @__PURE__ */ jsx(View, {
1834
- style: [inversionStyle, ListHeaderComponentStyle],
1835
- children: renderListComponent(ListHeaderComponent)
1836
- }, "$header"));
1837
- if (rowCount === 0) {
1838
- if (ListEmptyComponent != null) children.push(/* @__PURE__ */ jsx(View, {
1839
- style: inversionStyle,
1840
- children: renderListComponent(ListEmptyComponent)
1841
- }, "$empty"));
1842
- } else {
1843
- let prevCellKey;
1844
- for (let index = 0; index < rowCount; index++) {
1845
- const row = rowAt(index);
1846
- const cellKey = rowKey(row, index);
1847
- children.push(/* @__PURE__ */ jsx(Cell, {
1848
- cellKey,
1849
- prevCellKey,
1850
- index,
1851
- item: row,
1852
- style: cellStyle,
1853
- renderCell,
1854
- ItemSeparatorComponent: index < rowCount - 1 ? ItemSeparatorComponent : void 0,
1855
- CellRendererComponent,
1856
- separatorUpdaters,
1857
- onElement
1858
- }, cellKey));
1859
- prevCellKey = cellKey;
1860
- }
1861
- }
1862
- if (ListFooterComponent != null) children.push(/* @__PURE__ */ jsx(View, {
1863
- style: [inversionStyle, ListFooterComponentStyle],
1864
- children: renderListComponent(ListFooterComponent)
1865
- }, "$footer"));
1866
- const scrollProps = {
1867
- ...scrollViewProps,
1868
- horizontal,
1869
- style: [inversionStyle, style],
1870
- onScroll: handleScroll,
1871
- onContentSizeChange: handleContentSizeChange,
1872
- onLayout: handleLayout,
1873
- 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);
1874
2050
  };
1875
- if (renderScrollComponent !== void 0) return /* @__PURE__ */ jsx(CustomScroller, {
1876
- ...scrollProps,
1877
- ref: scroller,
1878
- render: renderScrollComponent
1879
- });
1880
- return /* @__PURE__ */ jsx(ScrollView, {
1881
- ...scrollProps,
1882
- ref: scroller
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
1883
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);
1884
2141
  }
1885
- // src/utils/warn.ts
1886
- const warned = /* @__PURE__ */ new Set();
1887
- const warnOnce = (key, message) => {
1888
- if (isProductionEnv() || warned.has(key)) return;
1889
- warned.add(key);
1890
- console.warn(`[@rootnative/web] ${message}`);
1891
- };
1892
- // src/components/Image/source.ts
1893
- const none = Object.freeze({
1894
- src: void 0,
1895
- srcSet: void 0,
1896
- sizes: void 0,
1897
- width: void 0,
1898
- height: void 0,
1899
- request: void 0
1900
- });
1901
- 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.";
1902
- const hasURI = (source) => typeof source.uri === "string" && source.uri.length > 0;
1903
- const requestOf = (source) => {
1904
- if (source.headers === void 0 && source.method === void 0 && source.body === void 0) return;
1905
- return {
1906
- method: source.method ?? "GET",
1907
- headers: source.headers,
1908
- body: source.body
1909
- };
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;
1910
2149
  };
1911
- const single = (source) => ({
1912
- src: source.uri,
1913
- srcSet: void 0,
1914
- sizes: void 0,
1915
- width: source.width,
1916
- height: source.height,
1917
- request: requestOf(source)
1918
- });
1919
- const firstCandidate = (srcSet) => srcSet.split(",")[0]?.trim().split(/\s+/)[0];
1920
- const list = (sources, layoutWidth) => {
1921
- const first = sources[0];
1922
- if (sources.length === 1) return single(first);
1923
- if (sources.every((s) => typeof s.width === "number")) return {
1924
- src: first.uri,
1925
- srcSet: sources.map((s) => `${s.uri} ${s.width}w`).join(", "),
1926
- sizes: layoutWidth === void 0 ? "100vw" : `${layoutWidth}px`,
1927
- width: void 0,
1928
- height: void 0,
1929
- request: void 0
1930
- };
1931
- if (sources.every((s) => typeof s.scale === "number")) {
1932
- const base = sources.find((s) => s.scale === 1) ?? first;
1933
- return {
1934
- src: base.uri,
1935
- srcSet: sources.map((s) => `${s.uri} ${s.scale}x`).join(", "),
1936
- sizes: void 0,
1937
- width: base.width,
1938
- height: base.height,
1939
- request: void 0
1940
- };
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;
1941
2166
  }
1942
- return single(first);
2167
+ return viewable;
1943
2168
  };
1944
- const resolveSource = (source, src, srcSet, layoutWidth) => {
1945
- if (src !== void 0 || srcSet !== void 0) return {
1946
- ...none,
1947
- src: src ?? (srcSet === void 0 ? void 0 : firstCandidate(srcSet)),
1948
- srcSet,
1949
- sizes: srcSet !== void 0 && /\d+w/.test(srcSet) ? "100vw" : void 0
1950
- };
1951
- if (source === void 0 || source === null) return none;
1952
- if (typeof source === "string") return {
1953
- ...none,
1954
- src: source
1955
- };
1956
- if (typeof source === "number") {
1957
- warnOnce("image-asset-id", ASSET_ID_WARNING);
1958
- 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;
1959
2177
  }
1960
- if (Array.isArray(source)) {
1961
- const sources = source.filter(hasURI);
1962
- return sources.length === 0 ? none : list(sources, layoutWidth);
2178
+ dispose() {
2179
+ for (const timer of this.timers) clearTimeout(timer);
2180
+ this.timers.clear();
1963
2181
  }
1964
- return hasURI(source) ? single(source) : none;
1965
- };
1966
- const resolveAssetSource = (source) => {
1967
- if (typeof source === "string") return {
1968
- uri: source,
1969
- scale: 1
1970
- };
1971
- if (typeof source === "number") {
1972
- warnOnce("image-asset-id", ASSET_ID_WARNING);
1973
- return null;
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
+ });
1974
2223
  }
1975
- const first = Array.isArray(source) ? source[0] : source;
1976
- if (first === void 0 || first === null || !hasURI(first)) return null;
1977
- const { uri, width, height, scale } = first;
1978
- return {
1979
- uri,
1980
- width,
1981
- height,
1982
- scale: scale ?? 1
1983
- };
1984
- };
1985
- // src/components/Image/index.tsx
1986
- const boxStyle = Object.freeze({
1987
- backgroundColor: "transparent",
1988
- border: "0 solid black",
1989
- boxSizing: "border-box",
1990
- display: "flex",
1991
- flexBasis: "auto",
1992
- flexDirection: "column",
1993
- flexShrink: 0,
1994
- margin: 0,
1995
- minHeight: 0,
1996
- minWidth: 0,
1997
- overflow: "hidden",
1998
- padding: 0,
1999
- position: "relative",
2000
- zIndex: 0
2001
- });
2002
- const fillStyle = Object.freeze({
2003
- position: "absolute",
2004
- left: 0,
2005
- top: 0,
2006
- width: "100%",
2007
- height: "100%",
2008
- display: "block",
2009
- border: 0,
2010
- margin: 0,
2011
- padding: 0
2012
- });
2013
- const hiddenStyle = Object.freeze({ visibility: "hidden" });
2014
- const objectFitOf = {
2015
- cover: "cover",
2016
- contain: "contain",
2017
- stretch: "fill",
2018
- center: "none",
2019
- repeat: "none"
2020
- };
2021
- const resizeModeOfObjectFit = {
2022
- cover: "cover",
2023
- contain: "contain",
2024
- fill: "stretch",
2025
- "scale-down": "contain",
2026
- none: "center"
2027
2224
  };
2028
- const maskSizeOf = {
2029
- cover: "cover",
2030
- contain: "contain",
2031
- stretch: "100% 100%",
2032
- center: "auto",
2033
- repeat: "auto"
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);
2034
2240
  };
2035
- const cssURL = (url) => `url("${url.replace(/["\\]/g, "\\$&")}")`;
2036
- const loadError = (uri) => `Failed to load image: ${uri ?? ""}`;
2037
- const sizeOf = (img) => ({
2038
- width: img.naturalWidth,
2039
- height: img.naturalHeight
2040
- });
2041
- const placeholderURI = (source) => {
2042
- if (typeof source === "string") return source;
2043
- 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, {});
2044
2246
  };
2045
- const useRequestURL = (uri, request) => {
2046
- const [state, setState] = useState({
2047
- uri: void 0,
2048
- url: void 0,
2049
- error: void 0
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
2050
2255
  });
2051
- const requestKey = request === void 0 ? void 0 : JSON.stringify(request);
2256
+ const shown = separatorProps.leadingItem === item ? separatorProps : {
2257
+ ...separatorProps,
2258
+ leadingItem: item
2259
+ };
2052
2260
  useEffect(() => {
2053
- if (uri === void 0 || requestKey === void 0) return;
2054
- const { method, headers, body } = JSON.parse(requestKey);
2055
- const controller = new AbortController();
2056
- let objectURL;
2057
- const init = {
2058
- method,
2059
- signal: controller.signal
2261
+ separatorUpdaters.set(cellKey, (next) => {
2262
+ setSeparatorProps((current) => ({
2263
+ ...current,
2264
+ ...next
2265
+ }));
2266
+ });
2267
+ return () => {
2268
+ separatorUpdaters.delete(cellKey);
2060
2269
  };
2061
- if (headers !== void 0) init.headers = headers;
2062
- if (body !== void 0) init.body = body;
2063
- fetch(uri, init).then((response) => {
2064
- if (!response.ok) throw new Error(`HTTP ${response.status}`);
2065
- return response.blob();
2066
- }).then((blob) => {
2067
- objectURL = URL.createObjectURL(blob);
2068
- setState({
2069
- uri,
2070
- url: objectURL,
2071
- error: void 0
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
+ });
2072
2448
  });
2073
- }).catch((error) => {
2074
- if (controller.signal.aborted) return;
2075
- const message = error instanceof Error ? error.message : String(error);
2076
- setState({
2077
- uri,
2078
- url: void 0,
2079
- error: `${loadError(uri)} (${message})`
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
+ });
2080
2461
  });
2081
- });
2082
- return () => {
2083
- controller.abort();
2084
- if (objectURL !== void 0) URL.revokeObjectURL(objectURL);
2085
- };
2086
- }, [uri, requestKey]);
2087
- return state.uri === uri ? state : {
2088
- url: void 0,
2089
- error: void 0
2090
- };
2091
- };
2092
- function ImageComponent(props) {
2093
- 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;
2094
- const element = useRef(null);
2095
- const img = useRef(null);
2096
- useImperativeHandle(ref, () => element.current, []);
2097
- useElementLayout(element, onLayout);
2098
- const registry = useStyleRegistry();
2099
- const { resizeMode: styleResizeMode, objectFit, tintColor: styleTintColor, overlayColor: _overlayColor, ...userBoxStyle } = flattenStyle(style) ?? {};
2100
- const resizeMode = (typeof objectFit === "string" ? resizeModeOfObjectFit[objectFit] : void 0) ?? resizeModeProp ?? styleResizeMode ?? "cover";
2101
- const tintColor = tintColorProp ?? styleTintColor;
2102
- const painted = resizeMode === "repeat" || tintColor !== void 0;
2103
- const styleWidth = userBoxStyle["width"] ?? width;
2104
- const resolved = resolveSource(source, src, srcSet, typeof styleWidth === "number" ? styleWidth : void 0);
2105
- const requested = useRequestURL(resolved.src, resolved.request);
2106
- const currentSrc = resolved.request === void 0 ? resolved.src : requested.url;
2107
- const handlers = useRef({
2108
- onLoad,
2109
- onLoadStart,
2110
- onLoadEnd,
2111
- onError
2112
- });
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]);
2113
2479
  useEffect(() => {
2114
- handlers.current = {
2115
- onLoad,
2116
- onLoadStart,
2117
- onLoadEnd,
2118
- onError
2119
- };
2480
+ updateViewability();
2120
2481
  });
2121
- const [loadedSrc, setLoadedSrc] = useState(void 0);
2122
- const firedFor = useRef(void 0);
2123
- useEffect(() => {
2124
- if (resolved.src === void 0) return;
2125
- firedFor.current = void 0;
2126
- handlers.current.onLoadStart?.();
2127
- }, [resolved.src]);
2128
- const fireLoad = useCallback((target) => {
2129
- const uri = target.currentSrc || target.src;
2130
- if (firedFor.current === uri) return;
2131
- firedFor.current = uri;
2132
- setLoadedSrc(target.src);
2133
- const { width: naturalWidth, height: naturalHeight } = sizeOf(target);
2134
- handlers.current.onLoad?.({ nativeEvent: { source: {
2135
- uri,
2136
- width: naturalWidth,
2137
- height: naturalHeight
2138
- } } });
2139
- handlers.current.onLoadEnd?.();
2140
- }, []);
2141
- const fireError = useCallback((target) => {
2142
- const uri = target.currentSrc || target.src;
2143
- if (firedFor.current === uri) return;
2144
- firedFor.current = uri;
2145
- handlers.current.onError?.({ nativeEvent: { error: loadError(uri) } });
2146
- 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
+ });
2147
2492
  }, []);
2148
- const handleLoad = useCallback((event) => fireLoad(event.currentTarget), [fireLoad]);
2149
- const handleError = useCallback((event) => fireError(event.currentTarget), [fireError]);
2150
- useEffect(() => {
2151
- const target = img.current;
2152
- if (target === null || currentSrc === void 0 || !target.complete) return;
2153
- if (target.naturalWidth > 0) fireLoad(target);
2154
- else fireError(target);
2155
- });
2156
- const requestError = requested.error;
2157
- useEffect(() => {
2158
- if (requestError === void 0) return;
2159
- if (firedFor.current === resolved.src) return;
2160
- firedFor.current = resolved.src;
2161
- handlers.current.onError?.({ nativeEvent: { error: requestError } });
2162
- handlers.current.onLoadEnd?.();
2163
- }, [requestError, resolved.src]);
2164
- const { tag, role } = resolveTag(rest, "div", true);
2165
- const sizeStyle = {
2166
- width: userBoxStyle["width"] ?? width ?? resolved.width,
2167
- height: userBoxStyle["height"] ?? height ?? resolved.height
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.");
2168
2564
  };
2169
- const boxClassName = compileStyle([
2170
- boxStyle,
2171
- sizeStyle,
2172
- userBoxStyle
2173
- ], registry);
2174
- const label = alt ?? rest.accessibilityLabel ?? rest["aria-label"];
2175
- const domProps = toDOMProps(rest);
2176
- domProps["className"] = boxClassName;
2177
- domProps["ref"] = element;
2178
- if (role !== void 0) domProps["role"] = role;
2179
- else if (painted && label !== void 0 && label !== "") {
2180
- domProps["role"] = "img";
2181
- domProps["aria-label"] = label;
2182
- }
2183
- const imgStyle = {
2184
- objectFit: objectFitOf[resizeMode],
2185
- filter: blurRadius !== void 0 && blurRadius > 0 ? `blur(${blurRadius}px)` : void 0
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
+ });
2186
2582
  };
2187
- const placeholder = placeholderURI(defaultSource);
2188
- const showPlaceholder = placeholder !== void 0 && (currentSrc === void 0 || loadedSrc !== currentSrc);
2189
- let paintStyle;
2190
- if (painted && currentSrc !== void 0) {
2191
- const url = cssURL(currentSrc);
2192
- const repeat = resizeMode === "repeat" ? "repeat" : "no-repeat";
2193
- paintStyle = tintColor === void 0 ? {
2194
- backgroundImage: url,
2195
- backgroundRepeat: repeat,
2196
- backgroundPosition: "center",
2197
- backgroundSize: "auto"
2198
- } : {
2199
- backgroundColor: tintColor,
2200
- WebkitMaskImage: url,
2201
- maskImage: url,
2202
- WebkitMaskRepeat: repeat,
2203
- maskRepeat: repeat,
2204
- WebkitMaskPosition: "center",
2205
- maskPosition: "center",
2206
- WebkitMaskSize: maskSizeOf[resizeMode],
2207
- maskSize: maskSizeOf[resizeMode]
2208
- };
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
+ }
2209
2612
  }
2210
- const children = [/* @__PURE__ */ jsx("img", {
2211
- ref: img,
2212
- src: currentSrc,
2213
- srcSet: resolved.srcSet,
2214
- sizes: resolved.sizes,
2215
- alt: painted ? "" : label ?? "",
2216
- "aria-hidden": painted ? true : void 0,
2217
- draggable: false,
2218
- crossOrigin,
2219
- referrerPolicy,
2220
- loading,
2221
- fetchPriority,
2222
- decoding,
2223
- onLoad: handleLoad,
2224
- onError: handleError,
2225
- className: compileStyle([
2226
- fillStyle,
2227
- imgStyle,
2228
- painted && hiddenStyle
2229
- ], registry)
2230
- }, "img")];
2231
- if (showPlaceholder) children.unshift(/* @__PURE__ */ jsx("img", {
2232
- src: placeholder,
2233
- alt: "",
2234
- "aria-hidden": true,
2235
- draggable: false,
2236
- className: compileStyle([fillStyle, imgStyle], registry)
2237
- }, "placeholder"));
2238
- if (paintStyle !== void 0) children.push(/* @__PURE__ */ jsx("div", {
2239
- "aria-hidden": true,
2240
- className: compileStyle([fillStyle, paintStyle], registry)
2241
- }, "paint"));
2242
- 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
+ });
2243
2635
  }
2244
- const loadSize = (uri) => new Promise((resolve, reject) => {
2245
- if (!hasDOM()) {
2246
- reject(/* @__PURE__ */ new Error("Image.getSize needs a DOM"));
2247
- return;
2248
- }
2249
- const probe = document.createElement("img");
2250
- probe.addEventListener("load", () => resolve(sizeOf(probe)), { once: true });
2251
- probe.addEventListener("error", () => reject(new Error(loadError(uri))), { once: true });
2252
- probe.src = uri;
2253
- });
2254
- const fetchObjectURL = async (uri, headers) => {
2255
- const response = await fetch(uri, { headers });
2256
- if (!response.ok) throw new Error(`${loadError(uri)} (HTTP ${response.status})`);
2257
- return URL.createObjectURL(await response.blob());
2258
- };
2259
- const withCallbacks = (promise, success, failure) => {
2260
- if (success === void 0) return promise;
2261
- 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}`);
2262
2642
  };
2263
- function getSize(uri, success, failure) {
2264
- return withCallbacks(loadSize(uri), success, failure);
2265
- }
2266
- function getSizeWithHeaders(uri, headers, success, failure) {
2267
- const promise = fetchObjectURL(uri, headers).then((url) => loadSize(url).finally(() => URL.revokeObjectURL(url)));
2268
- return withCallbacks(promise, success, failure);
2269
- }
2270
- const Image = Object.assign(ImageComponent, {
2271
- getSize,
2272
- getSizeWithHeaders,
2273
- prefetch: (url) => loadSize(url).then(() => true),
2274
- queryCache: () => Promise.resolve({}),
2275
- 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
2276
2651
  });
2277
- // src/events/responderEvent.ts
2278
- const hasPoint = (event) => event.clientX !== void 0 && !(event.type === "click" && event.detail === 0);
2279
- const activeTypes = /* @__PURE__ */ new Set([
2280
- "pointerdown",
2281
- "pointermove",
2282
- "keydown"
2283
- ]);
2284
- const define = (target, fields) => {
2285
- for (const key in fields) {
2286
- if (key in target) continue;
2287
- Object.defineProperty(target, key, {
2288
- value: fields[key],
2289
- configurable: true
2290
- });
2291
- }
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
+ };
2292
2661
  };
2293
- const toGestureResponderEvent = (event, element) => {
2294
- const native = event.nativeEvent;
2295
- if (!("locationX" in native)) {
2296
- const rect = element.getBoundingClientRect();
2297
- const point = hasPoint(native);
2298
- const clientX = point ? native.clientX ?? 0 : rect.left + rect.width / 2;
2299
- const clientY = point ? native.clientY ?? 0 : rect.top + rect.height / 2;
2300
- const touch = {
2301
- changedTouches: [],
2302
- force: native.pressure,
2303
- identifier: native.pointerId ?? 0,
2304
- locationX: clientX - rect.left,
2305
- locationY: clientY - rect.top,
2306
- pageX: clientX + window.scrollX,
2307
- pageY: clientY + window.scrollY,
2308
- target: native.target,
2309
- timestamp: event.timeStamp,
2310
- touches: []
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
2311
2691
  };
2312
- define(native, {
2313
- ...touch,
2314
- changedTouches: [touch],
2315
- touches: activeTypes.has(native.type) ? [touch] : []
2316
- });
2317
2692
  }
2318
- return event;
2693
+ return single(first);
2319
2694
  };
2320
- const toMouseEvent = (event) => {
2321
- define(event.nativeEvent, { timestamp: event.timeStamp });
2322
- return event;
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;
2323
2716
  };
2324
- // src/events/press/Pressability.ts
2325
- const transitions = {
2326
- NOT_RESPONDER: { RESPONDER_GRANT: "RESPONDER_INACTIVE_PRESS_IN" },
2327
- RESPONDER_INACTIVE_PRESS_IN: {
2328
- DELAY: "RESPONDER_ACTIVE_PRESS_IN",
2329
- RESPONDER_RELEASE: "NOT_RESPONDER",
2330
- RESPONDER_TERMINATED: "NOT_RESPONDER",
2331
- ENTER_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_IN",
2332
- LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT"
2333
- },
2334
- RESPONDER_INACTIVE_PRESS_OUT: {
2335
- DELAY: "RESPONDER_ACTIVE_PRESS_OUT",
2336
- RESPONDER_RELEASE: "NOT_RESPONDER",
2337
- RESPONDER_TERMINATED: "NOT_RESPONDER",
2338
- ENTER_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_IN",
2339
- LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT"
2340
- },
2341
- RESPONDER_ACTIVE_PRESS_IN: {
2342
- RESPONDER_RELEASE: "NOT_RESPONDER",
2343
- RESPONDER_TERMINATED: "NOT_RESPONDER",
2344
- ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
2345
- LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT",
2346
- LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
2347
- },
2348
- RESPONDER_ACTIVE_PRESS_OUT: {
2349
- RESPONDER_RELEASE: "NOT_RESPONDER",
2350
- RESPONDER_TERMINATED: "NOT_RESPONDER",
2351
- ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
2352
- LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT"
2353
- },
2354
- RESPONDER_ACTIVE_LONG_PRESS_IN: {
2355
- RESPONDER_RELEASE: "NOT_RESPONDER",
2356
- RESPONDER_TERMINATED: "NOT_RESPONDER",
2357
- ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
2358
- LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_OUT",
2359
- LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
2360
- },
2361
- RESPONDER_ACTIVE_LONG_PRESS_OUT: {
2362
- RESPONDER_RELEASE: "NOT_RESPONDER",
2363
- RESPONDER_TERMINATED: "NOT_RESPONDER",
2364
- ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
2365
- 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;
2366
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
+ };
2367
2735
  };
2368
- const isActive = (state) => state === "RESPONDER_ACTIVE_PRESS_IN" || state === "RESPONDER_ACTIVE_LONG_PRESS_IN";
2369
- const isActivation = (state) => state === "RESPONDER_ACTIVE_PRESS_OUT" || state === "RESPONDER_ACTIVE_PRESS_IN";
2370
- const isPressIn = (state) => state === "RESPONDER_INACTIVE_PRESS_IN" || state === "RESPONDER_ACTIVE_PRESS_IN" || state === "RESPONDER_ACTIVE_LONG_PRESS_IN";
2371
- const isTerminal = (signal) => signal === "RESPONDER_TERMINATED" || signal === "RESPONDER_RELEASE";
2372
- const DEFAULT_LONG_PRESS_DELAY_MS = 500;
2373
- const DEFAULT_MIN_PRESS_DURATION = 130;
2374
- const DEFAULT_PRESS_RECT_OFFSETS = {
2375
- bottom: 30,
2376
- left: 20,
2377
- right: 20,
2378
- top: 20
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"
2379
2771
  };
2380
- let longPressDeactivationDistance = 10;
2381
- const normalizeDelay = (delay, min = 0, fallback = 0) => Math.max(min, delay ?? fallback);
2382
- const normalizeRect = (rect) => typeof rect === "number" ? {
2383
- bottom: rect,
2384
- left: rect,
2385
- right: rect,
2386
- top: rect
2387
- } : rect;
2388
- const claimed = /* @__PURE__ */ new WeakSet();
2389
- const isActivationKey = (key) => key === "Enter" || key === " ";
2390
- const hasNativeActivation = (element) => {
2391
- switch (element.tagName) {
2392
- case "BUTTON":
2393
- case "INPUT":
2394
- case "SELECT":
2395
- case "SUMMARY":
2396
- case "TEXTAREA": return true;
2397
- case "A":
2398
- case "AREA": return element.hasAttribute("href");
2399
- default: return element.isContentEditable;
2400
- }
2772
+ const resizeModeOfObjectFit = {
2773
+ cover: "cover",
2774
+ contain: "contain",
2775
+ fill: "stretch",
2776
+ "scale-down": "contain",
2777
+ none: "center"
2401
2778
  };
2402
- const nativeControl = "a[href],area[href],audio[controls],button,input,select,summary,textarea,video[controls],[contenteditable]:not([contenteditable=\"false\"])";
2403
- const startsInNativeControl = (event) => {
2404
- const { currentTarget, target } = event;
2405
- if (!(target instanceof Element)) return false;
2406
- const control = target.closest(nativeControl);
2407
- return control !== null && control !== currentTarget && currentTarget.contains(control);
2779
+ const maskSizeOf = {
2780
+ cover: "cover",
2781
+ contain: "contain",
2782
+ stretch: "100% 100%",
2783
+ center: "auto",
2784
+ repeat: "auto"
2408
2785
  };
2409
- const clear = (timer) => {
2410
- if (timer !== null) clearTimeout(timer);
2411
- return null;
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;
2412
2795
  };
2413
- var Pressability = class {
2414
- constructor(config) {
2415
- this.state = "NOT_RESPONDER";
2416
- this.element = null;
2417
- this.region = null;
2418
- this.pointerId = null;
2419
- this.key = null;
2420
- this.activatePosition = null;
2421
- this.activateTime = null;
2422
- this.hovered = false;
2423
- this.pointerClickPending = false;
2424
- this.cancelClick = false;
2425
- this.hoverInTimer = null;
2426
- this.hoverOutTimer = null;
2427
- this.longPressTimer = null;
2428
- this.pressDelayTimer = null;
2429
- this.pressOutTimer = null;
2430
- this.config = config;
2431
- this.handlers = this.createEventHandlers();
2432
- }
2433
- configure(config) {
2434
- this.config = config;
2435
- }
2436
- reset() {
2437
- this.hoverInTimer = clear(this.hoverInTimer);
2438
- this.hoverOutTimer = clear(this.hoverOutTimer);
2439
- this.longPressTimer = clear(this.longPressTimer);
2440
- this.pressDelayTimer = clear(this.pressDelayTimer);
2441
- this.pressOutTimer = clear(this.pressOutTimer);
2442
- this.config = Object.freeze({});
2443
- }
2444
- getEventHandlers() {
2445
- return this.handlers;
2446
- }
2447
- static setLongPressDeactivationDistance(distance) {
2448
- longPressDeactivationDistance = distance;
2449
- }
2450
- createEventHandlers() {
2451
- return {
2452
- onPointerDown: (event) => {
2453
- const native = event.nativeEvent;
2454
- if (event.button !== 0 || claimed.has(native) || this.config.disabled === true) return;
2455
- if (startsInNativeControl(event)) return;
2456
- claimed.add(native);
2457
- if (this.pointerId !== null || this.key !== null) return;
2458
- const element = event.currentTarget;
2459
- this.pointerId = event.pointerId;
2460
- this.pointerClickPending = true;
2461
- try {
2462
- element.setPointerCapture(event.pointerId);
2463
- } catch {}
2464
- this.grant(element, toGestureResponderEvent(event, element));
2465
- },
2466
- onPointerMove: (event) => {
2467
- const element = this.element;
2468
- if (event.pointerId !== this.pointerId || element === null) return;
2469
- const pressEvent = toGestureResponderEvent(event, element);
2470
- this.config.onPressMove?.(pressEvent);
2471
- const region = this.region;
2472
- if (region === null) return;
2473
- const { pageX, pageY } = pressEvent.nativeEvent;
2474
- const start = this.activatePosition;
2475
- if (start !== null && Math.hypot(start.pageX - pageX, start.pageY - pageY) > longPressDeactivationDistance) this.longPressTimer = clear(this.longPressTimer);
2476
- if (this.isWithinRegion(pageX, pageY, region)) this.receiveSignal("ENTER_PRESS_RECT", pressEvent);
2477
- else {
2478
- this.longPressTimer = clear(this.longPressTimer);
2479
- this.receiveSignal("LEAVE_PRESS_RECT", pressEvent);
2480
- }
2481
- },
2482
- onPointerUp: (event) => {
2483
- const element = this.element;
2484
- if (event.pointerId !== this.pointerId || element === null) return;
2485
- this.pointerId = null;
2486
- this.receiveSignal("RESPONDER_RELEASE", toGestureResponderEvent(event, element));
2487
- },
2488
- onPointerCancel: (event) => {
2489
- const element = this.element;
2490
- if (event.pointerId !== this.pointerId || element === null) return;
2491
- this.pointerId = null;
2492
- this.pointerClickPending = false;
2493
- this.receiveSignal("RESPONDER_TERMINATED", toGestureResponderEvent(event, element));
2494
- },
2495
- onClick: (event) => {
2496
- const native = event.nativeEvent;
2497
- if (claimed.has(native) || startsInNativeControl(event)) return;
2498
- if (this.pointerClickPending && event.detail > 0) {
2499
- this.pointerClickPending = false;
2500
- claimed.add(native);
2501
- if (this.cancelClick) event.preventDefault();
2502
- return;
2503
- }
2504
- if (this.config.disabled === true) return;
2505
- claimed.add(native);
2506
- this.config.onPress?.(toGestureResponderEvent(event, event.currentTarget));
2507
- },
2508
- onKeyDown: (event) => {
2509
- if (!isActivationKey(event.key) || event.repeat || event.nativeEvent.isComposing) return;
2510
- const element = event.currentTarget;
2511
- if (event.target !== element || this.config.disabled === true) return;
2512
- if (hasNativeActivation(element)) return;
2513
- if (event.key === " ") event.preventDefault();
2514
- if (this.pointerId !== null || this.key !== null) return;
2515
- this.key = event.key;
2516
- this.grant(element, toGestureResponderEvent(event, element));
2517
- },
2518
- onKeyUp: (event) => {
2519
- const element = this.element;
2520
- if (event.key !== this.key || element === null) return;
2521
- this.key = null;
2522
- this.receiveSignal("RESPONDER_RELEASE", toGestureResponderEvent(event, element));
2523
- },
2524
- onFocus: (event) => {
2525
- this.config.onFocus?.(event);
2526
- },
2527
- onBlur: (event) => {
2528
- const element = this.element;
2529
- if (this.key !== null && element !== null && event.target === event.currentTarget) {
2530
- this.key = null;
2531
- this.receiveSignal("RESPONDER_TERMINATED", toGestureResponderEvent(event, element));
2532
- }
2533
- this.config.onBlur?.(event);
2534
- },
2535
- onPointerEnter: (event) => {
2536
- if (event.pointerType === "touch") return;
2537
- this.hovered = true;
2538
- this.hoverOutTimer = clear(this.hoverOutTimer);
2539
- this.hover(event, this.config.onHoverIn, this.config.delayHoverIn, "in");
2540
- },
2541
- onPointerLeave: (event) => {
2542
- if (!this.hovered) return;
2543
- this.hovered = false;
2544
- this.hoverInTimer = clear(this.hoverInTimer);
2545
- this.hover(event, this.config.onHoverOut, this.config.delayHoverOut, "out");
2546
- },
2547
- onContextMenu: (event) => {
2548
- if (this.pointerId !== null && this.config.onLongPress != null) event.preventDefault();
2549
- }
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
2550
2811
  };
2551
- }
2552
- hover(event, callback, delay, direction) {
2553
- if (callback == null) return;
2554
- const hoverEvent = toMouseEvent(event);
2555
- const wait = normalizeDelay(delay);
2556
- if (wait === 0) {
2557
- callback(hoverEvent);
2558
- return;
2559
- }
2560
- const timer = setTimeout(() => callback(hoverEvent), wait);
2561
- if (direction === "in") this.hoverInTimer = timer;
2562
- else this.hoverOutTimer = timer;
2563
- }
2564
- grant(element, event) {
2565
- this.pressOutTimer = clear(this.pressOutTimer);
2566
- this.element = element;
2567
- this.cancelClick = false;
2568
- this.state = "NOT_RESPONDER";
2569
- this.receiveSignal("RESPONDER_GRANT", event);
2570
- const delayPressIn = normalizeDelay(this.config.delayPressIn);
2571
- if (delayPressIn > 0) this.pressDelayTimer = setTimeout(() => this.receiveSignal("DELAY", event), delayPressIn);
2572
- else this.receiveSignal("DELAY", event);
2573
- const delayLongPress = normalizeDelay(this.config.delayLongPress, 10, DEFAULT_LONG_PRESS_DELAY_MS - delayPressIn);
2574
- this.longPressTimer = setTimeout(() => {
2575
- if (this.state === "RESPONDER_ACTIVE_PRESS_IN" || this.state === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.receiveSignal("LONG_PRESS_DETECTED", event);
2576
- }, delayLongPress + delayPressIn);
2577
- }
2578
- receiveSignal(signal, event) {
2579
- const prevState = this.state;
2580
- const nextState = transitions[prevState][signal];
2581
- if (nextState === void 0 || nextState === prevState) return;
2582
- this.performTransitionSideEffects(prevState, nextState, signal, event);
2583
- this.state = nextState;
2584
- }
2585
- performTransitionSideEffects(prevState, nextState, signal, event) {
2586
- if (isTerminal(signal)) {
2587
- this.activatePosition = null;
2588
- this.longPressTimer = clear(this.longPressTimer);
2589
- }
2590
- const isInitialTransition = prevState === "NOT_RESPONDER" && nextState === "RESPONDER_INACTIVE_PRESS_IN";
2591
- const isActivationTransition = !isActivation(prevState) && isActivation(nextState);
2592
- if (isInitialTransition || isActivationTransition) this.measureRegion();
2593
- if (isPressIn(prevState) && signal === "LONG_PRESS_DETECTED") this.config.onLongPress?.(event);
2594
- const isPrevActive = isActive(prevState);
2595
- const isNextActive = isActive(nextState);
2596
- if (!isPrevActive && isNextActive) this.activate(event);
2597
- else if (isPrevActive && !isNextActive) this.deactivate(event);
2598
- if (isPressIn(prevState) && signal === "RESPONDER_RELEASE") {
2599
- if (!isNextActive && !isPrevActive) {
2600
- this.activate(event);
2601
- this.deactivate(event);
2602
- }
2603
- const { onLongPress, onPress } = this.config;
2604
- if (onLongPress != null && prevState === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.cancelClick = true;
2605
- else if (onPress != null) {
2606
- onPress(event);
2607
- if (event.isDefaultPrevented()) this.cancelClick = true;
2608
- }
2609
- }
2610
- this.pressDelayTimer = clear(this.pressDelayTimer);
2611
- }
2612
- activate(event) {
2613
- const { pageX, pageY } = event.nativeEvent;
2614
- this.activatePosition = {
2615
- pageX,
2616
- 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);
2617
2836
  };
2618
- this.activateTime = Date.now();
2619
- this.config.onPressIn?.(event);
2620
- }
2621
- deactivate(event) {
2622
- const { onPressOut } = this.config;
2623
- if (onPressOut != null) {
2624
- const minPressDuration = normalizeDelay(this.config.minPressDuration, 0, DEFAULT_MIN_PRESS_DURATION);
2625
- const pressDuration = Date.now() - (this.activateTime ?? 0);
2626
- const delayPressOut = Math.max(minPressDuration - pressDuration, normalizeDelay(this.config.delayPressOut));
2627
- if (delayPressOut > 0) this.pressOutTimer = setTimeout(() => onPressOut(event), delayPressOut);
2628
- else onPressOut(event);
2629
- }
2630
- this.activateTime = null;
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;
2631
2933
  }
2632
- measureRegion() {
2633
- if (this.element === null) return;
2634
- const rect = this.element.getBoundingClientRect();
2635
- if (rect.width === 0 && rect.height === 0 && rect.top === 0 && rect.left === 0) return;
2636
- this.region = {
2637
- bottom: rect.bottom + window.scrollY,
2638
- left: rect.left + window.scrollX,
2639
- right: rect.right + window.scrollX,
2640
- top: rect.top + window.scrollY
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]
2641
2959
  };
2642
2960
  }
2643
- isWithinRegion(pageX, pageY, region) {
2644
- const hitSlop = normalizeRect(this.config.hitSlop);
2645
- const offset = normalizeRect(this.config.pressRectOffset);
2646
- const bottom = region.bottom + (hitSlop?.bottom ?? 0) + (offset?.bottom ?? DEFAULT_PRESS_RECT_OFFSETS.bottom);
2647
- const left = region.left - (hitSlop?.left ?? 0) - (offset?.left ?? DEFAULT_PRESS_RECT_OFFSETS.left);
2648
- const right = region.right + (hitSlop?.right ?? 0) + (offset?.right ?? DEFAULT_PRESS_RECT_OFFSETS.right);
2649
- const top = region.top - (hitSlop?.top ?? 0) - (offset?.top ?? DEFAULT_PRESS_RECT_OFFSETS.top);
2650
- return pageX > left && pageX < right && pageY > top && pageY < bottom;
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;
2651
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());
2652
3009
  };
2653
- // src/events/press/usePressability.ts
2654
- function usePressability(config) {
2655
- const [pressability, setPressability] = useState(() => config == null ? null : new Pressability(config));
2656
- if (pressability === null && config != null) setPressability(new Pressability(config));
2657
- useInsertionEffect(() => {
2658
- if (config != null && pressability !== null) pressability.configure(config);
2659
- }, [config, pressability]);
2660
- useInsertionEffect(() => {
2661
- if (pressability === null) return void 0;
2662
- return () => pressability.reset();
2663
- }, [pressability]);
2664
- 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);
2665
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
+ });
2666
3028
  // src/components/Pressable/index.tsx
2667
- const notCancelableStyle = Object.freeze({ touchAction: "none" });
2668
- const hitSlopClass = (registry, hitSlop) => {
2669
- if (hitSlop === void 0) return void 0;
2670
- const { top = 0, right = 0, bottom = 0, left = 0 } = typeof hitSlop === "number" ? {
2671
- top: hitSlop,
2672
- right: hitSlop,
2673
- bottom: hitSlop,
2674
- left: hitSlop
2675
- } : hitSlop;
2676
- if (top === 0 && right === 0 && bottom === 0 && left === 0) return void 0;
2677
- const name = `rn-hs-${[
2678
- top,
2679
- right,
2680
- bottom,
2681
- left
2682
- ].map((n) => String(n).replace(/[^0-9]/g, "_")).join("-")}`;
2683
- return registry.staticClass(name, [`.${name}::before{content:"";position:absolute;top:${-top}px;right:${-right}px;bottom:${-bottom}px;left:${-left}px;z-index:-1}`]);
2684
- };
3029
+ const notCancelableStyle$1 = Object.freeze({ touchAction: "none" });
2685
3030
  const isFocusVisible = (element) => {
2686
3031
  try {
2687
3032
  return element.matches(":focus-visible");
@@ -2689,31 +3034,6 @@ const isFocusVisible = (element) => {
2689
3034
  return true;
2690
3035
  }
2691
3036
  };
2692
- const sharedHandlers = [
2693
- "onClick",
2694
- "onContextMenu",
2695
- "onKeyDown",
2696
- "onKeyUp",
2697
- "onPointerCancel",
2698
- "onPointerDown",
2699
- "onPointerEnter",
2700
- "onPointerLeave",
2701
- "onPointerMove",
2702
- "onPointerUp"
2703
- ];
2704
- const mergeHandlers = (app, own) => {
2705
- const merged = { ...own };
2706
- for (const key of sharedHandlers) {
2707
- const first = app[key];
2708
- if (first === void 0) continue;
2709
- const second = own[key];
2710
- merged[key] = (event) => {
2711
- first(event);
2712
- second(event);
2713
- };
2714
- }
2715
- return merged;
2716
- };
2717
3037
  const Pressable = memo(function Pressable(props) {
2718
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;
2719
3039
  const [pressed, setPressed] = useState(false);
@@ -2790,7 +3110,7 @@ const Pressable = memo(function Pressable(props) {
2790
3110
  ...rest,
2791
3111
  ...mergeHandlers(rest, handlers),
2792
3112
  focusable: disabled !== true && focusable !== false,
2793
- style: [typeof style === "function" ? style(state) : style, cancelable === false && notCancelableStyle],
3113
+ style: [typeof style === "function" ? style(state) : style, cancelable === false && notCancelableStyle$1],
2794
3114
  children: typeof children === "function" ? children(state) : children
2795
3115
  };
2796
3116
  if (disabled === true) viewProps["aria-disabled"] = true;
@@ -2903,91 +3223,86 @@ const StatusBar = Object.assign(StatusBarComponent, {
2903
3223
  popStackEntry,
2904
3224
  replaceStackEntry
2905
3225
  });
2906
- // src/components/Text/TextAncestorContext.ts
2907
- const TextAncestorContext = createContext(false);
2908
- // src/components/Text/index.tsx
2909
- const resetStyle$1 = Object.freeze({
2910
- backgroundColor: "transparent",
2911
- border: "0 solid black",
2912
- boxSizing: "border-box",
2913
- color: "black",
2914
- display: "inline",
2915
- fontFamily: "System",
2916
- fontSize: 14,
2917
- listStyle: "none",
2918
- margin: 0,
2919
- padding: 0,
2920
- position: "relative",
2921
- textAlign: "start",
2922
- textDecoration: "none",
2923
- whiteSpace: "pre-wrap",
2924
- wordWrap: "break-word"
2925
- });
2926
- const nestedResetStyle = Object.freeze({
2927
- color: "inherit",
2928
- font: "inherit",
2929
- textAlign: "inherit",
2930
- textDecoration: "inherit",
2931
- whiteSpace: "inherit"
2932
- });
2933
- const singleLineStyle = Object.freeze({
2934
- overflow: "hidden",
2935
- textOverflow: "ellipsis",
2936
- whiteSpace: "nowrap"
2937
- });
2938
- const multiLineStyle = (lines) => ({
2939
- display: "-webkit-box",
2940
- WebkitBoxOrient: "vertical",
2941
- WebkitLineClamp: lines,
2942
- overflow: "hidden"
2943
- });
2944
- const selectionClass$1 = (registry, color) => {
2945
- const css = toCSSColor(color);
2946
- if (css === void 0) return void 0;
2947
- const name = `rn-sel-${css.replace(/[^a-z0-9]/g, "")}`;
2948
- return registry.staticClass(name, [`.${name}::selection{background-color:${css}}`]);
2949
- };
2950
- function Text(props) {
2951
- const { children, disabled, ellipsizeMode, numberOfLines, onClick, onLayout, onPress, pointerEvents, ref, selectable, selectionColor, style, ...rest } = props;
2952
- const nested = useContext(TextAncestorContext);
2953
- const element = useRef(null);
2954
- useImperativeHandle(ref, () => element.current, []);
2955
- useElementLayout(element, onLayout);
2956
- const registry = useStyleRegistry();
2957
- const { tag, role } = resolveTag(rest, "span", children != null);
2958
- const lineStyle = numberOfLines === void 0 || numberOfLines < 1 ? void 0 : numberOfLines === 1 ? singleLineStyle : multiLineStyle(numberOfLines);
2959
- let className = compileStyle([
2960
- nested ? nestedResetStyle : resetStyle$1,
2961
- style,
2962
- lineStyle,
2963
- ellipsizeMode === "clip" ? { textOverflow: "clip" } : void 0,
2964
- selectable === false ? { userSelect: "none" } : void 0,
2965
- pointerEvents === "none" || pointerEvents === "auto" ? { pointerEvents } : void 0
2966
- ], registry);
2967
- if (selectionColor !== void 0) {
2968
- const extra = selectionClass$1(registry, selectionColor);
2969
- if (extra !== void 0) className = `${className} ${extra}`;
2970
- }
2971
- const handleClick = useCallback((event) => {
2972
- onClick?.(event);
2973
- if (disabled === true || event.defaultPrevented) return;
2974
- onPress?.(event);
2975
- }, [
2976
- disabled,
2977
- onClick,
2978
- onPress
2979
- ]);
2980
- const domProps = toDOMProps(rest);
2981
- if (role !== void 0) domProps["role"] = role;
2982
- if (tag.length === 2 && tag[0] === "h") delete domProps["aria-level"];
2983
- if (tag === "button") domProps["type"] = "button";
2984
- if (disabled === true) domProps["aria-disabled"] = true;
2985
- if (onPress !== void 0 || onClick !== void 0) domProps["onClick"] = handleClick;
2986
- domProps["className"] = className;
2987
- domProps["ref"] = element;
2988
- const content = nested ? children : createElement(TextAncestorContext.Provider, { value: true }, children);
2989
- 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
+ });
2990
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
+ });
2991
3306
  // src/components/TextInput/autocomplete.ts
2992
3307
  const reactNativeToHTML = {
2993
3308
  "address-line1": "address-line1",
@@ -3370,6 +3685,188 @@ const TextInput = Object.assign(TextInputComponent, { State: {
3370
3685
  focusTextInput: (input) => input?.focus(),
3371
3686
  blurTextInput: (input) => input?.blur()
3372
3687
  } });
3373
- export { AccessibilityInfo, Appearance, BackHandler, Dimensions, FlatList, I18nManager, Image, PanResponder, PixelRatio, Platform, Pressable, ScrollView, StatusBar, StyleSheet, Text, TextAncestorContext, TextInput, View, processColor, useColorScheme, usePressability, useWindowDimensions };
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 };
3374
3871
 
3375
3872
  //# sourceMappingURL=index.js.map