@legendapp/list 2.0.0-next.9 → 2.1.0-next.0
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/.DS_Store +0 -0
- package/animated.d.mts +3 -65
- package/animated.d.ts +3 -65
- package/index.d.mts +123 -339
- package/index.d.ts +123 -339
- package/index.js +1905 -729
- package/index.mjs +1893 -717
- package/keyboard-controller.d.mts +7 -260
- package/keyboard-controller.d.ts +7 -260
- package/package.json +1 -1
- package/reanimated.d.mts +1 -1
- package/reanimated.d.ts +1 -1
- package/reanimated.js +19 -17
- package/reanimated.mjs +20 -18
package/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var React3 = require('react');
|
|
4
|
-
var reactNative = require('react-native');
|
|
5
4
|
var shim = require('use-sync-external-store/shim');
|
|
6
5
|
|
|
7
6
|
function _interopNamespace(e) {
|
|
@@ -24,15 +23,476 @@ function _interopNamespace(e) {
|
|
|
24
23
|
|
|
25
24
|
var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
var __create = Object.create;
|
|
27
|
+
var __defProp = Object.defineProperty;
|
|
28
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
29
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
30
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
31
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
32
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
33
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
34
|
+
}) : x)(function(x) {
|
|
35
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
36
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
37
|
+
});
|
|
38
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
39
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
!mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
|
|
58
|
+
// node_modules/react-dom/cjs/react-dom.production.js
|
|
59
|
+
var require_react_dom_production = __commonJS({
|
|
60
|
+
"node_modules/react-dom/cjs/react-dom.production.js"(exports) {
|
|
61
|
+
var React12 = __require("react");
|
|
62
|
+
function formatProdErrorMessage(code) {
|
|
63
|
+
var url = "https://react.dev/errors/" + code;
|
|
64
|
+
if (1 < arguments.length) {
|
|
65
|
+
url += "?args[]=" + encodeURIComponent(arguments[1]);
|
|
66
|
+
for (var i = 2; i < arguments.length; i++)
|
|
67
|
+
url += "&args[]=" + encodeURIComponent(arguments[i]);
|
|
68
|
+
}
|
|
69
|
+
return "Minified React error #" + code + "; visit " + url + " for the full message or use the non-minified dev environment for full errors and additional helpful warnings.";
|
|
70
|
+
}
|
|
71
|
+
function noop2() {
|
|
72
|
+
}
|
|
73
|
+
var Internals = {
|
|
74
|
+
d: {
|
|
75
|
+
f: noop2,
|
|
76
|
+
r: function() {
|
|
77
|
+
throw Error(formatProdErrorMessage(522));
|
|
78
|
+
},
|
|
79
|
+
D: noop2,
|
|
80
|
+
C: noop2,
|
|
81
|
+
L: noop2,
|
|
82
|
+
m: noop2,
|
|
83
|
+
X: noop2,
|
|
84
|
+
S: noop2,
|
|
85
|
+
M: noop2
|
|
86
|
+
},
|
|
87
|
+
p: 0,
|
|
88
|
+
findDOMNode: null
|
|
89
|
+
};
|
|
90
|
+
var REACT_PORTAL_TYPE = Symbol.for("react.portal");
|
|
91
|
+
function createPortal$1(children, containerInfo, implementation) {
|
|
92
|
+
var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
|
|
93
|
+
return {
|
|
94
|
+
$$typeof: REACT_PORTAL_TYPE,
|
|
95
|
+
key: null == key ? null : "" + key,
|
|
96
|
+
children,
|
|
97
|
+
containerInfo,
|
|
98
|
+
implementation
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
var ReactSharedInternals = React12.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
102
|
+
function getCrossOriginStringAs(as, input) {
|
|
103
|
+
if ("font" === as) return "";
|
|
104
|
+
if ("string" === typeof input)
|
|
105
|
+
return "use-credentials" === input ? input : "";
|
|
106
|
+
}
|
|
107
|
+
exports.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = Internals;
|
|
108
|
+
exports.createPortal = function(children, container) {
|
|
109
|
+
var key = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : null;
|
|
110
|
+
if (!container || 1 !== container.nodeType && 9 !== container.nodeType && 11 !== container.nodeType)
|
|
111
|
+
throw Error(formatProdErrorMessage(299));
|
|
112
|
+
return createPortal$1(children, container, null, key);
|
|
113
|
+
};
|
|
114
|
+
exports.flushSync = function(fn) {
|
|
115
|
+
var previousTransition = ReactSharedInternals.T, previousUpdatePriority = Internals.p;
|
|
116
|
+
try {
|
|
117
|
+
if (ReactSharedInternals.T = null, Internals.p = 2, fn) return fn();
|
|
118
|
+
} finally {
|
|
119
|
+
ReactSharedInternals.T = previousTransition, Internals.p = previousUpdatePriority, Internals.d.f();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
exports.preconnect = function(href, options) {
|
|
123
|
+
"string" === typeof href && (options ? (options = options.crossOrigin, options = "string" === typeof options ? "use-credentials" === options ? options : "" : void 0) : options = null, Internals.d.C(href, options));
|
|
124
|
+
};
|
|
125
|
+
exports.prefetchDNS = function(href) {
|
|
126
|
+
"string" === typeof href && Internals.d.D(href);
|
|
127
|
+
};
|
|
128
|
+
exports.preinit = function(href, options) {
|
|
129
|
+
if ("string" === typeof href && options && "string" === typeof options.as) {
|
|
130
|
+
var as = options.as, crossOrigin = getCrossOriginStringAs(as, options.crossOrigin), integrity = "string" === typeof options.integrity ? options.integrity : void 0, fetchPriority = "string" === typeof options.fetchPriority ? options.fetchPriority : void 0;
|
|
131
|
+
"style" === as ? Internals.d.S(
|
|
132
|
+
href,
|
|
133
|
+
"string" === typeof options.precedence ? options.precedence : void 0,
|
|
134
|
+
{
|
|
135
|
+
crossOrigin,
|
|
136
|
+
integrity,
|
|
137
|
+
fetchPriority
|
|
138
|
+
}
|
|
139
|
+
) : "script" === as && Internals.d.X(href, {
|
|
140
|
+
crossOrigin,
|
|
141
|
+
integrity,
|
|
142
|
+
fetchPriority,
|
|
143
|
+
nonce: "string" === typeof options.nonce ? options.nonce : void 0
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
exports.preinitModule = function(href, options) {
|
|
148
|
+
if ("string" === typeof href)
|
|
149
|
+
if ("object" === typeof options && null !== options) {
|
|
150
|
+
if (null == options.as || "script" === options.as) {
|
|
151
|
+
var crossOrigin = getCrossOriginStringAs(
|
|
152
|
+
options.as,
|
|
153
|
+
options.crossOrigin
|
|
154
|
+
);
|
|
155
|
+
Internals.d.M(href, {
|
|
156
|
+
crossOrigin,
|
|
157
|
+
integrity: "string" === typeof options.integrity ? options.integrity : void 0,
|
|
158
|
+
nonce: "string" === typeof options.nonce ? options.nonce : void 0
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
} else null == options && Internals.d.M(href);
|
|
162
|
+
};
|
|
163
|
+
exports.preload = function(href, options) {
|
|
164
|
+
if ("string" === typeof href && "object" === typeof options && null !== options && "string" === typeof options.as) {
|
|
165
|
+
var as = options.as, crossOrigin = getCrossOriginStringAs(as, options.crossOrigin);
|
|
166
|
+
Internals.d.L(href, as, {
|
|
167
|
+
crossOrigin,
|
|
168
|
+
integrity: "string" === typeof options.integrity ? options.integrity : void 0,
|
|
169
|
+
nonce: "string" === typeof options.nonce ? options.nonce : void 0,
|
|
170
|
+
type: "string" === typeof options.type ? options.type : void 0,
|
|
171
|
+
fetchPriority: "string" === typeof options.fetchPriority ? options.fetchPriority : void 0,
|
|
172
|
+
referrerPolicy: "string" === typeof options.referrerPolicy ? options.referrerPolicy : void 0,
|
|
173
|
+
imageSrcSet: "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0,
|
|
174
|
+
imageSizes: "string" === typeof options.imageSizes ? options.imageSizes : void 0,
|
|
175
|
+
media: "string" === typeof options.media ? options.media : void 0
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
exports.preloadModule = function(href, options) {
|
|
180
|
+
if ("string" === typeof href)
|
|
181
|
+
if (options) {
|
|
182
|
+
var crossOrigin = getCrossOriginStringAs(options.as, options.crossOrigin);
|
|
183
|
+
Internals.d.m(href, {
|
|
184
|
+
as: "string" === typeof options.as && "script" !== options.as ? options.as : void 0,
|
|
185
|
+
crossOrigin,
|
|
186
|
+
integrity: "string" === typeof options.integrity ? options.integrity : void 0
|
|
187
|
+
});
|
|
188
|
+
} else Internals.d.m(href);
|
|
189
|
+
};
|
|
190
|
+
exports.requestFormReset = function(form) {
|
|
191
|
+
Internals.d.r(form);
|
|
192
|
+
};
|
|
193
|
+
exports.unstable_batchedUpdates = function(fn, a) {
|
|
194
|
+
return fn(a);
|
|
195
|
+
};
|
|
196
|
+
exports.useFormState = function(action, initialState, permalink) {
|
|
197
|
+
return ReactSharedInternals.H.useFormState(action, initialState, permalink);
|
|
198
|
+
};
|
|
199
|
+
exports.useFormStatus = function() {
|
|
200
|
+
return ReactSharedInternals.H.useHostTransitionStatus();
|
|
201
|
+
};
|
|
202
|
+
exports.version = "19.1.1";
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
// node_modules/react-dom/cjs/react-dom.development.js
|
|
207
|
+
var require_react_dom_development = __commonJS({
|
|
208
|
+
"node_modules/react-dom/cjs/react-dom.development.js"(exports) {
|
|
209
|
+
"production" !== process.env.NODE_ENV && function() {
|
|
210
|
+
function noop2() {
|
|
211
|
+
}
|
|
212
|
+
function testStringCoercion(value) {
|
|
213
|
+
return "" + value;
|
|
214
|
+
}
|
|
215
|
+
function createPortal$1(children, containerInfo, implementation) {
|
|
216
|
+
var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
|
|
217
|
+
try {
|
|
218
|
+
testStringCoercion(key);
|
|
219
|
+
var JSCompiler_inline_result = false;
|
|
220
|
+
} catch (e) {
|
|
221
|
+
JSCompiler_inline_result = true;
|
|
222
|
+
}
|
|
223
|
+
JSCompiler_inline_result && (console.error(
|
|
224
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
225
|
+
"function" === typeof Symbol && Symbol.toStringTag && key[Symbol.toStringTag] || key.constructor.name || "Object"
|
|
226
|
+
), testStringCoercion(key));
|
|
227
|
+
return {
|
|
228
|
+
$$typeof: REACT_PORTAL_TYPE,
|
|
229
|
+
key: null == key ? null : "" + key,
|
|
230
|
+
children,
|
|
231
|
+
containerInfo,
|
|
232
|
+
implementation
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function getCrossOriginStringAs(as, input) {
|
|
236
|
+
if ("font" === as) return "";
|
|
237
|
+
if ("string" === typeof input)
|
|
238
|
+
return "use-credentials" === input ? input : "";
|
|
239
|
+
}
|
|
240
|
+
function getValueDescriptorExpectingObjectForWarning(thing) {
|
|
241
|
+
return null === thing ? "`null`" : void 0 === thing ? "`undefined`" : "" === thing ? "an empty string" : 'something with type "' + typeof thing + '"';
|
|
242
|
+
}
|
|
243
|
+
function getValueDescriptorExpectingEnumForWarning(thing) {
|
|
244
|
+
return null === thing ? "`null`" : void 0 === thing ? "`undefined`" : "" === thing ? "an empty string" : "string" === typeof thing ? JSON.stringify(thing) : "number" === typeof thing ? "`" + thing + "`" : 'something with type "' + typeof thing + '"';
|
|
245
|
+
}
|
|
246
|
+
function resolveDispatcher() {
|
|
247
|
+
var dispatcher = ReactSharedInternals.H;
|
|
248
|
+
null === dispatcher && console.error(
|
|
249
|
+
"Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
|
|
250
|
+
);
|
|
251
|
+
return dispatcher;
|
|
252
|
+
}
|
|
253
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
254
|
+
var React12 = __require("react"), Internals = {
|
|
255
|
+
d: {
|
|
256
|
+
f: noop2,
|
|
257
|
+
r: function() {
|
|
258
|
+
throw Error(
|
|
259
|
+
"Invalid form element. requestFormReset must be passed a form that was rendered by React."
|
|
260
|
+
);
|
|
261
|
+
},
|
|
262
|
+
D: noop2,
|
|
263
|
+
C: noop2,
|
|
264
|
+
L: noop2,
|
|
265
|
+
m: noop2,
|
|
266
|
+
X: noop2,
|
|
267
|
+
S: noop2,
|
|
268
|
+
M: noop2
|
|
269
|
+
},
|
|
270
|
+
p: 0,
|
|
271
|
+
findDOMNode: null
|
|
272
|
+
}, REACT_PORTAL_TYPE = Symbol.for("react.portal"), ReactSharedInternals = React12.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
|
273
|
+
"function" === typeof Map && null != Map.prototype && "function" === typeof Map.prototype.forEach && "function" === typeof Set && null != Set.prototype && "function" === typeof Set.prototype.clear && "function" === typeof Set.prototype.forEach || console.error(
|
|
274
|
+
"React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"
|
|
275
|
+
);
|
|
276
|
+
exports.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = Internals;
|
|
277
|
+
exports.createPortal = function(children, container) {
|
|
278
|
+
var key = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : null;
|
|
279
|
+
if (!container || 1 !== container.nodeType && 9 !== container.nodeType && 11 !== container.nodeType)
|
|
280
|
+
throw Error("Target container is not a DOM element.");
|
|
281
|
+
return createPortal$1(children, container, null, key);
|
|
282
|
+
};
|
|
283
|
+
exports.flushSync = function(fn) {
|
|
284
|
+
var previousTransition = ReactSharedInternals.T, previousUpdatePriority = Internals.p;
|
|
285
|
+
try {
|
|
286
|
+
if (ReactSharedInternals.T = null, Internals.p = 2, fn)
|
|
287
|
+
return fn();
|
|
288
|
+
} finally {
|
|
289
|
+
ReactSharedInternals.T = previousTransition, Internals.p = previousUpdatePriority, Internals.d.f() && console.error(
|
|
290
|
+
"flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task."
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
exports.preconnect = function(href, options) {
|
|
295
|
+
"string" === typeof href && href ? null != options && "object" !== typeof options ? console.error(
|
|
296
|
+
"ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.",
|
|
297
|
+
getValueDescriptorExpectingEnumForWarning(options)
|
|
298
|
+
) : null != options && "string" !== typeof options.crossOrigin && console.error(
|
|
299
|
+
"ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.",
|
|
300
|
+
getValueDescriptorExpectingObjectForWarning(options.crossOrigin)
|
|
301
|
+
) : console.error(
|
|
302
|
+
"ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
|
|
303
|
+
getValueDescriptorExpectingObjectForWarning(href)
|
|
304
|
+
);
|
|
305
|
+
"string" === typeof href && (options ? (options = options.crossOrigin, options = "string" === typeof options ? "use-credentials" === options ? options : "" : void 0) : options = null, Internals.d.C(href, options));
|
|
306
|
+
};
|
|
307
|
+
exports.prefetchDNS = function(href) {
|
|
308
|
+
if ("string" !== typeof href || !href)
|
|
309
|
+
console.error(
|
|
310
|
+
"ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
|
|
311
|
+
getValueDescriptorExpectingObjectForWarning(href)
|
|
312
|
+
);
|
|
313
|
+
else if (1 < arguments.length) {
|
|
314
|
+
var options = arguments[1];
|
|
315
|
+
"object" === typeof options && options.hasOwnProperty("crossOrigin") ? console.error(
|
|
316
|
+
"ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
|
|
317
|
+
getValueDescriptorExpectingEnumForWarning(options)
|
|
318
|
+
) : console.error(
|
|
319
|
+
"ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
|
|
320
|
+
getValueDescriptorExpectingEnumForWarning(options)
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
"string" === typeof href && Internals.d.D(href);
|
|
324
|
+
};
|
|
325
|
+
exports.preinit = function(href, options) {
|
|
326
|
+
"string" === typeof href && href ? null == options || "object" !== typeof options ? console.error(
|
|
327
|
+
"ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.",
|
|
328
|
+
getValueDescriptorExpectingEnumForWarning(options)
|
|
329
|
+
) : "style" !== options.as && "script" !== options.as && console.error(
|
|
330
|
+
'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".',
|
|
331
|
+
getValueDescriptorExpectingEnumForWarning(options.as)
|
|
332
|
+
) : console.error(
|
|
333
|
+
"ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
|
|
334
|
+
getValueDescriptorExpectingObjectForWarning(href)
|
|
335
|
+
);
|
|
336
|
+
if ("string" === typeof href && options && "string" === typeof options.as) {
|
|
337
|
+
var as = options.as, crossOrigin = getCrossOriginStringAs(as, options.crossOrigin), integrity = "string" === typeof options.integrity ? options.integrity : void 0, fetchPriority = "string" === typeof options.fetchPriority ? options.fetchPriority : void 0;
|
|
338
|
+
"style" === as ? Internals.d.S(
|
|
339
|
+
href,
|
|
340
|
+
"string" === typeof options.precedence ? options.precedence : void 0,
|
|
341
|
+
{
|
|
342
|
+
crossOrigin,
|
|
343
|
+
integrity,
|
|
344
|
+
fetchPriority
|
|
345
|
+
}
|
|
346
|
+
) : "script" === as && Internals.d.X(href, {
|
|
347
|
+
crossOrigin,
|
|
348
|
+
integrity,
|
|
349
|
+
fetchPriority,
|
|
350
|
+
nonce: "string" === typeof options.nonce ? options.nonce : void 0
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
exports.preinitModule = function(href, options) {
|
|
355
|
+
var encountered = "";
|
|
356
|
+
"string" === typeof href && href || (encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".");
|
|
357
|
+
void 0 !== options && "object" !== typeof options ? encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + "." : options && "as" in options && "script" !== options.as && (encountered += " The `as` option encountered was " + getValueDescriptorExpectingEnumForWarning(options.as) + ".");
|
|
358
|
+
if (encountered)
|
|
359
|
+
console.error(
|
|
360
|
+
"ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s",
|
|
361
|
+
encountered
|
|
362
|
+
);
|
|
363
|
+
else
|
|
364
|
+
switch (encountered = options && "string" === typeof options.as ? options.as : "script", encountered) {
|
|
365
|
+
case "script":
|
|
366
|
+
break;
|
|
367
|
+
default:
|
|
368
|
+
encountered = getValueDescriptorExpectingEnumForWarning(encountered), console.error(
|
|
369
|
+
'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script" but received "%s" instead. This warning was generated for `href` "%s". In the future other module types will be supported, aligning with the import-attributes proposal. Learn more here: (https://github.com/tc39/proposal-import-attributes)',
|
|
370
|
+
encountered,
|
|
371
|
+
href
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
if ("string" === typeof href)
|
|
375
|
+
if ("object" === typeof options && null !== options) {
|
|
376
|
+
if (null == options.as || "script" === options.as)
|
|
377
|
+
encountered = getCrossOriginStringAs(
|
|
378
|
+
options.as,
|
|
379
|
+
options.crossOrigin
|
|
380
|
+
), Internals.d.M(href, {
|
|
381
|
+
crossOrigin: encountered,
|
|
382
|
+
integrity: "string" === typeof options.integrity ? options.integrity : void 0,
|
|
383
|
+
nonce: "string" === typeof options.nonce ? options.nonce : void 0
|
|
384
|
+
});
|
|
385
|
+
} else null == options && Internals.d.M(href);
|
|
386
|
+
};
|
|
387
|
+
exports.preload = function(href, options) {
|
|
388
|
+
var encountered = "";
|
|
389
|
+
"string" === typeof href && href || (encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".");
|
|
390
|
+
null == options || "object" !== typeof options ? encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + "." : "string" === typeof options.as && options.as || (encountered += " The `as` option encountered was " + getValueDescriptorExpectingObjectForWarning(options.as) + ".");
|
|
391
|
+
encountered && console.error(
|
|
392
|
+
'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `<link rel="preload" as="..." />` tag.%s',
|
|
393
|
+
encountered
|
|
394
|
+
);
|
|
395
|
+
if ("string" === typeof href && "object" === typeof options && null !== options && "string" === typeof options.as) {
|
|
396
|
+
encountered = options.as;
|
|
397
|
+
var crossOrigin = getCrossOriginStringAs(
|
|
398
|
+
encountered,
|
|
399
|
+
options.crossOrigin
|
|
400
|
+
);
|
|
401
|
+
Internals.d.L(href, encountered, {
|
|
402
|
+
crossOrigin,
|
|
403
|
+
integrity: "string" === typeof options.integrity ? options.integrity : void 0,
|
|
404
|
+
nonce: "string" === typeof options.nonce ? options.nonce : void 0,
|
|
405
|
+
type: "string" === typeof options.type ? options.type : void 0,
|
|
406
|
+
fetchPriority: "string" === typeof options.fetchPriority ? options.fetchPriority : void 0,
|
|
407
|
+
referrerPolicy: "string" === typeof options.referrerPolicy ? options.referrerPolicy : void 0,
|
|
408
|
+
imageSrcSet: "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0,
|
|
409
|
+
imageSizes: "string" === typeof options.imageSizes ? options.imageSizes : void 0,
|
|
410
|
+
media: "string" === typeof options.media ? options.media : void 0
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
exports.preloadModule = function(href, options) {
|
|
415
|
+
var encountered = "";
|
|
416
|
+
"string" === typeof href && href || (encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".");
|
|
417
|
+
void 0 !== options && "object" !== typeof options ? encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + "." : options && "as" in options && "string" !== typeof options.as && (encountered += " The `as` option encountered was " + getValueDescriptorExpectingObjectForWarning(options.as) + ".");
|
|
418
|
+
encountered && console.error(
|
|
419
|
+
'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `<link rel="modulepreload" as="..." />` tag.%s',
|
|
420
|
+
encountered
|
|
421
|
+
);
|
|
422
|
+
"string" === typeof href && (options ? (encountered = getCrossOriginStringAs(
|
|
423
|
+
options.as,
|
|
424
|
+
options.crossOrigin
|
|
425
|
+
), Internals.d.m(href, {
|
|
426
|
+
as: "string" === typeof options.as && "script" !== options.as ? options.as : void 0,
|
|
427
|
+
crossOrigin: encountered,
|
|
428
|
+
integrity: "string" === typeof options.integrity ? options.integrity : void 0
|
|
429
|
+
})) : Internals.d.m(href));
|
|
430
|
+
};
|
|
431
|
+
exports.requestFormReset = function(form) {
|
|
432
|
+
Internals.d.r(form);
|
|
433
|
+
};
|
|
434
|
+
exports.unstable_batchedUpdates = function(fn, a) {
|
|
435
|
+
return fn(a);
|
|
436
|
+
};
|
|
437
|
+
exports.useFormState = function(action, initialState, permalink) {
|
|
438
|
+
return resolveDispatcher().useFormState(action, initialState, permalink);
|
|
439
|
+
};
|
|
440
|
+
exports.useFormStatus = function() {
|
|
441
|
+
return resolveDispatcher().useHostTransitionStatus();
|
|
442
|
+
};
|
|
443
|
+
exports.version = "19.1.1";
|
|
444
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
445
|
+
}();
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
// node_modules/react-dom/index.js
|
|
450
|
+
var require_react_dom = __commonJS({
|
|
451
|
+
"node_modules/react-dom/index.js"(exports, module) {
|
|
452
|
+
function checkDCE() {
|
|
453
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined" || typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== "function") {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
if (process.env.NODE_ENV !== "production") {
|
|
457
|
+
throw new Error("^_^");
|
|
458
|
+
}
|
|
459
|
+
try {
|
|
460
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);
|
|
461
|
+
} catch (err) {
|
|
462
|
+
console.error(err);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (process.env.NODE_ENV === "production") {
|
|
466
|
+
checkDCE();
|
|
467
|
+
module.exports = require_react_dom_production();
|
|
468
|
+
} else {
|
|
469
|
+
module.exports = require_react_dom_development();
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
var AnimatedView = React3.forwardRef(function AnimatedView2(props, ref) {
|
|
474
|
+
return /* @__PURE__ */ React.createElement("div", { ref, ...props });
|
|
475
|
+
});
|
|
476
|
+
var View = React3.forwardRef(function View2(props, ref) {
|
|
477
|
+
return /* @__PURE__ */ React.createElement("div", { ref, ...props });
|
|
478
|
+
});
|
|
479
|
+
var Text = View;
|
|
480
|
+
|
|
481
|
+
// src/platform/Animated.tsx
|
|
482
|
+
var createAnimatedValue = (value) => value;
|
|
483
|
+
|
|
484
|
+
// src/state/state.tsx
|
|
28
485
|
var ContextState = React3__namespace.createContext(null);
|
|
29
486
|
function StateProvider({ children }) {
|
|
30
487
|
const [value] = React3__namespace.useState(() => ({
|
|
488
|
+
animatedScrollY: createAnimatedValue(0),
|
|
31
489
|
columnWrapperStyle: void 0,
|
|
490
|
+
internalState: void 0,
|
|
32
491
|
listeners: /* @__PURE__ */ new Map(),
|
|
33
492
|
mapViewabilityAmountCallbacks: /* @__PURE__ */ new Map(),
|
|
34
493
|
mapViewabilityAmountValues: /* @__PURE__ */ new Map(),
|
|
35
494
|
mapViewabilityCallbacks: /* @__PURE__ */ new Map(),
|
|
495
|
+
mapViewabilityConfigStates: /* @__PURE__ */ new Map(),
|
|
36
496
|
mapViewabilityValues: /* @__PURE__ */ new Map(),
|
|
37
497
|
values: /* @__PURE__ */ new Map([
|
|
38
498
|
["alignItemsPaddingTop", 0],
|
|
@@ -130,7 +590,7 @@ function useSelector$(signalName, selector) {
|
|
|
130
590
|
|
|
131
591
|
// src/components/DebugView.tsx
|
|
132
592
|
var DebugRow = ({ children }) => {
|
|
133
|
-
return /* @__PURE__ */ React3__namespace.createElement(
|
|
593
|
+
return /* @__PURE__ */ React3__namespace.createElement(View, { style: { alignItems: "center", flexDirection: "row", justifyContent: "space-between" } }, children);
|
|
134
594
|
};
|
|
135
595
|
var DebugView = React3__namespace.memo(function DebugView2({ state }) {
|
|
136
596
|
const ctx = useStateContext();
|
|
@@ -148,7 +608,7 @@ var DebugView = React3__namespace.memo(function DebugView2({ state }) {
|
|
|
148
608
|
forceUpdate();
|
|
149
609
|
}, 100);
|
|
150
610
|
return /* @__PURE__ */ React3__namespace.createElement(
|
|
151
|
-
|
|
611
|
+
View,
|
|
152
612
|
{
|
|
153
613
|
pointerEvents: "none",
|
|
154
614
|
style: {
|
|
@@ -163,14 +623,12 @@ var DebugView = React3__namespace.memo(function DebugView2({ state }) {
|
|
|
163
623
|
top: 0
|
|
164
624
|
}
|
|
165
625
|
},
|
|
166
|
-
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
167
|
-
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
168
|
-
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
169
|
-
/* @__PURE__ */ React3__namespace.createElement(
|
|
170
|
-
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
171
|
-
/* @__PURE__ */ React3__namespace.createElement(
|
|
172
|
-
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "RawScroll: "), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, rawScroll.toFixed(2))),
|
|
173
|
-
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, "ComputedScroll: "), /* @__PURE__ */ React3__namespace.createElement(reactNative.Text, null, scroll.toFixed(2)))
|
|
626
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "TotalSize:"), /* @__PURE__ */ React3__namespace.createElement(Text, null, totalSize.toFixed(2))),
|
|
627
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "ContentSize:"), /* @__PURE__ */ React3__namespace.createElement(Text, null, contentSize.toFixed(2))),
|
|
628
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "At end:"), /* @__PURE__ */ React3__namespace.createElement(Text, null, String(state.isAtEnd))),
|
|
629
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "ScrollAdjust:"), /* @__PURE__ */ React3__namespace.createElement(Text, null, scrollAdjust.toFixed(2))),
|
|
630
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "RawScroll: "), /* @__PURE__ */ React3__namespace.createElement(Text, null, rawScroll.toFixed(2))),
|
|
631
|
+
/* @__PURE__ */ React3__namespace.createElement(DebugRow, null, /* @__PURE__ */ React3__namespace.createElement(Text, null, "ComputedScroll: "), /* @__PURE__ */ React3__namespace.createElement(Text, null, scroll.toFixed(2)))
|
|
174
632
|
);
|
|
175
633
|
});
|
|
176
634
|
function useInterval(callback, delay) {
|
|
@@ -179,24 +637,141 @@ function useInterval(callback, delay) {
|
|
|
179
637
|
return () => clearInterval(interval);
|
|
180
638
|
}, [delay]);
|
|
181
639
|
}
|
|
182
|
-
var
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
640
|
+
var globalResizeObserver = null;
|
|
641
|
+
function getGlobalResizeObserver() {
|
|
642
|
+
if (!globalResizeObserver) {
|
|
643
|
+
globalResizeObserver = new ResizeObserver((entries) => {
|
|
644
|
+
for (const entry of entries) {
|
|
645
|
+
const callbacks = callbackMap.get(entry.target);
|
|
646
|
+
if (callbacks) {
|
|
647
|
+
for (const callback of callbacks) {
|
|
648
|
+
callback(entry);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
return globalResizeObserver;
|
|
655
|
+
}
|
|
656
|
+
var callbackMap = /* @__PURE__ */ new WeakMap();
|
|
657
|
+
function useResizeObserver(element, callback) {
|
|
658
|
+
React3.useEffect(() => {
|
|
659
|
+
if (!element) return;
|
|
660
|
+
const observer = getGlobalResizeObserver();
|
|
661
|
+
let callbacks = callbackMap.get(element);
|
|
662
|
+
if (!callbacks) {
|
|
663
|
+
callbacks = /* @__PURE__ */ new Set();
|
|
664
|
+
callbackMap.set(element, callbacks);
|
|
665
|
+
observer.observe(element);
|
|
666
|
+
}
|
|
667
|
+
callbacks.add(callback);
|
|
668
|
+
return () => {
|
|
669
|
+
const callbacks2 = callbackMap.get(element);
|
|
670
|
+
if (callbacks2) {
|
|
671
|
+
callbacks2.delete(callback);
|
|
672
|
+
if (callbacks2.size === 0) {
|
|
673
|
+
callbackMap.delete(element);
|
|
674
|
+
observer.unobserve(element);
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
}, [element, callback]);
|
|
679
|
+
}
|
|
187
680
|
|
|
188
|
-
// src/
|
|
189
|
-
function
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
681
|
+
// src/hooks/useSyncLayout.tsx
|
|
682
|
+
function useSyncLayout({
|
|
683
|
+
ref,
|
|
684
|
+
onLayoutChange
|
|
685
|
+
}) {
|
|
686
|
+
var _a, _b;
|
|
687
|
+
useResizeObserver(
|
|
688
|
+
((_b = (_a = ref.current) == null ? void 0 : _a.getScrollableNode) == null ? void 0 : _b.call(_a)) || ref.current,
|
|
689
|
+
React3.useCallback(
|
|
690
|
+
(entry) => {
|
|
691
|
+
onLayoutChange(entry.contentRect, false);
|
|
692
|
+
},
|
|
693
|
+
[onLayoutChange]
|
|
694
|
+
)
|
|
695
|
+
);
|
|
696
|
+
React3.useLayoutEffect(() => {
|
|
697
|
+
if (ref.current) {
|
|
698
|
+
const rect = ref.current.getBoundingClientRect();
|
|
699
|
+
onLayoutChange(
|
|
700
|
+
{
|
|
701
|
+
height: rect.height,
|
|
702
|
+
width: rect.width,
|
|
703
|
+
x: rect.left,
|
|
704
|
+
y: rect.top
|
|
705
|
+
},
|
|
706
|
+
true
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
}, []);
|
|
710
|
+
return {};
|
|
193
711
|
}
|
|
194
712
|
|
|
713
|
+
// src/components/LayoutView.tsx
|
|
714
|
+
var LayoutView = ({ onLayoutChange, refView, children, ...rest }) => {
|
|
715
|
+
const ref = refView != null ? refView : React3.useRef();
|
|
716
|
+
useSyncLayout({ onLayoutChange, ref });
|
|
717
|
+
return /* @__PURE__ */ React.createElement("div", { ...rest, ref }, children);
|
|
718
|
+
};
|
|
719
|
+
|
|
195
720
|
// src/constants.ts
|
|
196
721
|
var POSITION_OUT_OF_VIEW = -1e7;
|
|
197
722
|
var ENABLE_DEVMODE = __DEV__ && false;
|
|
198
723
|
var ENABLE_DEBUG_VIEW = __DEV__ && false;
|
|
199
|
-
var
|
|
724
|
+
var typedForwardRef = React3.forwardRef;
|
|
725
|
+
var typedMemo = React3.memo;
|
|
726
|
+
|
|
727
|
+
// src/components/PositionView.tsx
|
|
728
|
+
var PositionViewState = typedMemo(function PositionView({
|
|
729
|
+
id,
|
|
730
|
+
horizontal,
|
|
731
|
+
style,
|
|
732
|
+
refView,
|
|
733
|
+
...rest
|
|
734
|
+
}) {
|
|
735
|
+
const [position = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
|
|
736
|
+
const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
|
|
737
|
+
const combinedStyle = horizontal ? { ...base, left: position } : { ...base, top: position };
|
|
738
|
+
return /* @__PURE__ */ React3__namespace.createElement(LayoutView, { refView, style: combinedStyle, ...rest });
|
|
739
|
+
});
|
|
740
|
+
var PositionViewSticky = typedMemo(function PositionViewSticky2({
|
|
741
|
+
id,
|
|
742
|
+
horizontal,
|
|
743
|
+
style,
|
|
744
|
+
refView,
|
|
745
|
+
index,
|
|
746
|
+
...rest
|
|
747
|
+
}) {
|
|
748
|
+
const [position = POSITION_OUT_OF_VIEW] = useArr$([`containerPosition${id}`]);
|
|
749
|
+
const viewStyle = React3__namespace.useMemo(() => {
|
|
750
|
+
const base = Array.isArray(style) ? Object.assign({}, ...style) : style;
|
|
751
|
+
const axisStyle = horizontal ? { transform: `translateX(${position}px)` } : { top: position };
|
|
752
|
+
return {
|
|
753
|
+
...base,
|
|
754
|
+
zIndex: index + 1e3,
|
|
755
|
+
...axisStyle
|
|
756
|
+
};
|
|
757
|
+
}, [style, position, horizontal, index]);
|
|
758
|
+
return /* @__PURE__ */ React3__namespace.createElement(LayoutView, { refView, style: viewStyle, ...rest });
|
|
759
|
+
});
|
|
760
|
+
var PositionView2 = PositionViewState;
|
|
761
|
+
function Separator({ ItemSeparatorComponent, itemKey, leadingItem }) {
|
|
762
|
+
const [lastItemKeys] = useArr$(["lastItemKeys"]);
|
|
763
|
+
const isALastItem = lastItemKeys.includes(itemKey);
|
|
764
|
+
return isALastItem ? null : /* @__PURE__ */ React3__namespace.createElement(ItemSeparatorComponent, { leadingItem });
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// src/constants-platform.ts
|
|
768
|
+
var IsNewArchitecture = true;
|
|
769
|
+
|
|
770
|
+
// src/platform/Platform.ts
|
|
771
|
+
var Platform = {
|
|
772
|
+
// Widen the type to avoid unreachable-branch lints in cross-platform code that compares against other OSes
|
|
773
|
+
OS: "web"
|
|
774
|
+
};
|
|
200
775
|
var symbolFirst = Symbol();
|
|
201
776
|
function useInit(cb) {
|
|
202
777
|
const refValue = React3.useRef(symbolFirst);
|
|
@@ -333,8 +908,12 @@ function useListScrollSize() {
|
|
|
333
908
|
const [scrollSize] = useArr$(["scrollSize"]);
|
|
334
909
|
return scrollSize;
|
|
335
910
|
}
|
|
336
|
-
|
|
337
|
-
|
|
911
|
+
function useSyncLayout2() {
|
|
912
|
+
{
|
|
913
|
+
const { triggerLayout: syncLayout } = React3.useContext(ContextContainer);
|
|
914
|
+
return syncLayout;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
338
917
|
|
|
339
918
|
// src/components/Container.tsx
|
|
340
919
|
var Container = typedMemo(function Container2({
|
|
@@ -346,51 +925,56 @@ var Container = typedMemo(function Container2({
|
|
|
346
925
|
ItemSeparatorComponent
|
|
347
926
|
}) {
|
|
348
927
|
const ctx = useStateContext();
|
|
349
|
-
const columnWrapperStyle = ctx
|
|
350
|
-
const [column = 0, data, itemKey,
|
|
928
|
+
const { columnWrapperStyle } = ctx;
|
|
929
|
+
const [column = 0, data, itemKey, numColumns, extraData, isSticky] = useArr$([
|
|
351
930
|
`containerColumn${id}`,
|
|
352
931
|
`containerItemData${id}`,
|
|
353
932
|
`containerItemKey${id}`,
|
|
354
|
-
`containerPosition${id}`,
|
|
355
933
|
"numColumns",
|
|
356
|
-
"extraData"
|
|
934
|
+
"extraData",
|
|
935
|
+
`containerSticky${id}`
|
|
357
936
|
]);
|
|
358
937
|
const refLastSize = React3.useRef();
|
|
359
938
|
const ref = React3.useRef(null);
|
|
360
|
-
const [
|
|
939
|
+
const [_, forceLayoutRender] = React3.useState(0);
|
|
361
940
|
const otherAxisPos = numColumns > 1 ? `${(column - 1) / numColumns * 100}%` : 0;
|
|
362
941
|
const otherAxisSize = numColumns > 1 ? `${1 / numColumns * 100}%` : void 0;
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
942
|
+
const style = React3.useMemo(() => {
|
|
943
|
+
let paddingStyles;
|
|
944
|
+
if (columnWrapperStyle) {
|
|
945
|
+
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
946
|
+
if (horizontal) {
|
|
947
|
+
const py = numColumns > 1 ? (rowGap || gap || 0) / 2 : void 0;
|
|
948
|
+
paddingStyles = {
|
|
949
|
+
paddingBottom: py,
|
|
950
|
+
paddingRight: columnGap || gap || void 0,
|
|
951
|
+
paddingTop: py
|
|
952
|
+
};
|
|
953
|
+
} else {
|
|
954
|
+
const px = numColumns > 1 ? (columnGap || gap || 0) / 2 : void 0;
|
|
955
|
+
paddingStyles = {
|
|
956
|
+
paddingBottom: rowGap || gap || void 0,
|
|
957
|
+
paddingLeft: px,
|
|
958
|
+
paddingRight: px
|
|
959
|
+
};
|
|
960
|
+
}
|
|
377
961
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
};
|
|
962
|
+
return horizontal ? {
|
|
963
|
+
flexDirection: ItemSeparatorComponent ? "row" : void 0,
|
|
964
|
+
height: otherAxisSize,
|
|
965
|
+
left: 0,
|
|
966
|
+
position: "absolute",
|
|
967
|
+
top: otherAxisPos,
|
|
968
|
+
...paddingStyles || {}
|
|
969
|
+
} : {
|
|
970
|
+
left: otherAxisPos,
|
|
971
|
+
position: "absolute",
|
|
972
|
+
right: numColumns > 1 ? void 0 : 0,
|
|
973
|
+
top: 0,
|
|
974
|
+
width: otherAxisSize,
|
|
975
|
+
...paddingStyles || {}
|
|
976
|
+
};
|
|
977
|
+
}, [horizontal, otherAxisPos, otherAxisSize, columnWrapperStyle, numColumns]);
|
|
394
978
|
const renderedItemInfo = React3.useMemo(
|
|
395
979
|
() => itemKey !== void 0 ? getRenderedItem2(itemKey) : null,
|
|
396
980
|
[itemKey, data, extraData]
|
|
@@ -408,104 +992,183 @@ var Container = typedMemo(function Container2({
|
|
|
408
992
|
value: data
|
|
409
993
|
};
|
|
410
994
|
}, [id, itemKey, index, data]);
|
|
411
|
-
const
|
|
412
|
-
var _a, _b;
|
|
995
|
+
const onLayoutChange = (rectangle) => {
|
|
413
996
|
if (!isNullOrUndefined(itemKey)) {
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
const size = layout[horizontal ? "width" : "height"];
|
|
997
|
+
let layout = rectangle;
|
|
998
|
+
layout[horizontal ? "width" : "height"];
|
|
417
999
|
const doUpdate = () => {
|
|
418
1000
|
refLastSize.current = { height: layout.height, width: layout.width };
|
|
419
1001
|
updateItemSize2(itemKey, layout);
|
|
420
1002
|
};
|
|
421
|
-
|
|
1003
|
+
{
|
|
422
1004
|
doUpdate();
|
|
423
|
-
} else {
|
|
424
|
-
(_b = (_a = ref.current) == null ? void 0 : _a.measure) == null ? void 0 : _b.call(_a, (_x, _y, width, height) => {
|
|
425
|
-
layout = { height, width };
|
|
426
|
-
doUpdate();
|
|
427
|
-
});
|
|
428
1005
|
}
|
|
429
1006
|
}
|
|
430
1007
|
};
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
1008
|
+
const PositionComponent = isSticky ? PositionViewSticky : PositionView2;
|
|
1009
|
+
return /* @__PURE__ */ React.createElement(ContextContainer.Provider, { value: contextValue }, /* @__PURE__ */ React.createElement(
|
|
1010
|
+
PositionComponent,
|
|
1011
|
+
{
|
|
1012
|
+
horizontal,
|
|
1013
|
+
id,
|
|
1014
|
+
index,
|
|
1015
|
+
key: recycleItems ? void 0 : itemKey,
|
|
1016
|
+
onLayoutChange,
|
|
1017
|
+
refView: ref,
|
|
1018
|
+
style
|
|
1019
|
+
},
|
|
1020
|
+
renderedItem,
|
|
1021
|
+
renderedItemInfo && ItemSeparatorComponent && /* @__PURE__ */ React.createElement(
|
|
1022
|
+
Separator,
|
|
1023
|
+
{
|
|
1024
|
+
ItemSeparatorComponent,
|
|
1025
|
+
itemKey,
|
|
1026
|
+
leadingItem: renderedItemInfo.item
|
|
1027
|
+
}
|
|
1028
|
+
)
|
|
1029
|
+
));
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
// src/utils/reordering.ts
|
|
1033
|
+
var mapFn = (element) => {
|
|
1034
|
+
const indexStr = element.getAttribute("index");
|
|
1035
|
+
return [element, indexStr === null ? null : parseInt(indexStr)];
|
|
1036
|
+
};
|
|
1037
|
+
function sortDOMElementsPatience(container) {
|
|
1038
|
+
const elements = Array.from(container.children);
|
|
1039
|
+
if (elements.length <= 1) return elements;
|
|
1040
|
+
const items = elements.map(mapFn);
|
|
1041
|
+
items.sort((a, b) => {
|
|
1042
|
+
const aKey = a[1];
|
|
1043
|
+
const bKey = b[1];
|
|
1044
|
+
if (aKey === null) {
|
|
1045
|
+
return 1;
|
|
1046
|
+
}
|
|
1047
|
+
if (bKey === null) {
|
|
1048
|
+
return -1;
|
|
1049
|
+
}
|
|
1050
|
+
return aKey - bKey;
|
|
1051
|
+
});
|
|
1052
|
+
const targetPositions = /* @__PURE__ */ new Map();
|
|
1053
|
+
items.forEach((item, index) => {
|
|
1054
|
+
targetPositions.set(item[0], index);
|
|
1055
|
+
});
|
|
1056
|
+
const currentPositions = elements.map((el) => targetPositions.get(el));
|
|
1057
|
+
const lis = findLIS(currentPositions);
|
|
1058
|
+
const stableIndices = new Set(lis);
|
|
1059
|
+
for (let targetPos = 0; targetPos < items.length; targetPos++) {
|
|
1060
|
+
const element = items[targetPos][0];
|
|
1061
|
+
const currentPos = elements.indexOf(element);
|
|
1062
|
+
if (!stableIndices.has(currentPos)) {
|
|
1063
|
+
let nextStableElement = null;
|
|
1064
|
+
for (let i = targetPos + 1; i < items.length; i++) {
|
|
1065
|
+
const nextEl = items[i][0];
|
|
1066
|
+
const nextCurrentPos = elements.indexOf(nextEl);
|
|
1067
|
+
if (stableIndices.has(nextCurrentPos)) {
|
|
1068
|
+
nextStableElement = nextEl;
|
|
1069
|
+
break;
|
|
441
1070
|
}
|
|
442
1071
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
const timeout = setTimeout(() => {
|
|
448
|
-
if (!didLayout && refLastSize.current) {
|
|
449
|
-
updateItemSize2(itemKey, refLastSize.current);
|
|
450
|
-
}
|
|
451
|
-
}, 16);
|
|
452
|
-
return () => {
|
|
453
|
-
clearTimeout(timeout);
|
|
454
|
-
};
|
|
1072
|
+
if (nextStableElement) {
|
|
1073
|
+
container.insertBefore(element, nextStableElement);
|
|
1074
|
+
} else {
|
|
1075
|
+
container.appendChild(element);
|
|
455
1076
|
}
|
|
456
|
-
}
|
|
1077
|
+
}
|
|
457
1078
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
1079
|
+
}
|
|
1080
|
+
function findLIS(arr) {
|
|
1081
|
+
const n = arr.length;
|
|
1082
|
+
const tails = [];
|
|
1083
|
+
const predecessors = new Array(n).fill(-1);
|
|
1084
|
+
const indices = [];
|
|
1085
|
+
for (let i = 0; i < n; i++) {
|
|
1086
|
+
const num = arr[i];
|
|
1087
|
+
let left = 0, right = tails.length;
|
|
1088
|
+
while (left < right) {
|
|
1089
|
+
const mid = Math.floor((left + right) / 2);
|
|
1090
|
+
if (arr[indices[mid]] < num) {
|
|
1091
|
+
left = mid + 1;
|
|
1092
|
+
} else {
|
|
1093
|
+
right = mid;
|
|
1094
|
+
}
|
|
464
1095
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
1096
|
+
if (left === tails.length) {
|
|
1097
|
+
tails.push(num);
|
|
1098
|
+
indices.push(i);
|
|
1099
|
+
} else {
|
|
1100
|
+
tails[left] = num;
|
|
1101
|
+
indices[left] = i;
|
|
1102
|
+
}
|
|
1103
|
+
if (left > 0) {
|
|
1104
|
+
predecessors[i] = indices[left - 1];
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
const result = [];
|
|
1108
|
+
let k = indices[indices.length - 1];
|
|
1109
|
+
while (k !== -1) {
|
|
1110
|
+
result.unshift(k);
|
|
1111
|
+
k = predecessors[k];
|
|
1112
|
+
}
|
|
1113
|
+
return result;
|
|
1114
|
+
}
|
|
470
1115
|
|
|
471
|
-
// src/hooks/
|
|
472
|
-
function
|
|
473
|
-
var _a;
|
|
474
|
-
const { getValue, delay } = params || {};
|
|
1116
|
+
// src/hooks/useDOMOrder.ts
|
|
1117
|
+
function useDOMOrder(ref) {
|
|
475
1118
|
const ctx = useStateContext();
|
|
476
|
-
const
|
|
477
|
-
React3.
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
if (newValue !== void 0) {
|
|
487
|
-
animValue.setValue(newValue);
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
const delayValue = typeof delay === "function" ? delay(newValue, prevValue) : delay;
|
|
491
|
-
prevValue = newValue;
|
|
492
|
-
if (!didQueueTask) {
|
|
493
|
-
didQueueTask = true;
|
|
494
|
-
if (delayValue === 0) {
|
|
495
|
-
queueMicrotask(fn);
|
|
496
|
-
} else {
|
|
497
|
-
setTimeout(fn, delayValue);
|
|
498
|
-
}
|
|
1119
|
+
const debounceRef = React3.useRef(void 0);
|
|
1120
|
+
React3.useEffect(() => {
|
|
1121
|
+
const unsubscribe = listen$(ctx, "lastPositionUpdate", () => {
|
|
1122
|
+
if (debounceRef.current !== void 0) {
|
|
1123
|
+
clearTimeout(debounceRef.current);
|
|
1124
|
+
}
|
|
1125
|
+
debounceRef.current = setTimeout(() => {
|
|
1126
|
+
const parent = ref.current;
|
|
1127
|
+
if (parent) {
|
|
1128
|
+
sortDOMElementsPatience(parent);
|
|
499
1129
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
}
|
|
1130
|
+
debounceRef.current = void 0;
|
|
1131
|
+
}, 500);
|
|
503
1132
|
});
|
|
504
|
-
|
|
505
|
-
|
|
1133
|
+
return () => {
|
|
1134
|
+
unsubscribe();
|
|
1135
|
+
if (debounceRef.current !== void 0) {
|
|
1136
|
+
clearTimeout(debounceRef.current);
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
}, [ctx]);
|
|
506
1140
|
}
|
|
507
1141
|
|
|
508
1142
|
// src/components/Containers.tsx
|
|
1143
|
+
var ContainersInner = typedMemo(function ContainersInner2({ horizontal, numColumns, children }) {
|
|
1144
|
+
const ref = React3.useRef(null);
|
|
1145
|
+
const ctx = useStateContext();
|
|
1146
|
+
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
1147
|
+
const [totalSize, otherAxisSize] = useArr$(["totalSize", "otherAxisSize"]);
|
|
1148
|
+
useDOMOrder(ref);
|
|
1149
|
+
const style = horizontal ? { minHeight: otherAxisSize, width: totalSize } : { height: totalSize, minWidth: otherAxisSize };
|
|
1150
|
+
if (columnWrapperStyle && numColumns > 1) {
|
|
1151
|
+
const { columnGap, rowGap, gap } = columnWrapperStyle;
|
|
1152
|
+
const gapX = columnGap || gap || 0;
|
|
1153
|
+
const gapY = rowGap || gap || 0;
|
|
1154
|
+
if (horizontal) {
|
|
1155
|
+
if (gapY) {
|
|
1156
|
+
style.marginTop = style.marginBottom = -gapY / 2;
|
|
1157
|
+
}
|
|
1158
|
+
if (gapX) {
|
|
1159
|
+
style.marginRight = -gapX;
|
|
1160
|
+
}
|
|
1161
|
+
} else {
|
|
1162
|
+
if (gapX) {
|
|
1163
|
+
style.marginLeft = style.marginRight = -gapX;
|
|
1164
|
+
}
|
|
1165
|
+
if (gapY) {
|
|
1166
|
+
style.marginBottom = -gapY;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
return /* @__PURE__ */ React3__namespace.createElement("div", { ref, style }, children);
|
|
1171
|
+
});
|
|
509
1172
|
var Containers = typedMemo(function Containers2({
|
|
510
1173
|
horizontal,
|
|
511
1174
|
recycleItems,
|
|
@@ -514,15 +1177,7 @@ var Containers = typedMemo(function Containers2({
|
|
|
514
1177
|
updateItemSize: updateItemSize2,
|
|
515
1178
|
getRenderedItem: getRenderedItem2
|
|
516
1179
|
}) {
|
|
517
|
-
const ctx = useStateContext();
|
|
518
|
-
const columnWrapperStyle = ctx.columnWrapperStyle;
|
|
519
1180
|
const [numContainers, numColumns] = useArr$(["numContainersPooled", "numColumns"]);
|
|
520
|
-
const animSize = useValue$("totalSize", {
|
|
521
|
-
// Use a microtask if increasing the size significantly, otherwise use a timeout
|
|
522
|
-
delay: (value, prevValue) => !prevValue || value - prevValue > 20 ? 0 : 200
|
|
523
|
-
});
|
|
524
|
-
const animOpacity = waitForInitialLayout && !IsNewArchitecture ? useValue$("containersDidLayout", { getValue: (value) => value ? 1 : 0 }) : void 0;
|
|
525
|
-
const otherAxisSize = useValue$("otherAxisSize", { delay: 0 });
|
|
526
1181
|
const containers = [];
|
|
527
1182
|
for (let i = 0; i < numContainers; i++) {
|
|
528
1183
|
containers.push(
|
|
@@ -540,45 +1195,209 @@ var Containers = typedMemo(function Containers2({
|
|
|
540
1195
|
)
|
|
541
1196
|
);
|
|
542
1197
|
}
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
1198
|
+
return /* @__PURE__ */ React3__namespace.createElement(ContainersInner, { horizontal, numColumns, waitForInitialLayout }, containers);
|
|
1199
|
+
});
|
|
1200
|
+
var DevNumbers = __DEV__ && React3__namespace.memo(function DevNumbers2() {
|
|
1201
|
+
return Array.from({ length: 100 }).map((_, index) => /* @__PURE__ */ React3__namespace.createElement(
|
|
1202
|
+
View,
|
|
1203
|
+
{
|
|
1204
|
+
key: index,
|
|
1205
|
+
style: {
|
|
1206
|
+
height: 100,
|
|
1207
|
+
pointerEvents: "none",
|
|
1208
|
+
position: "absolute",
|
|
1209
|
+
top: index * 100,
|
|
1210
|
+
width: "100%"
|
|
551
1211
|
}
|
|
552
|
-
|
|
553
|
-
|
|
1212
|
+
},
|
|
1213
|
+
/* @__PURE__ */ React3__namespace.createElement(Text, { style: { color: "red" } }, index * 100)
|
|
1214
|
+
));
|
|
1215
|
+
});
|
|
1216
|
+
var ListComponentScrollView = React3.forwardRef(function ListComponentScrollView2({
|
|
1217
|
+
children,
|
|
1218
|
+
style,
|
|
1219
|
+
contentContainerStyle,
|
|
1220
|
+
horizontal = false,
|
|
1221
|
+
contentOffset,
|
|
1222
|
+
maintainVisibleContentPosition,
|
|
1223
|
+
onScroll: onScroll2,
|
|
1224
|
+
onMomentumScrollEnd,
|
|
1225
|
+
showsHorizontalScrollIndicator = true,
|
|
1226
|
+
showsVerticalScrollIndicator = true,
|
|
1227
|
+
refreshControl,
|
|
1228
|
+
onLayout,
|
|
1229
|
+
ScrollComponent,
|
|
1230
|
+
...props
|
|
1231
|
+
}, ref) {
|
|
1232
|
+
const scrollRef = React3.useRef(null);
|
|
1233
|
+
const contentRef = React3.useRef(null);
|
|
1234
|
+
const momentumTimeout = React3.useRef(null);
|
|
1235
|
+
React3.useImperativeHandle(ref, () => {
|
|
1236
|
+
const api = {
|
|
1237
|
+
getBoundingClientRect: () => {
|
|
1238
|
+
var _a;
|
|
1239
|
+
return (_a = scrollRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
1240
|
+
},
|
|
1241
|
+
getScrollableNode: () => scrollRef.current,
|
|
1242
|
+
getScrollResponder: () => scrollRef.current,
|
|
1243
|
+
scrollBy: (options) => {
|
|
1244
|
+
const el = scrollRef.current;
|
|
1245
|
+
if (!el) return;
|
|
1246
|
+
const { x = 0, y = 0, animated = true } = options;
|
|
1247
|
+
el.scrollBy({ behavior: animated ? "smooth" : "auto", left: x, top: y });
|
|
1248
|
+
},
|
|
1249
|
+
scrollTo: (options) => {
|
|
1250
|
+
const el = scrollRef.current;
|
|
1251
|
+
if (!el) return;
|
|
1252
|
+
const { x = 0, y = 0, animated = true } = options;
|
|
1253
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", left: x, top: y });
|
|
1254
|
+
},
|
|
1255
|
+
scrollToEnd: (options = {}) => {
|
|
1256
|
+
const el = scrollRef.current;
|
|
1257
|
+
if (!el) return;
|
|
1258
|
+
const { animated = true } = options;
|
|
1259
|
+
if (horizontal) {
|
|
1260
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", left: el.scrollWidth });
|
|
1261
|
+
} else {
|
|
1262
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", top: el.scrollHeight });
|
|
1263
|
+
}
|
|
1264
|
+
},
|
|
1265
|
+
scrollToOffset: (params) => {
|
|
1266
|
+
const el = scrollRef.current;
|
|
1267
|
+
if (!el) return;
|
|
1268
|
+
const { offset, animated = true } = params;
|
|
1269
|
+
if (horizontal) {
|
|
1270
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", left: offset });
|
|
1271
|
+
} else {
|
|
1272
|
+
el.scrollTo({ behavior: animated ? "smooth" : "auto", top: offset });
|
|
1273
|
+
}
|
|
554
1274
|
}
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
|
|
1275
|
+
};
|
|
1276
|
+
return api;
|
|
1277
|
+
}, [horizontal]);
|
|
1278
|
+
const handleScroll = React3.useCallback(
|
|
1279
|
+
(event) => {
|
|
1280
|
+
if (!onScroll2 || !(event == null ? void 0 : event.target)) {
|
|
1281
|
+
return;
|
|
558
1282
|
}
|
|
559
|
-
|
|
560
|
-
|
|
1283
|
+
const target = event.target;
|
|
1284
|
+
const scrollEvent = {
|
|
1285
|
+
nativeEvent: {
|
|
1286
|
+
contentOffset: {
|
|
1287
|
+
x: target.scrollLeft,
|
|
1288
|
+
y: target.scrollTop
|
|
1289
|
+
},
|
|
1290
|
+
contentSize: {
|
|
1291
|
+
height: target.scrollHeight,
|
|
1292
|
+
width: target.scrollWidth
|
|
1293
|
+
},
|
|
1294
|
+
layoutMeasurement: {
|
|
1295
|
+
height: target.clientHeight,
|
|
1296
|
+
width: target.clientWidth
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
onScroll2(scrollEvent);
|
|
1301
|
+
if (onMomentumScrollEnd) {
|
|
1302
|
+
if (momentumTimeout.current != null) clearTimeout(momentumTimeout.current);
|
|
1303
|
+
momentumTimeout.current = setTimeout(() => {
|
|
1304
|
+
onMomentumScrollEnd({
|
|
1305
|
+
nativeEvent: {
|
|
1306
|
+
contentOffset: scrollEvent.nativeEvent.contentOffset
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
}, 100);
|
|
561
1310
|
}
|
|
1311
|
+
},
|
|
1312
|
+
[onScroll2, onMomentumScrollEnd]
|
|
1313
|
+
);
|
|
1314
|
+
React3.useLayoutEffect(() => {
|
|
1315
|
+
const element = scrollRef.current;
|
|
1316
|
+
if (!element) return;
|
|
1317
|
+
element.addEventListener("scroll", handleScroll, { passive: true });
|
|
1318
|
+
return () => {
|
|
1319
|
+
element.removeEventListener("scroll", handleScroll);
|
|
1320
|
+
};
|
|
1321
|
+
}, [handleScroll]);
|
|
1322
|
+
React3.useLayoutEffect(() => {
|
|
1323
|
+
if (contentOffset && scrollRef.current) {
|
|
1324
|
+
scrollRef.current.scrollLeft = contentOffset.x || 0;
|
|
1325
|
+
scrollRef.current.scrollTop = contentOffset.y || 0;
|
|
562
1326
|
}
|
|
563
|
-
}
|
|
564
|
-
|
|
1327
|
+
}, [contentOffset]);
|
|
1328
|
+
React3.useLayoutEffect(() => {
|
|
1329
|
+
if (!onLayout || !scrollRef.current) return;
|
|
1330
|
+
const element = scrollRef.current;
|
|
1331
|
+
const fireLayout = () => {
|
|
1332
|
+
const rect = element.getBoundingClientRect();
|
|
1333
|
+
onLayout({
|
|
1334
|
+
nativeEvent: {
|
|
1335
|
+
layout: {
|
|
1336
|
+
height: rect.height,
|
|
1337
|
+
width: rect.width,
|
|
1338
|
+
x: rect.left,
|
|
1339
|
+
y: rect.top
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
};
|
|
1344
|
+
fireLayout();
|
|
1345
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
1346
|
+
fireLayout();
|
|
1347
|
+
});
|
|
1348
|
+
resizeObserver.observe(element);
|
|
1349
|
+
return () => resizeObserver.disconnect();
|
|
1350
|
+
}, [onLayout]);
|
|
1351
|
+
const scrollViewStyle = {
|
|
1352
|
+
overflow: "auto",
|
|
1353
|
+
overflowX: horizontal ? "auto" : showsHorizontalScrollIndicator ? "auto" : "hidden",
|
|
1354
|
+
overflowY: horizontal ? showsVerticalScrollIndicator ? "auto" : "hidden" : "auto",
|
|
1355
|
+
position: "relative",
|
|
1356
|
+
// Ensure proper positioning context
|
|
1357
|
+
WebkitOverflowScrolling: "touch",
|
|
1358
|
+
// iOS momentum scrolling
|
|
1359
|
+
...style
|
|
1360
|
+
};
|
|
1361
|
+
const contentStyle = {
|
|
1362
|
+
display: horizontal ? "flex" : "block",
|
|
1363
|
+
flexDirection: horizontal ? "row" : void 0,
|
|
1364
|
+
minHeight: horizontal ? void 0 : "100%",
|
|
1365
|
+
minWidth: horizontal ? "100%" : void 0,
|
|
1366
|
+
...contentContainerStyle
|
|
1367
|
+
};
|
|
1368
|
+
return /* @__PURE__ */ React.createElement("div", { ref: scrollRef, style: scrollViewStyle, ...props }, refreshControl, /* @__PURE__ */ React.createElement("div", { ref: contentRef, style: contentStyle }, children));
|
|
565
1369
|
});
|
|
1370
|
+
function useValueListener$(key, callback) {
|
|
1371
|
+
const ctx = useStateContext();
|
|
1372
|
+
React3.useLayoutEffect(() => {
|
|
1373
|
+
listen$(ctx, key, (value) => {
|
|
1374
|
+
callback(value);
|
|
1375
|
+
});
|
|
1376
|
+
}, []);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// src/components/ScrollAdjust.tsx
|
|
566
1380
|
function ScrollAdjust() {
|
|
567
|
-
const
|
|
568
|
-
const
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
1381
|
+
const ctx = useStateContext();
|
|
1382
|
+
const lastScrollOffsetRef = React3__namespace.useRef(0);
|
|
1383
|
+
const callback = React3__namespace.useCallback(() => {
|
|
1384
|
+
var _a;
|
|
1385
|
+
const scrollAdjust = peek$(ctx, "scrollAdjust");
|
|
1386
|
+
const scrollAdjustUserOffset = peek$(ctx, "scrollAdjustUserOffset");
|
|
1387
|
+
const scrollOffset = (scrollAdjust || 0) + (scrollAdjustUserOffset || 0);
|
|
1388
|
+
const scrollView = (_a = ctx.internalState) == null ? void 0 : _a.refScroller.current;
|
|
1389
|
+
if (scrollView && scrollOffset !== lastScrollOffsetRef.current) {
|
|
1390
|
+
const scrollDelta = scrollOffset - lastScrollOffsetRef.current;
|
|
1391
|
+
if (scrollDelta !== 0) {
|
|
1392
|
+
scrollView.scrollBy(0, scrollDelta);
|
|
1393
|
+
console.log("ScrollAdjust (web scrollBy)", scrollDelta, "total offset:", scrollOffset);
|
|
1394
|
+
}
|
|
1395
|
+
lastScrollOffsetRef.current = scrollOffset;
|
|
580
1396
|
}
|
|
581
|
-
);
|
|
1397
|
+
}, []);
|
|
1398
|
+
useValueListener$("scrollAdjust", callback);
|
|
1399
|
+
useValueListener$("scrollAdjustUserOffset", callback);
|
|
1400
|
+
return null;
|
|
582
1401
|
}
|
|
583
1402
|
|
|
584
1403
|
// src/components/SnapWrapper.tsx
|
|
@@ -586,26 +1405,11 @@ function SnapWrapper({ ScrollComponent, ...props }) {
|
|
|
586
1405
|
const [snapToOffsets] = useArr$(["snapToOffsets"]);
|
|
587
1406
|
return /* @__PURE__ */ React.createElement(ScrollComponent, { ...props, snapToOffsets });
|
|
588
1407
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
(event) => {
|
|
595
|
-
onChange(event.nativeEvent.layout, false);
|
|
596
|
-
},
|
|
597
|
-
[onChange]
|
|
598
|
-
);
|
|
599
|
-
if (IsNewArchitecture) {
|
|
600
|
-
React3.useLayoutEffect(() => {
|
|
601
|
-
if (ref.current) {
|
|
602
|
-
ref.current.measure((x, y, width, height) => {
|
|
603
|
-
onChange({ height, width, x, y }, true);
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
}, []);
|
|
607
|
-
}
|
|
608
|
-
return { onLayout, ref };
|
|
1408
|
+
|
|
1409
|
+
// src/hooks/useValue$.ts
|
|
1410
|
+
function useValue$(key, params) {
|
|
1411
|
+
const [value] = useArr$([key]);
|
|
1412
|
+
return value;
|
|
609
1413
|
}
|
|
610
1414
|
|
|
611
1415
|
// src/components/ListComponent.tsx
|
|
@@ -619,13 +1423,13 @@ var getComponent = (Component) => {
|
|
|
619
1423
|
return null;
|
|
620
1424
|
};
|
|
621
1425
|
var Padding = () => {
|
|
622
|
-
const animPaddingTop = useValue$("alignItemsPaddingTop"
|
|
623
|
-
return /* @__PURE__ */ React3__namespace.createElement(
|
|
1426
|
+
const animPaddingTop = useValue$("alignItemsPaddingTop");
|
|
1427
|
+
return /* @__PURE__ */ React3__namespace.createElement(AnimatedView, { style: { paddingTop: animPaddingTop } });
|
|
624
1428
|
};
|
|
625
1429
|
var PaddingDevMode = () => {
|
|
626
|
-
const animPaddingTop = useValue$("alignItemsPaddingTop"
|
|
627
|
-
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
628
|
-
|
|
1430
|
+
const animPaddingTop = useValue$("alignItemsPaddingTop");
|
|
1431
|
+
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(AnimatedView, { style: { paddingTop: animPaddingTop } }), /* @__PURE__ */ React3__namespace.createElement(
|
|
1432
|
+
AnimatedView,
|
|
629
1433
|
{
|
|
630
1434
|
style: {
|
|
631
1435
|
backgroundColor: "green",
|
|
@@ -663,16 +1467,15 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
663
1467
|
scrollAdjustHandler,
|
|
664
1468
|
onLayoutHeader,
|
|
665
1469
|
snapToIndices,
|
|
1470
|
+
stickyIndices,
|
|
666
1471
|
...rest
|
|
667
1472
|
}) {
|
|
668
1473
|
const ctx = useStateContext();
|
|
669
|
-
const
|
|
670
|
-
onChange: onLayoutHeader
|
|
671
|
-
});
|
|
1474
|
+
const refHeader = React3__namespace.useRef(null);
|
|
672
1475
|
const ScrollComponent = renderScrollComponent ? React3.useMemo(
|
|
673
1476
|
() => React3__namespace.forwardRef((props, ref) => renderScrollComponent({ ...props, ref })),
|
|
674
1477
|
[renderScrollComponent]
|
|
675
|
-
) :
|
|
1478
|
+
) : ListComponentScrollView;
|
|
676
1479
|
React3__namespace.useEffect(() => {
|
|
677
1480
|
if (canRender) {
|
|
678
1481
|
setTimeout(() => {
|
|
@@ -681,16 +1484,17 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
681
1484
|
}
|
|
682
1485
|
}, [canRender]);
|
|
683
1486
|
const SnapOrScroll = snapToIndices ? SnapWrapper : ScrollComponent;
|
|
1487
|
+
const contentContainerStyleWeb = React3.useMemo(() => {
|
|
1488
|
+
const base = contentContainerStyle || void 0;
|
|
1489
|
+
if (!horizontal) return base;
|
|
1490
|
+
if (base && base.height === "100%") return base;
|
|
1491
|
+
return { ...base || {}, height: "100%" };
|
|
1492
|
+
}, [horizontal, (contentContainerStyle == null ? void 0 : contentContainerStyle.height) === "100%" ? 1 : 0]);
|
|
684
1493
|
return /* @__PURE__ */ React3__namespace.createElement(
|
|
685
1494
|
SnapOrScroll,
|
|
686
1495
|
{
|
|
687
1496
|
...rest,
|
|
688
|
-
contentContainerStyle:
|
|
689
|
-
contentContainerStyle,
|
|
690
|
-
horizontal ? {
|
|
691
|
-
height: "100%"
|
|
692
|
-
} : {}
|
|
693
|
-
],
|
|
1497
|
+
contentContainerStyle: contentContainerStyleWeb,
|
|
694
1498
|
contentOffset: initialContentOffset ? horizontal ? { x: initialContentOffset, y: 0 } : { x: 0, y: initialContentOffset } : void 0,
|
|
695
1499
|
horizontal,
|
|
696
1500
|
maintainVisibleContentPosition: maintainVisibleContentPosition && !ListEmptyComponent ? { minIndexForVisible: 0 } : void 0,
|
|
@@ -702,7 +1506,15 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
702
1506
|
},
|
|
703
1507
|
maintainVisibleContentPosition && /* @__PURE__ */ React3__namespace.createElement(ScrollAdjust, null),
|
|
704
1508
|
ENABLE_DEVMODE ? /* @__PURE__ */ React3__namespace.createElement(PaddingDevMode, null) : /* @__PURE__ */ React3__namespace.createElement(Padding, null),
|
|
705
|
-
ListHeaderComponent && /* @__PURE__ */ React3__namespace.createElement(
|
|
1509
|
+
ListHeaderComponent && /* @__PURE__ */ React3__namespace.createElement(
|
|
1510
|
+
LayoutView,
|
|
1511
|
+
{
|
|
1512
|
+
onLayoutChange: onLayoutHeader,
|
|
1513
|
+
refView: refHeader,
|
|
1514
|
+
style: ListHeaderComponentStyle
|
|
1515
|
+
},
|
|
1516
|
+
getComponent(ListHeaderComponent)
|
|
1517
|
+
),
|
|
706
1518
|
ListEmptyComponent && getComponent(ListEmptyComponent),
|
|
707
1519
|
canRender && /* @__PURE__ */ React3__namespace.createElement(
|
|
708
1520
|
Containers,
|
|
@@ -716,16 +1528,17 @@ var ListComponent = typedMemo(function ListComponent2({
|
|
|
716
1528
|
}
|
|
717
1529
|
),
|
|
718
1530
|
ListFooterComponent && /* @__PURE__ */ React3__namespace.createElement(
|
|
719
|
-
|
|
1531
|
+
LayoutView,
|
|
720
1532
|
{
|
|
721
|
-
|
|
722
|
-
const size =
|
|
1533
|
+
onLayoutChange: (layout) => {
|
|
1534
|
+
const size = layout[horizontal ? "width" : "height"];
|
|
723
1535
|
set$(ctx, "footerSize", size);
|
|
724
1536
|
},
|
|
725
1537
|
style: ListFooterComponentStyle
|
|
726
1538
|
},
|
|
727
1539
|
getComponent(ListFooterComponent)
|
|
728
|
-
)
|
|
1540
|
+
),
|
|
1541
|
+
__DEV__ && ENABLE_DEVMODE && /* @__PURE__ */ React3__namespace.createElement(DevNumbers, null)
|
|
729
1542
|
);
|
|
730
1543
|
});
|
|
731
1544
|
|
|
@@ -746,33 +1559,45 @@ function calculateOffsetForIndex(ctx, state, index) {
|
|
|
746
1559
|
let position = 0;
|
|
747
1560
|
if (index !== void 0) {
|
|
748
1561
|
position = (state == null ? void 0 : state.positions.get(getId(state, index))) || 0;
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
1562
|
+
const paddingTop = peek$(ctx, "stylePaddingTop");
|
|
1563
|
+
if (paddingTop) {
|
|
1564
|
+
position += paddingTop;
|
|
1565
|
+
}
|
|
1566
|
+
const headerSize = peek$(ctx, "headerSize");
|
|
1567
|
+
if (headerSize) {
|
|
1568
|
+
position += headerSize;
|
|
1569
|
+
}
|
|
757
1570
|
}
|
|
758
1571
|
return position;
|
|
759
1572
|
}
|
|
760
1573
|
|
|
761
1574
|
// src/utils/getItemSize.ts
|
|
762
1575
|
function getItemSize(state, key, index, data, useAverageSize) {
|
|
1576
|
+
var _a, _b;
|
|
763
1577
|
const {
|
|
764
1578
|
sizesKnown,
|
|
765
1579
|
sizes,
|
|
766
1580
|
scrollingTo,
|
|
767
|
-
|
|
1581
|
+
averageSizes,
|
|
1582
|
+
props: { estimatedItemSize, getEstimatedItemSize, getFixedItemSize, getItemType }
|
|
768
1583
|
} = state;
|
|
769
1584
|
const sizeKnown = sizesKnown.get(key);
|
|
770
1585
|
if (sizeKnown !== void 0) {
|
|
771
1586
|
return sizeKnown;
|
|
772
1587
|
}
|
|
773
1588
|
let size;
|
|
774
|
-
|
|
775
|
-
|
|
1589
|
+
const itemType = getItemType ? (_a = getItemType(data, index)) != null ? _a : "" : "";
|
|
1590
|
+
if (getFixedItemSize) {
|
|
1591
|
+
size = getFixedItemSize(index, data, itemType);
|
|
1592
|
+
if (size !== void 0) {
|
|
1593
|
+
sizesKnown.set(key, size);
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
if (size === void 0 && useAverageSize && sizeKnown === void 0 && !scrollingTo) {
|
|
1597
|
+
const averageSizeForType = (_b = averageSizes[itemType]) == null ? void 0 : _b.avg;
|
|
1598
|
+
if (averageSizeForType !== void 0) {
|
|
1599
|
+
size = roundSize(averageSizeForType);
|
|
1600
|
+
}
|
|
776
1601
|
}
|
|
777
1602
|
if (size === void 0) {
|
|
778
1603
|
size = sizes.get(key);
|
|
@@ -781,7 +1606,7 @@ function getItemSize(state, key, index, data, useAverageSize) {
|
|
|
781
1606
|
}
|
|
782
1607
|
}
|
|
783
1608
|
if (size === void 0) {
|
|
784
|
-
size = getEstimatedItemSize ? getEstimatedItemSize(index, data) : estimatedItemSize;
|
|
1609
|
+
size = getEstimatedItemSize ? getEstimatedItemSize(index, data, itemType) : estimatedItemSize;
|
|
785
1610
|
}
|
|
786
1611
|
sizes.set(key, size);
|
|
787
1612
|
return size;
|
|
@@ -800,11 +1625,46 @@ function calculateOffsetWithOffsetPosition(state, offsetParam, params) {
|
|
|
800
1625
|
return offset;
|
|
801
1626
|
}
|
|
802
1627
|
|
|
1628
|
+
// src/core/finishScrollTo.ts
|
|
1629
|
+
var finishScrollTo = (state) => {
|
|
1630
|
+
if (state) {
|
|
1631
|
+
state.scrollingTo = void 0;
|
|
1632
|
+
state.scrollHistory.length = 0;
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
|
|
1636
|
+
// src/core/scrollTo.ts
|
|
1637
|
+
function scrollTo(state, params = {}) {
|
|
1638
|
+
var _a;
|
|
1639
|
+
const { animated, noScrollingTo } = params;
|
|
1640
|
+
const {
|
|
1641
|
+
refScroller,
|
|
1642
|
+
props: { horizontal }
|
|
1643
|
+
} = state;
|
|
1644
|
+
const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
|
|
1645
|
+
state.scrollHistory.length = 0;
|
|
1646
|
+
if (!noScrollingTo) {
|
|
1647
|
+
state.scrollingTo = params;
|
|
1648
|
+
}
|
|
1649
|
+
state.scrollPending = offset;
|
|
1650
|
+
(_a = refScroller.current) == null ? void 0 : _a.scrollTo({
|
|
1651
|
+
animated: !!animated,
|
|
1652
|
+
x: horizontal ? offset : 0,
|
|
1653
|
+
y: horizontal ? 0 : offset
|
|
1654
|
+
});
|
|
1655
|
+
if (!animated) {
|
|
1656
|
+
state.scroll = offset;
|
|
1657
|
+
setTimeout(() => finishScrollTo(state), 100);
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
|
|
803
1661
|
// src/utils/requestAdjust.ts
|
|
804
|
-
function requestAdjust(ctx, state, positionDiff) {
|
|
1662
|
+
function requestAdjust(ctx, state, positionDiff, dataChanged) {
|
|
805
1663
|
if (Math.abs(positionDiff) > 0.1) {
|
|
806
1664
|
const doit = () => {
|
|
807
|
-
|
|
1665
|
+
{
|
|
1666
|
+
state.scrollAdjustHandler.requestAdjust(positionDiff);
|
|
1667
|
+
}
|
|
808
1668
|
};
|
|
809
1669
|
state.scroll += positionDiff;
|
|
810
1670
|
state.scrollForNextCalculateItemsInView = void 0;
|
|
@@ -823,49 +1683,72 @@ function requestAdjust(ctx, state, positionDiff) {
|
|
|
823
1683
|
if (state.ignoreScrollFromMVCPTimeout) {
|
|
824
1684
|
clearTimeout(state.ignoreScrollFromMVCPTimeout);
|
|
825
1685
|
}
|
|
826
|
-
state.ignoreScrollFromMVCPTimeout = setTimeout(
|
|
827
|
-
|
|
828
|
-
|
|
1686
|
+
state.ignoreScrollFromMVCPTimeout = setTimeout(
|
|
1687
|
+
() => {
|
|
1688
|
+
state.ignoreScrollFromMVCP = void 0;
|
|
1689
|
+
},
|
|
1690
|
+
100
|
|
1691
|
+
);
|
|
829
1692
|
} else {
|
|
830
1693
|
requestAnimationFrame(doit);
|
|
831
1694
|
}
|
|
832
1695
|
}
|
|
833
1696
|
}
|
|
834
1697
|
|
|
835
|
-
// src/core/
|
|
836
|
-
function prepareMVCP(ctx, state) {
|
|
1698
|
+
// src/core/mvcp.ts
|
|
1699
|
+
function prepareMVCP(ctx, state, dataChanged) {
|
|
837
1700
|
const {
|
|
1701
|
+
idsInView,
|
|
838
1702
|
positions,
|
|
839
1703
|
scrollingTo,
|
|
840
1704
|
props: { maintainVisibleContentPosition }
|
|
841
1705
|
} = state;
|
|
842
1706
|
let prevPosition;
|
|
843
1707
|
let targetId;
|
|
844
|
-
|
|
1708
|
+
const idsInViewWithPositions = [];
|
|
845
1709
|
const scrollTarget = scrollingTo == null ? void 0 : scrollingTo.index;
|
|
846
1710
|
if (maintainVisibleContentPosition) {
|
|
847
1711
|
const indexByKey = state.indexByKey;
|
|
848
1712
|
if (scrollTarget !== void 0) {
|
|
849
1713
|
targetId = getId(state, scrollTarget);
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
1714
|
+
} else if (idsInView.length > 0 && peek$(ctx, "containersDidLayout")) {
|
|
1715
|
+
if (dataChanged) {
|
|
1716
|
+
for (let i = 0; i < idsInView.length; i++) {
|
|
1717
|
+
const id = idsInView[i];
|
|
1718
|
+
const index = indexByKey.get(id);
|
|
1719
|
+
if (index !== void 0) {
|
|
1720
|
+
idsInViewWithPositions.push({ id, position: positions.get(id) });
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
} else {
|
|
1724
|
+
targetId = state.idsInView.find((id) => indexByKey.get(id) !== void 0);
|
|
1725
|
+
}
|
|
854
1726
|
}
|
|
855
|
-
if (targetId !== void 0
|
|
1727
|
+
if (targetId !== void 0) {
|
|
856
1728
|
prevPosition = positions.get(targetId);
|
|
857
1729
|
}
|
|
858
1730
|
}
|
|
859
1731
|
return () => {
|
|
1732
|
+
let positionDiff;
|
|
1733
|
+
if (dataChanged && targetId === void 0) {
|
|
1734
|
+
for (let i = 0; i < idsInViewWithPositions.length; i++) {
|
|
1735
|
+
const { id, position } = idsInViewWithPositions[i];
|
|
1736
|
+
const newPosition = positions.get(id);
|
|
1737
|
+
if (newPosition !== void 0) {
|
|
1738
|
+
positionDiff = newPosition - position;
|
|
1739
|
+
break;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
860
1743
|
if (targetId !== void 0 && prevPosition !== void 0) {
|
|
861
1744
|
const newPosition = positions.get(targetId);
|
|
862
1745
|
if (newPosition !== void 0) {
|
|
863
|
-
|
|
864
|
-
if (Math.abs(positionDiff) > 0.1) {
|
|
865
|
-
requestAdjust(ctx, state, positionDiff);
|
|
866
|
-
}
|
|
1746
|
+
positionDiff = newPosition - prevPosition;
|
|
867
1747
|
}
|
|
868
1748
|
}
|
|
1749
|
+
if (positionDiff !== void 0 && Math.abs(positionDiff) > 0.1) {
|
|
1750
|
+
requestAdjust(ctx, state, positionDiff);
|
|
1751
|
+
}
|
|
869
1752
|
};
|
|
870
1753
|
}
|
|
871
1754
|
|
|
@@ -874,10 +1757,10 @@ function setPaddingTop(ctx, state, { stylePaddingTop, alignItemsPaddingTop }) {
|
|
|
874
1757
|
if (stylePaddingTop !== void 0) {
|
|
875
1758
|
const prevStylePaddingTop = peek$(ctx, "stylePaddingTop") || 0;
|
|
876
1759
|
if (stylePaddingTop < prevStylePaddingTop) {
|
|
877
|
-
let prevTotalSize = peek$(ctx, "totalSize");
|
|
1760
|
+
let prevTotalSize = peek$(ctx, "totalSize") || 0;
|
|
878
1761
|
set$(ctx, "totalSize", prevTotalSize + prevStylePaddingTop);
|
|
879
1762
|
state.timeoutSetPaddingTop = setTimeout(() => {
|
|
880
|
-
prevTotalSize = peek$(ctx, "totalSize");
|
|
1763
|
+
prevTotalSize = peek$(ctx, "totalSize") || 0;
|
|
881
1764
|
set$(ctx, "totalSize", prevTotalSize - prevStylePaddingTop);
|
|
882
1765
|
}, 16);
|
|
883
1766
|
}
|
|
@@ -941,43 +1824,6 @@ function addTotalSize(ctx, state, key, add) {
|
|
|
941
1824
|
}
|
|
942
1825
|
}
|
|
943
1826
|
|
|
944
|
-
// src/utils/getScrollVelocity.ts
|
|
945
|
-
var getScrollVelocity = (state) => {
|
|
946
|
-
const { scrollHistory } = state;
|
|
947
|
-
let velocity = 0;
|
|
948
|
-
if (scrollHistory.length >= 1) {
|
|
949
|
-
const newest = scrollHistory[scrollHistory.length - 1];
|
|
950
|
-
let oldest;
|
|
951
|
-
let start = 0;
|
|
952
|
-
for (let i = 0; i < scrollHistory.length - 1; i++) {
|
|
953
|
-
const entry = scrollHistory[i];
|
|
954
|
-
const nextEntry = scrollHistory[i + 1];
|
|
955
|
-
if (i > 0) {
|
|
956
|
-
const prevEntry = scrollHistory[i - 1];
|
|
957
|
-
const prevDirection = entry.scroll - prevEntry.scroll;
|
|
958
|
-
const currentDirection = nextEntry.scroll - entry.scroll;
|
|
959
|
-
if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
|
|
960
|
-
start = i;
|
|
961
|
-
break;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
for (let i = start; i < scrollHistory.length - 1; i++) {
|
|
966
|
-
const entry = scrollHistory[i];
|
|
967
|
-
if (newest.time - entry.time <= 1e3) {
|
|
968
|
-
oldest = entry;
|
|
969
|
-
break;
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
if (oldest) {
|
|
973
|
-
const scrollDiff = newest.scroll - oldest.scroll;
|
|
974
|
-
const timeDiff = newest.time - oldest.time;
|
|
975
|
-
velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
return velocity;
|
|
979
|
-
};
|
|
980
|
-
|
|
981
1827
|
// src/utils/updateSnapToOffsets.ts
|
|
982
1828
|
function updateSnapToOffsets(ctx, state) {
|
|
983
1829
|
const {
|
|
@@ -994,69 +1840,42 @@ function updateSnapToOffsets(ctx, state) {
|
|
|
994
1840
|
}
|
|
995
1841
|
|
|
996
1842
|
// src/core/updateAllPositions.ts
|
|
997
|
-
function updateAllPositions(ctx, state, dataChanged) {
|
|
998
|
-
var _a, _b, _c, _d, _e;
|
|
1843
|
+
function updateAllPositions(ctx, state, dataChanged, startIndex = 0) {
|
|
1844
|
+
var _a, _b, _c, _d, _e, _f;
|
|
999
1845
|
const {
|
|
1000
|
-
averageSizes,
|
|
1001
1846
|
columns,
|
|
1002
1847
|
indexByKey,
|
|
1003
1848
|
positions,
|
|
1004
|
-
firstFullyOnScreenIndex,
|
|
1005
1849
|
idCache,
|
|
1006
1850
|
sizesKnown,
|
|
1007
|
-
props: { snapToIndices }
|
|
1851
|
+
props: { getEstimatedItemSize, snapToIndices, enableAverages }
|
|
1008
1852
|
} = state;
|
|
1009
1853
|
const data = state.props.data;
|
|
1010
1854
|
const numColumns = peek$(ctx, "numColumns");
|
|
1011
1855
|
const indexByKeyForChecking = __DEV__ ? /* @__PURE__ */ new Map() : void 0;
|
|
1012
|
-
const
|
|
1013
|
-
if (dataChanged) {
|
|
1014
|
-
indexByKey.clear();
|
|
1015
|
-
idCache.clear();
|
|
1016
|
-
}
|
|
1017
|
-
const itemType = "";
|
|
1018
|
-
let averageSize = (_a = averageSizes[itemType]) == null ? void 0 : _a.avg;
|
|
1019
|
-
if (averageSize !== void 0) {
|
|
1020
|
-
averageSize = roundSize(averageSize);
|
|
1021
|
-
}
|
|
1022
|
-
const shouldUseBackwards = !dataChanged && scrollVelocity < 0 && firstFullyOnScreenIndex > 5 && firstFullyOnScreenIndex < data.length;
|
|
1023
|
-
if (shouldUseBackwards && firstFullyOnScreenIndex !== void 0) {
|
|
1024
|
-
const anchorId = getId(state, firstFullyOnScreenIndex);
|
|
1025
|
-
const anchorPosition = positions.get(anchorId);
|
|
1026
|
-
if (anchorPosition !== void 0) {
|
|
1027
|
-
let currentRowTop2 = anchorPosition;
|
|
1028
|
-
let maxSizeInRow2 = 0;
|
|
1029
|
-
let bailout = false;
|
|
1030
|
-
for (let i = firstFullyOnScreenIndex - 1; i >= 0; i--) {
|
|
1031
|
-
const id = (_b = idCache.get(i)) != null ? _b : getId(state, i);
|
|
1032
|
-
const size = (_c = sizesKnown.get(id)) != null ? _c : getItemSize(state, id, i, data[i], averageSize);
|
|
1033
|
-
const itemColumn = columns.get(id);
|
|
1034
|
-
maxSizeInRow2 = Math.max(maxSizeInRow2, size);
|
|
1035
|
-
if (itemColumn === 1) {
|
|
1036
|
-
currentRowTop2 -= maxSizeInRow2;
|
|
1037
|
-
maxSizeInRow2 = 0;
|
|
1038
|
-
}
|
|
1039
|
-
if (currentRowTop2 < -2e3) {
|
|
1040
|
-
bailout = true;
|
|
1041
|
-
break;
|
|
1042
|
-
}
|
|
1043
|
-
positions.set(id, currentRowTop2);
|
|
1044
|
-
}
|
|
1045
|
-
if (!bailout) {
|
|
1046
|
-
updateTotalSize(ctx, state);
|
|
1047
|
-
return;
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1856
|
+
const useAverageSize = enableAverages && !getEstimatedItemSize;
|
|
1051
1857
|
let currentRowTop = 0;
|
|
1052
1858
|
let column = 1;
|
|
1053
1859
|
let maxSizeInRow = 0;
|
|
1054
1860
|
const hasColumns = numColumns > 1;
|
|
1861
|
+
if (startIndex > 0) {
|
|
1862
|
+
const prevIndex = startIndex - 1;
|
|
1863
|
+
const prevId = (_a = idCache.get(prevIndex)) != null ? _a : getId(state, prevIndex);
|
|
1864
|
+
const prevPosition = (_b = positions.get(prevId)) != null ? _b : 0;
|
|
1865
|
+
if (hasColumns) {
|
|
1866
|
+
const prevColumn = (_c = columns.get(prevId)) != null ? _c : 1;
|
|
1867
|
+
currentRowTop = prevPosition;
|
|
1868
|
+
column = prevColumn % numColumns + 1;
|
|
1869
|
+
} else {
|
|
1870
|
+
const prevSize = (_d = sizesKnown.get(prevId)) != null ? _d : getItemSize(state, prevId, prevIndex, data[prevIndex], useAverageSize);
|
|
1871
|
+
currentRowTop = prevPosition + prevSize;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1055
1874
|
const needsIndexByKey = dataChanged || indexByKey.size === 0;
|
|
1056
1875
|
const dataLength = data.length;
|
|
1057
|
-
for (let i =
|
|
1058
|
-
const id = (
|
|
1059
|
-
const size = (
|
|
1876
|
+
for (let i = startIndex; i < dataLength; i++) {
|
|
1877
|
+
const id = (_e = idCache.get(i)) != null ? _e : getId(state, i);
|
|
1878
|
+
const size = (_f = sizesKnown.get(id)) != null ? _f : getItemSize(state, id, i, data[i], useAverageSize);
|
|
1060
1879
|
if (__DEV__ && needsIndexByKey) {
|
|
1061
1880
|
if (indexByKeyForChecking.has(id)) {
|
|
1062
1881
|
console.error(
|
|
@@ -1091,32 +1910,18 @@ function updateAllPositions(ctx, state, dataChanged) {
|
|
|
1091
1910
|
}
|
|
1092
1911
|
|
|
1093
1912
|
// src/core/viewability.ts
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
...viewabilityConfigCallbackPairs || [],
|
|
1100
|
-
{
|
|
1101
|
-
onViewableItemsChanged,
|
|
1102
|
-
viewabilityConfig: viewabilityConfig || {
|
|
1103
|
-
viewAreaCoveragePercentThreshold: 0
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
];
|
|
1913
|
+
function ensureViewabilityState(ctx, configId) {
|
|
1914
|
+
let map = ctx.mapViewabilityConfigStates;
|
|
1915
|
+
if (!map) {
|
|
1916
|
+
map = /* @__PURE__ */ new Map();
|
|
1917
|
+
ctx.mapViewabilityConfigStates = map;
|
|
1107
1918
|
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
previousEnd: -1,
|
|
1113
|
-
previousStart: -1,
|
|
1114
|
-
start: -1,
|
|
1115
|
-
viewableItems: []
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1919
|
+
let state = map.get(configId);
|
|
1920
|
+
if (!state) {
|
|
1921
|
+
state = { end: -1, previousEnd: -1, previousStart: -1, start: -1, viewableItems: [] };
|
|
1922
|
+
map.set(configId, state);
|
|
1118
1923
|
}
|
|
1119
|
-
return
|
|
1924
|
+
return state;
|
|
1120
1925
|
}
|
|
1121
1926
|
function updateViewableItems(state, ctx, viewabilityConfigCallbackPairs, scrollSize, start, end) {
|
|
1122
1927
|
const {
|
|
@@ -1124,9 +1929,7 @@ function updateViewableItems(state, ctx, viewabilityConfigCallbackPairs, scrollS
|
|
|
1124
1929
|
props: { data }
|
|
1125
1930
|
} = state;
|
|
1126
1931
|
for (const viewabilityConfigCallbackPair of viewabilityConfigCallbackPairs) {
|
|
1127
|
-
const viewabilityState =
|
|
1128
|
-
viewabilityConfigCallbackPair.viewabilityConfig.id
|
|
1129
|
-
);
|
|
1932
|
+
const viewabilityState = ensureViewabilityState(ctx, viewabilityConfigCallbackPair.viewabilityConfig.id);
|
|
1130
1933
|
viewabilityState.start = start;
|
|
1131
1934
|
viewabilityState.end = end;
|
|
1132
1935
|
if (viewabilityConfigCallbackPair.viewabilityConfig.minimumViewTime) {
|
|
@@ -1143,7 +1946,7 @@ function updateViewableItems(state, ctx, viewabilityConfigCallbackPairs, scrollS
|
|
|
1143
1946
|
function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, state, ctx, scrollSize) {
|
|
1144
1947
|
const { viewabilityConfig, onViewableItemsChanged } = viewabilityConfigCallbackPair;
|
|
1145
1948
|
const configId = viewabilityConfig.id;
|
|
1146
|
-
const viewabilityState =
|
|
1949
|
+
const viewabilityState = ensureViewabilityState(ctx, configId);
|
|
1147
1950
|
const { viewableItems: previousViewableItems, start, end } = viewabilityState;
|
|
1148
1951
|
const viewabilityTokens = /* @__PURE__ */ new Map();
|
|
1149
1952
|
for (const [containerId, value] of ctx.mapViewabilityAmountValues) {
|
|
@@ -1222,6 +2025,15 @@ function updateViewableItemsWithConfig(data, viewabilityConfigCallbackPair, stat
|
|
|
1222
2025
|
}
|
|
1223
2026
|
}
|
|
1224
2027
|
}
|
|
2028
|
+
function shallowEqual(prev, next) {
|
|
2029
|
+
if (!prev) return false;
|
|
2030
|
+
const keys = Object.keys(next);
|
|
2031
|
+
for (let i = 0; i < keys.length; i++) {
|
|
2032
|
+
const k = keys[i];
|
|
2033
|
+
if (prev[k] !== next[k]) return false;
|
|
2034
|
+
}
|
|
2035
|
+
return true;
|
|
2036
|
+
}
|
|
1225
2037
|
function computeViewability(state, ctx, viewabilityConfig, containerId, key, scrollSize, item, index) {
|
|
1226
2038
|
const { sizes, positions, scroll: scrollState } = state;
|
|
1227
2039
|
const topPad = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
@@ -1250,7 +2062,8 @@ function computeViewability(state, ctx, viewabilityConfig, containerId, key, scr
|
|
|
1250
2062
|
size,
|
|
1251
2063
|
sizeVisible
|
|
1252
2064
|
};
|
|
1253
|
-
|
|
2065
|
+
const prev = ctx.mapViewabilityAmountValues.get(containerId);
|
|
2066
|
+
if (!shallowEqual(prev, value)) {
|
|
1254
2067
|
ctx.mapViewabilityAmountValues.set(containerId, value);
|
|
1255
2068
|
const cb = ctx.mapViewabilityAmountCallbacks.get(containerId);
|
|
1256
2069
|
if (cb) {
|
|
@@ -1280,10 +2093,13 @@ function maybeUpdateViewabilityCallback(ctx, configId, containerId, viewToken) {
|
|
|
1280
2093
|
cb == null ? void 0 : cb(viewToken);
|
|
1281
2094
|
}
|
|
1282
2095
|
|
|
2096
|
+
// src/platform/batchedUpdates.ts
|
|
2097
|
+
var import_react_dom = __toESM(require_react_dom());
|
|
2098
|
+
|
|
1283
2099
|
// src/utils/checkAllSizesKnown.ts
|
|
1284
2100
|
function checkAllSizesKnown(state) {
|
|
1285
2101
|
const { startBuffered, endBuffered, sizesKnown } = state;
|
|
1286
|
-
if (endBuffered !== null) {
|
|
2102
|
+
if (endBuffered !== null && startBuffered >= 0 && endBuffered >= 0) {
|
|
1287
2103
|
let areAllKnown = true;
|
|
1288
2104
|
for (let i = startBuffered; areAllKnown && i <= endBuffered; i++) {
|
|
1289
2105
|
const key = getId(state, i);
|
|
@@ -1295,35 +2111,79 @@ function checkAllSizesKnown(state) {
|
|
|
1295
2111
|
}
|
|
1296
2112
|
|
|
1297
2113
|
// src/utils/findAvailableContainers.ts
|
|
1298
|
-
function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffered, pendingRemoval) {
|
|
2114
|
+
function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffered, pendingRemoval, requiredItemTypes, needNewContainers) {
|
|
1299
2115
|
const numContainers = peek$(ctx, "numContainers");
|
|
2116
|
+
const { stickyContainerPool, containerItemTypes } = state;
|
|
1300
2117
|
const result = [];
|
|
1301
2118
|
const availableContainers = [];
|
|
1302
|
-
|
|
2119
|
+
const stickyIndicesSet = state.props.stickyIndicesSet;
|
|
2120
|
+
const stickyItemIndices = (needNewContainers == null ? void 0 : needNewContainers.filter((index) => stickyIndicesSet.has(index))) || [];
|
|
2121
|
+
const canReuseContainer = (containerIndex, requiredType) => {
|
|
2122
|
+
if (!requiredType) return true;
|
|
2123
|
+
const existingType = containerItemTypes.get(containerIndex);
|
|
2124
|
+
if (!existingType) return true;
|
|
2125
|
+
return existingType === requiredType;
|
|
2126
|
+
};
|
|
2127
|
+
const neededTypes = requiredItemTypes ? [...requiredItemTypes] : [];
|
|
2128
|
+
let typeIndex = 0;
|
|
2129
|
+
for (let i = 0; i < stickyItemIndices.length; i++) {
|
|
2130
|
+
const requiredType = neededTypes[typeIndex];
|
|
2131
|
+
let foundContainer = false;
|
|
2132
|
+
for (const containerIndex of stickyContainerPool) {
|
|
2133
|
+
const key = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
2134
|
+
const isPendingRemoval = pendingRemoval.includes(containerIndex);
|
|
2135
|
+
if ((key === void 0 || isPendingRemoval) && canReuseContainer(containerIndex, requiredType)) {
|
|
2136
|
+
result.push(containerIndex);
|
|
2137
|
+
if (isPendingRemoval) {
|
|
2138
|
+
const index = pendingRemoval.indexOf(containerIndex);
|
|
2139
|
+
pendingRemoval.splice(index, 1);
|
|
2140
|
+
}
|
|
2141
|
+
foundContainer = true;
|
|
2142
|
+
if (requiredItemTypes) typeIndex++;
|
|
2143
|
+
break;
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
if (!foundContainer) {
|
|
2147
|
+
const newContainerIndex = numContainers + result.filter((index) => index >= numContainers).length;
|
|
2148
|
+
result.push(newContainerIndex);
|
|
2149
|
+
stickyContainerPool.add(newContainerIndex);
|
|
2150
|
+
if (requiredItemTypes) typeIndex++;
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
|
|
2154
|
+
if (stickyContainerPool.has(u)) {
|
|
2155
|
+
continue;
|
|
2156
|
+
}
|
|
1303
2157
|
const key = peek$(ctx, `containerItemKey${u}`);
|
|
1304
2158
|
let isOk = key === void 0;
|
|
1305
2159
|
if (!isOk) {
|
|
1306
2160
|
const index = pendingRemoval.indexOf(u);
|
|
1307
2161
|
if (index !== -1) {
|
|
1308
2162
|
pendingRemoval.splice(index, 1);
|
|
1309
|
-
|
|
2163
|
+
const requiredType = neededTypes[typeIndex];
|
|
2164
|
+
isOk = canReuseContainer(u, requiredType);
|
|
1310
2165
|
}
|
|
1311
2166
|
}
|
|
1312
2167
|
if (isOk) {
|
|
1313
2168
|
result.push(u);
|
|
1314
|
-
if (
|
|
1315
|
-
|
|
2169
|
+
if (requiredItemTypes) {
|
|
2170
|
+
typeIndex++;
|
|
1316
2171
|
}
|
|
1317
2172
|
}
|
|
1318
2173
|
}
|
|
1319
|
-
for (let u = 0; u < numContainers; u++) {
|
|
2174
|
+
for (let u = 0; u < numContainers && result.length < numNeeded; u++) {
|
|
2175
|
+
if (stickyContainerPool.has(u)) {
|
|
2176
|
+
continue;
|
|
2177
|
+
}
|
|
1320
2178
|
const key = peek$(ctx, `containerItemKey${u}`);
|
|
1321
2179
|
if (key === void 0) continue;
|
|
1322
2180
|
const index = state.indexByKey.get(key);
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
2181
|
+
const isOutOfView = index < startBuffered || index > endBuffered;
|
|
2182
|
+
if (isOutOfView) {
|
|
2183
|
+
const distance = index < startBuffered ? startBuffered - index : index - endBuffered;
|
|
2184
|
+
if (!requiredItemTypes || typeIndex < neededTypes.length && canReuseContainer(u, neededTypes[typeIndex])) {
|
|
2185
|
+
availableContainers.push({ distance, index: u });
|
|
2186
|
+
}
|
|
1327
2187
|
}
|
|
1328
2188
|
}
|
|
1329
2189
|
const remaining = numNeeded - result.length;
|
|
@@ -1335,6 +2195,9 @@ function findAvailableContainers(ctx, state, numNeeded, startBuffered, endBuffer
|
|
|
1335
2195
|
}
|
|
1336
2196
|
for (const container of availableContainers) {
|
|
1337
2197
|
result.push(container.index);
|
|
2198
|
+
if (requiredItemTypes) {
|
|
2199
|
+
typeIndex++;
|
|
2200
|
+
}
|
|
1338
2201
|
}
|
|
1339
2202
|
}
|
|
1340
2203
|
const stillNeeded = numNeeded - result.length;
|
|
@@ -1363,37 +2226,44 @@ function comparatorByDistance(a, b) {
|
|
|
1363
2226
|
return b.distance - a.distance;
|
|
1364
2227
|
}
|
|
1365
2228
|
|
|
1366
|
-
// src/
|
|
1367
|
-
var
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
2229
|
+
// src/utils/getScrollVelocity.ts
|
|
2230
|
+
var getScrollVelocity = (state) => {
|
|
2231
|
+
const { scrollHistory } = state;
|
|
2232
|
+
let velocity = 0;
|
|
2233
|
+
if (scrollHistory.length >= 1) {
|
|
2234
|
+
const newest = scrollHistory[scrollHistory.length - 1];
|
|
2235
|
+
let oldest;
|
|
2236
|
+
let start = 0;
|
|
2237
|
+
const now = Date.now();
|
|
2238
|
+
for (let i = 0; i < scrollHistory.length - 1; i++) {
|
|
2239
|
+
const entry = scrollHistory[i];
|
|
2240
|
+
const nextEntry = scrollHistory[i + 1];
|
|
2241
|
+
if (i > 0) {
|
|
2242
|
+
const prevEntry = scrollHistory[i - 1];
|
|
2243
|
+
const prevDirection = entry.scroll - prevEntry.scroll;
|
|
2244
|
+
const currentDirection = nextEntry.scroll - entry.scroll;
|
|
2245
|
+
if (prevDirection > 0 && currentDirection < 0 || prevDirection < 0 && currentDirection > 0) {
|
|
2246
|
+
start = i;
|
|
2247
|
+
break;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
for (let i = start; i < scrollHistory.length - 1; i++) {
|
|
2252
|
+
const entry = scrollHistory[i];
|
|
2253
|
+
if (now - entry.time <= 1e3) {
|
|
2254
|
+
oldest = entry;
|
|
2255
|
+
break;
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
if (oldest && oldest !== newest) {
|
|
2259
|
+
const scrollDiff = newest.scroll - oldest.scroll;
|
|
2260
|
+
const timeDiff = newest.time - oldest.time;
|
|
2261
|
+
velocity = timeDiff > 0 ? scrollDiff / timeDiff : 0;
|
|
2262
|
+
}
|
|
1371
2263
|
}
|
|
2264
|
+
return velocity;
|
|
1372
2265
|
};
|
|
1373
2266
|
|
|
1374
|
-
// src/core/scrollTo.ts
|
|
1375
|
-
function scrollTo(state, params = {}) {
|
|
1376
|
-
var _a;
|
|
1377
|
-
const { animated } = params;
|
|
1378
|
-
const {
|
|
1379
|
-
refScroller,
|
|
1380
|
-
props: { horizontal }
|
|
1381
|
-
} = state;
|
|
1382
|
-
const offset = calculateOffsetWithOffsetPosition(state, params.offset, params);
|
|
1383
|
-
state.scrollHistory.length = 0;
|
|
1384
|
-
state.scrollingTo = params;
|
|
1385
|
-
state.scrollPending = offset;
|
|
1386
|
-
(_a = refScroller.current) == null ? void 0 : _a.scrollTo({
|
|
1387
|
-
animated: !!animated,
|
|
1388
|
-
x: horizontal ? offset : 0,
|
|
1389
|
-
y: horizontal ? 0 : offset
|
|
1390
|
-
});
|
|
1391
|
-
if (!animated) {
|
|
1392
|
-
state.scroll = offset;
|
|
1393
|
-
setTimeout(() => finishScrollTo(state), 100);
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
2267
|
// src/core/scrollToIndex.ts
|
|
1398
2268
|
function scrollToIndex(ctx, state, { index, viewOffset = 0, animated = true, viewPosition }) {
|
|
1399
2269
|
if (index >= state.props.data.length) {
|
|
@@ -1481,33 +2351,101 @@ function setDidLayout(ctx, state) {
|
|
|
1481
2351
|
} = state;
|
|
1482
2352
|
state.queuedInitialLayout = true;
|
|
1483
2353
|
checkAtBottom(ctx, state);
|
|
1484
|
-
|
|
1485
|
-
|
|
2354
|
+
const setIt = () => {
|
|
2355
|
+
set$(ctx, "containersDidLayout", true);
|
|
2356
|
+
if (onLoad) {
|
|
2357
|
+
onLoad({ elapsedTimeInMs: Date.now() - loadStartTime });
|
|
2358
|
+
}
|
|
2359
|
+
};
|
|
2360
|
+
{
|
|
2361
|
+
setIt();
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
// src/core/calculateItemsInView.ts
|
|
2366
|
+
function findCurrentStickyIndex(stickyArray, scroll, state) {
|
|
2367
|
+
var _a;
|
|
2368
|
+
const idCache = state.idCache;
|
|
2369
|
+
const positions = state.positions;
|
|
2370
|
+
for (let i = stickyArray.length - 1; i >= 0; i--) {
|
|
2371
|
+
const stickyId = (_a = idCache.get(stickyArray[i])) != null ? _a : getId(state, stickyArray[i]);
|
|
2372
|
+
const stickyPos = stickyId ? positions.get(stickyId) : void 0;
|
|
2373
|
+
if (stickyPos !== void 0 && scroll >= stickyPos) {
|
|
2374
|
+
return i;
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
return -1;
|
|
2378
|
+
}
|
|
2379
|
+
function getActiveStickyIndices(ctx, state, stickyIndices) {
|
|
2380
|
+
return new Set(
|
|
2381
|
+
Array.from(state.stickyContainerPool).map((i) => peek$(ctx, `containerItemKey${i}`)).map((key) => key ? state.indexByKey.get(key) : void 0).filter((idx) => idx !== void 0 && stickyIndices.has(idx))
|
|
2382
|
+
);
|
|
2383
|
+
}
|
|
2384
|
+
function handleStickyActivation(ctx, state, stickyIndices, stickyArray, scroll, needNewContainers, startBuffered, endBuffered) {
|
|
2385
|
+
var _a;
|
|
2386
|
+
const activeIndices = getActiveStickyIndices(ctx, state, stickyIndices);
|
|
2387
|
+
const currentStickyIdx = findCurrentStickyIndex(stickyArray, scroll, state);
|
|
2388
|
+
for (let offset = 0; offset <= 1; offset++) {
|
|
2389
|
+
const idx = currentStickyIdx - offset;
|
|
2390
|
+
if (idx < 0 || activeIndices.has(stickyArray[idx])) continue;
|
|
2391
|
+
const stickyIndex = stickyArray[idx];
|
|
2392
|
+
const stickyId = (_a = state.idCache.get(stickyIndex)) != null ? _a : getId(state, stickyIndex);
|
|
2393
|
+
if (stickyId && !state.containerItemKeys.has(stickyId) && (stickyIndex < startBuffered || stickyIndex > endBuffered)) {
|
|
2394
|
+
needNewContainers.push(stickyIndex);
|
|
2395
|
+
}
|
|
1486
2396
|
}
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
2397
|
+
}
|
|
2398
|
+
function handleStickyRecycling(ctx, state, stickyArray, scroll, scrollBuffer, pendingRemoval) {
|
|
2399
|
+
var _a, _b, _c;
|
|
2400
|
+
const currentStickyIdx = findCurrentStickyIndex(stickyArray, scroll, state);
|
|
2401
|
+
for (const containerIndex of state.stickyContainerPool) {
|
|
2402
|
+
const itemKey = peek$(ctx, `containerItemKey${containerIndex}`);
|
|
2403
|
+
const itemIndex = itemKey ? state.indexByKey.get(itemKey) : void 0;
|
|
2404
|
+
if (itemIndex === void 0) continue;
|
|
2405
|
+
const arrayIdx = stickyArray.indexOf(itemIndex);
|
|
2406
|
+
if (arrayIdx === -1) continue;
|
|
2407
|
+
const isRecentSticky = arrayIdx >= currentStickyIdx - 1 && arrayIdx <= currentStickyIdx + 1;
|
|
2408
|
+
if (isRecentSticky) continue;
|
|
2409
|
+
const nextIndex = stickyArray[arrayIdx + 1];
|
|
2410
|
+
let shouldRecycle = false;
|
|
2411
|
+
if (nextIndex) {
|
|
2412
|
+
const nextId = (_a = state.idCache.get(nextIndex)) != null ? _a : getId(state, nextIndex);
|
|
2413
|
+
const nextPos = nextId ? state.positions.get(nextId) : void 0;
|
|
2414
|
+
shouldRecycle = nextPos !== void 0 && scroll > nextPos + scrollBuffer * 2;
|
|
2415
|
+
} else {
|
|
2416
|
+
const currentId = (_b = state.idCache.get(itemIndex)) != null ? _b : getId(state, itemIndex);
|
|
2417
|
+
if (currentId) {
|
|
2418
|
+
const currentPos = state.positions.get(currentId);
|
|
2419
|
+
const currentSize = (_c = state.sizes.get(currentId)) != null ? _c : getItemSize(state, currentId, itemIndex, state.props.data[itemIndex]);
|
|
2420
|
+
shouldRecycle = currentPos !== void 0 && scroll > currentPos + currentSize + scrollBuffer * 3;
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
if (shouldRecycle) {
|
|
2424
|
+
pendingRemoval.push(containerIndex);
|
|
2425
|
+
}
|
|
1490
2426
|
}
|
|
1491
2427
|
}
|
|
1492
|
-
|
|
1493
|
-
// src/core/calculateItemsInView.ts
|
|
1494
2428
|
function calculateItemsInView(ctx, state, params = {}) {
|
|
1495
|
-
|
|
2429
|
+
(0, import_react_dom.unstable_batchedUpdates)(() => {
|
|
1496
2430
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1497
2431
|
const {
|
|
1498
|
-
scrollLength,
|
|
1499
|
-
startBufferedId: startBufferedIdOrig,
|
|
1500
|
-
positions,
|
|
1501
2432
|
columns,
|
|
1502
2433
|
containerItemKeys,
|
|
2434
|
+
enableScrollForNextCalculateItemsInView,
|
|
1503
2435
|
idCache,
|
|
1504
|
-
sizes,
|
|
1505
2436
|
indexByKey,
|
|
2437
|
+
minIndexSizeChanged,
|
|
2438
|
+
positions,
|
|
1506
2439
|
scrollForNextCalculateItemsInView,
|
|
1507
|
-
|
|
1508
|
-
|
|
2440
|
+
scrollLength,
|
|
2441
|
+
sizes,
|
|
2442
|
+
startBufferedId: startBufferedIdOrig,
|
|
2443
|
+
viewabilityConfigCallbackPairs,
|
|
2444
|
+
props: { getItemType, initialScroll, itemsAreEqual, keyExtractor, scrollBuffer }
|
|
1509
2445
|
} = state;
|
|
1510
|
-
const data = state.props
|
|
2446
|
+
const { data } = state.props;
|
|
2447
|
+
const stickyIndicesArr = state.props.stickyIndicesArr || [];
|
|
2448
|
+
const stickyIndicesSet = state.props.stickyIndicesSet || /* @__PURE__ */ new Set();
|
|
1511
2449
|
const prevNumContainers = peek$(ctx, "numContainers");
|
|
1512
2450
|
if (!data || scrollLength === 0 || !prevNumContainers) {
|
|
1513
2451
|
return;
|
|
@@ -1519,14 +2457,22 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1519
2457
|
const { dataChanged, doMVCP } = params;
|
|
1520
2458
|
const speed = getScrollVelocity(state);
|
|
1521
2459
|
if (doMVCP || dataChanged) {
|
|
1522
|
-
const checkMVCP = doMVCP ? prepareMVCP(ctx, state) : void 0;
|
|
1523
|
-
|
|
2460
|
+
const checkMVCP = doMVCP ? prepareMVCP(ctx, state, dataChanged) : void 0;
|
|
2461
|
+
if (dataChanged) {
|
|
2462
|
+
indexByKey.clear();
|
|
2463
|
+
idCache.clear();
|
|
2464
|
+
positions.clear();
|
|
2465
|
+
}
|
|
2466
|
+
const startIndex = dataChanged ? 0 : minIndexSizeChanged != null ? minIndexSizeChanged : 0;
|
|
2467
|
+
updateAllPositions(ctx, state, dataChanged, startIndex);
|
|
2468
|
+
if (minIndexSizeChanged !== void 0) {
|
|
2469
|
+
state.minIndexSizeChanged = void 0;
|
|
2470
|
+
}
|
|
1524
2471
|
checkMVCP == null ? void 0 : checkMVCP();
|
|
1525
2472
|
}
|
|
1526
2473
|
const scrollExtra = 0;
|
|
1527
2474
|
const { queuedInitialLayout } = state;
|
|
1528
2475
|
let { scroll: scrollState } = state;
|
|
1529
|
-
const initialScroll = state.props.initialScroll;
|
|
1530
2476
|
if (!queuedInitialLayout && initialScroll) {
|
|
1531
2477
|
const updatedOffset = calculateOffsetWithOffsetPosition(
|
|
1532
2478
|
state,
|
|
@@ -1538,16 +2484,15 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1538
2484
|
const scrollAdjustPad = -previousScrollAdjust - topPad;
|
|
1539
2485
|
let scroll = scrollState + scrollExtra + scrollAdjustPad;
|
|
1540
2486
|
if (scroll + scrollLength > totalSize) {
|
|
1541
|
-
scroll = totalSize - scrollLength;
|
|
2487
|
+
scroll = Math.max(0, totalSize - scrollLength);
|
|
1542
2488
|
}
|
|
1543
2489
|
if (ENABLE_DEBUG_VIEW) {
|
|
1544
2490
|
set$(ctx, "debugRawScroll", scrollState);
|
|
1545
2491
|
set$(ctx, "debugComputedScroll", scroll);
|
|
1546
2492
|
}
|
|
1547
|
-
const scrollBuffer = state.props.scrollBuffer;
|
|
1548
2493
|
let scrollBufferTop = scrollBuffer;
|
|
1549
2494
|
let scrollBufferBottom = scrollBuffer;
|
|
1550
|
-
if (speed > 0) {
|
|
2495
|
+
if (speed > 0 || speed === 0 && scroll < Math.max(50, scrollBuffer)) {
|
|
1551
2496
|
scrollBufferTop = scrollBuffer * 0.5;
|
|
1552
2497
|
scrollBufferBottom = scrollBuffer * 1.5;
|
|
1553
2498
|
} else {
|
|
@@ -1555,7 +2500,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1555
2500
|
scrollBufferBottom = scrollBuffer * 0.5;
|
|
1556
2501
|
}
|
|
1557
2502
|
const scrollTopBuffered = scroll - scrollBufferTop;
|
|
1558
|
-
const scrollBottom = scroll + scrollLength;
|
|
2503
|
+
const scrollBottom = scroll + scrollLength + (scroll < 0 ? -scroll : 0);
|
|
1559
2504
|
const scrollBottomBuffered = scrollBottom + scrollBufferBottom;
|
|
1560
2505
|
if (scrollForNextCalculateItemsInView) {
|
|
1561
2506
|
const { top, bottom } = scrollForNextCalculateItemsInView;
|
|
@@ -1569,10 +2514,6 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1569
2514
|
let endNoBuffer = null;
|
|
1570
2515
|
let endBuffered = null;
|
|
1571
2516
|
let loopStart = startBufferedIdOrig ? indexByKey.get(startBufferedIdOrig) || 0 : 0;
|
|
1572
|
-
if (minIndexSizeChanged !== void 0) {
|
|
1573
|
-
loopStart = Math.min(minIndexSizeChanged, loopStart);
|
|
1574
|
-
state.minIndexSizeChanged = void 0;
|
|
1575
|
-
}
|
|
1576
2517
|
for (let i = loopStart; i >= 0; i--) {
|
|
1577
2518
|
const id = (_a = idCache.get(i)) != null ? _a : getId(state, i);
|
|
1578
2519
|
const top = positions.get(id);
|
|
@@ -1655,7 +2596,7 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1655
2596
|
if (dataChanged) {
|
|
1656
2597
|
for (let i = 0; i < numContainers; i++) {
|
|
1657
2598
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1658
|
-
if (!
|
|
2599
|
+
if (!keyExtractor || itemKey && indexByKey.get(itemKey) === void 0) {
|
|
1659
2600
|
pendingRemoval.push(i);
|
|
1660
2601
|
}
|
|
1661
2602
|
}
|
|
@@ -1669,14 +2610,32 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1669
2610
|
needNewContainers.push(i);
|
|
1670
2611
|
}
|
|
1671
2612
|
}
|
|
2613
|
+
if (stickyIndicesArr.length > 0) {
|
|
2614
|
+
handleStickyActivation(
|
|
2615
|
+
ctx,
|
|
2616
|
+
state,
|
|
2617
|
+
stickyIndicesSet,
|
|
2618
|
+
stickyIndicesArr,
|
|
2619
|
+
scroll,
|
|
2620
|
+
needNewContainers,
|
|
2621
|
+
startBuffered,
|
|
2622
|
+
endBuffered
|
|
2623
|
+
);
|
|
2624
|
+
}
|
|
1672
2625
|
if (needNewContainers.length > 0) {
|
|
2626
|
+
const requiredItemTypes = getItemType ? needNewContainers.map((i) => {
|
|
2627
|
+
const itemType = getItemType(data[i], i);
|
|
2628
|
+
return itemType ? String(itemType) : "";
|
|
2629
|
+
}) : void 0;
|
|
1673
2630
|
const availableContainers = findAvailableContainers(
|
|
1674
2631
|
ctx,
|
|
1675
2632
|
state,
|
|
1676
2633
|
needNewContainers.length,
|
|
1677
2634
|
startBuffered,
|
|
1678
2635
|
endBuffered,
|
|
1679
|
-
pendingRemoval
|
|
2636
|
+
pendingRemoval,
|
|
2637
|
+
requiredItemTypes,
|
|
2638
|
+
needNewContainers
|
|
1680
2639
|
);
|
|
1681
2640
|
for (let idx = 0; idx < needNewContainers.length; idx++) {
|
|
1682
2641
|
const i = needNewContainers[idx];
|
|
@@ -1688,7 +2647,18 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1688
2647
|
}
|
|
1689
2648
|
set$(ctx, `containerItemKey${containerIndex}`, id);
|
|
1690
2649
|
set$(ctx, `containerItemData${containerIndex}`, data[i]);
|
|
2650
|
+
if (requiredItemTypes) {
|
|
2651
|
+
state.containerItemTypes.set(containerIndex, requiredItemTypes[idx]);
|
|
2652
|
+
}
|
|
1691
2653
|
containerItemKeys.add(id);
|
|
2654
|
+
if (stickyIndicesSet.has(i)) {
|
|
2655
|
+
set$(ctx, `containerSticky${containerIndex}`, true);
|
|
2656
|
+
const topPadding = (peek$(ctx, "stylePaddingTop") || 0) + (peek$(ctx, "headerSize") || 0);
|
|
2657
|
+
set$(ctx, `containerStickyOffset${containerIndex}`, createAnimatedValue(topPadding));
|
|
2658
|
+
state.stickyContainerPool.add(containerIndex);
|
|
2659
|
+
} else {
|
|
2660
|
+
state.stickyContainerPool.delete(containerIndex);
|
|
2661
|
+
}
|
|
1692
2662
|
if (containerIndex >= numContainers2) {
|
|
1693
2663
|
numContainers2 = containerIndex + 1;
|
|
1694
2664
|
}
|
|
@@ -1701,12 +2671,22 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1701
2671
|
}
|
|
1702
2672
|
}
|
|
1703
2673
|
}
|
|
2674
|
+
if (stickyIndicesArr.length > 0) {
|
|
2675
|
+
handleStickyRecycling(ctx, state, stickyIndicesArr, scroll, scrollBuffer, pendingRemoval);
|
|
2676
|
+
}
|
|
2677
|
+
let didChangePositions = false;
|
|
1704
2678
|
for (let i = 0; i < numContainers; i++) {
|
|
1705
2679
|
const itemKey = peek$(ctx, `containerItemKey${i}`);
|
|
1706
2680
|
if (pendingRemoval.includes(i)) {
|
|
1707
2681
|
if (itemKey) {
|
|
1708
2682
|
containerItemKeys.delete(itemKey);
|
|
1709
2683
|
}
|
|
2684
|
+
state.containerItemTypes.delete(i);
|
|
2685
|
+
if (state.stickyContainerPool.has(i)) {
|
|
2686
|
+
set$(ctx, `containerSticky${i}`, false);
|
|
2687
|
+
set$(ctx, `containerStickyOffset${i}`, void 0);
|
|
2688
|
+
state.stickyContainerPool.delete(i);
|
|
2689
|
+
}
|
|
1710
2690
|
set$(ctx, `containerItemKey${i}`, void 0);
|
|
1711
2691
|
set$(ctx, `containerItemData${i}`, void 0);
|
|
1712
2692
|
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
@@ -1726,58 +2706,75 @@ function calculateItemsInView(ctx, state, params = {}) {
|
|
|
1726
2706
|
const prevData = peek$(ctx, `containerItemData${i}`);
|
|
1727
2707
|
if (position > POSITION_OUT_OF_VIEW && position !== prevPos) {
|
|
1728
2708
|
set$(ctx, `containerPosition${i}`, position);
|
|
2709
|
+
didChangePositions = true;
|
|
1729
2710
|
}
|
|
1730
2711
|
if (column >= 0 && column !== prevColumn) {
|
|
1731
2712
|
set$(ctx, `containerColumn${i}`, column);
|
|
1732
2713
|
}
|
|
1733
|
-
if (prevData !== item) {
|
|
2714
|
+
if (prevData !== item && (itemsAreEqual ? !itemsAreEqual(prevData, item, itemIndex, data) : true)) {
|
|
1734
2715
|
set$(ctx, `containerItemData${i}`, data[itemIndex]);
|
|
1735
2716
|
}
|
|
1736
2717
|
}
|
|
1737
2718
|
}
|
|
1738
2719
|
}
|
|
1739
2720
|
}
|
|
2721
|
+
if (didChangePositions) {
|
|
2722
|
+
set$(ctx, "lastPositionUpdate", Date.now());
|
|
2723
|
+
}
|
|
1740
2724
|
if (!queuedInitialLayout && endBuffered !== null) {
|
|
1741
2725
|
if (checkAllSizesKnown(state)) {
|
|
1742
2726
|
setDidLayout(ctx, state);
|
|
1743
2727
|
}
|
|
1744
2728
|
}
|
|
1745
|
-
if (
|
|
1746
|
-
updateViewableItems(
|
|
1747
|
-
state,
|
|
1748
|
-
ctx,
|
|
1749
|
-
state.viewabilityConfigCallbackPairs,
|
|
1750
|
-
scrollLength,
|
|
1751
|
-
startNoBuffer,
|
|
1752
|
-
endNoBuffer
|
|
1753
|
-
);
|
|
2729
|
+
if (viewabilityConfigCallbackPairs) {
|
|
2730
|
+
updateViewableItems(state, ctx, viewabilityConfigCallbackPairs, scrollLength, startNoBuffer, endNoBuffer);
|
|
1754
2731
|
}
|
|
1755
2732
|
});
|
|
1756
2733
|
}
|
|
1757
2734
|
|
|
1758
2735
|
// src/core/doInitialAllocateContainers.ts
|
|
1759
2736
|
function doInitialAllocateContainers(ctx, state) {
|
|
1760
|
-
|
|
1761
|
-
const
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
2737
|
+
var _a;
|
|
2738
|
+
const {
|
|
2739
|
+
scrollLength,
|
|
2740
|
+
props: {
|
|
2741
|
+
data,
|
|
2742
|
+
getEstimatedItemSize,
|
|
2743
|
+
getFixedItemSize,
|
|
2744
|
+
getItemType,
|
|
2745
|
+
scrollBuffer,
|
|
2746
|
+
numColumns,
|
|
2747
|
+
estimatedItemSize
|
|
2748
|
+
}
|
|
2749
|
+
} = state;
|
|
2750
|
+
const hasContainers = peek$(ctx, "numContainers");
|
|
2751
|
+
if (scrollLength > 0 && data.length > 0 && !hasContainers) {
|
|
2752
|
+
let averageItemSize;
|
|
2753
|
+
const fn = getFixedItemSize || getEstimatedItemSize;
|
|
2754
|
+
if (fn) {
|
|
2755
|
+
let totalSize = 0;
|
|
2756
|
+
const num = Math.min(20, data.length);
|
|
2757
|
+
for (let i = 0; i < num; i++) {
|
|
2758
|
+
totalSize += fn(0, data[0], getItemType ? (_a = getItemType(data[0], 0)) != null ? _a : "" : "");
|
|
2759
|
+
}
|
|
2760
|
+
averageItemSize = totalSize / num;
|
|
2761
|
+
} else {
|
|
2762
|
+
averageItemSize = estimatedItemSize;
|
|
2763
|
+
}
|
|
2764
|
+
const numContainers = Math.ceil((scrollLength + scrollBuffer * 2) / averageItemSize * numColumns);
|
|
1768
2765
|
for (let i = 0; i < numContainers; i++) {
|
|
1769
2766
|
set$(ctx, `containerPosition${i}`, POSITION_OUT_OF_VIEW);
|
|
1770
2767
|
set$(ctx, `containerColumn${i}`, -1);
|
|
1771
2768
|
}
|
|
1772
2769
|
set$(ctx, "numContainers", numContainers);
|
|
1773
2770
|
set$(ctx, "numContainersPooled", numContainers * state.props.initialContainerPoolRatio);
|
|
1774
|
-
if (
|
|
2771
|
+
if (state.lastLayout) {
|
|
1775
2772
|
if (state.props.initialScroll) {
|
|
1776
2773
|
requestAnimationFrame(() => {
|
|
1777
|
-
calculateItemsInView(ctx, state);
|
|
2774
|
+
calculateItemsInView(ctx, state, { dataChanged: true });
|
|
1778
2775
|
});
|
|
1779
2776
|
} else {
|
|
1780
|
-
calculateItemsInView(ctx, state);
|
|
2777
|
+
calculateItemsInView(ctx, state, { dataChanged: true });
|
|
1781
2778
|
}
|
|
1782
2779
|
}
|
|
1783
2780
|
return true;
|
|
@@ -1797,16 +2794,18 @@ function doMaintainScrollAtEnd(ctx, state, animated) {
|
|
|
1797
2794
|
}
|
|
1798
2795
|
requestAnimationFrame(() => {
|
|
1799
2796
|
var _a;
|
|
1800
|
-
state.
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
(
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
2797
|
+
if (state == null ? void 0 : state.isAtEnd) {
|
|
2798
|
+
state.maintainingScrollAtEnd = true;
|
|
2799
|
+
(_a = refScroller.current) == null ? void 0 : _a.scrollToEnd({
|
|
2800
|
+
animated
|
|
2801
|
+
});
|
|
2802
|
+
setTimeout(
|
|
2803
|
+
() => {
|
|
2804
|
+
state.maintainingScrollAtEnd = false;
|
|
2805
|
+
},
|
|
2806
|
+
0
|
|
2807
|
+
);
|
|
2808
|
+
}
|
|
1810
2809
|
});
|
|
1811
2810
|
return true;
|
|
1812
2811
|
}
|
|
@@ -1843,44 +2842,57 @@ function checkAtTop(state) {
|
|
|
1843
2842
|
// src/core/handleLayout.ts
|
|
1844
2843
|
function handleLayout(ctx, state, layout, setCanRender) {
|
|
1845
2844
|
const { maintainScrollAtEnd } = state.props;
|
|
1846
|
-
const
|
|
2845
|
+
const measuredLength = layout[state.props.horizontal ? "width" : "height"];
|
|
2846
|
+
const previousLength = state.scrollLength;
|
|
2847
|
+
const scrollLength = measuredLength > 0 ? measuredLength : previousLength;
|
|
1847
2848
|
const otherAxisSize = layout[state.props.horizontal ? "height" : "width"];
|
|
1848
2849
|
const needsCalculate = !state.lastLayout || scrollLength > state.scrollLength || state.lastLayout.x !== layout.x || state.lastLayout.y !== layout.y;
|
|
1849
2850
|
state.lastLayout = layout;
|
|
1850
|
-
const didChange = scrollLength !== state.scrollLength;
|
|
1851
2851
|
const prevOtherAxisSize = state.otherAxisSize;
|
|
1852
|
-
state.scrollLength
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
)
|
|
2852
|
+
const didChange = scrollLength !== state.scrollLength || otherAxisSize !== prevOtherAxisSize;
|
|
2853
|
+
if (didChange) {
|
|
2854
|
+
state.scrollLength = scrollLength;
|
|
2855
|
+
state.otherAxisSize = otherAxisSize;
|
|
2856
|
+
state.lastBatchingAction = Date.now();
|
|
2857
|
+
state.scrollForNextCalculateItemsInView = void 0;
|
|
2858
|
+
if (scrollLength > 0) {
|
|
2859
|
+
doInitialAllocateContainers(ctx, state);
|
|
2860
|
+
}
|
|
2861
|
+
if (needsCalculate) {
|
|
2862
|
+
calculateItemsInView(ctx, state, { doMVCP: true });
|
|
2863
|
+
}
|
|
2864
|
+
if (didChange || otherAxisSize !== prevOtherAxisSize) {
|
|
2865
|
+
set$(ctx, "scrollSize", { height: layout.height, width: layout.width });
|
|
2866
|
+
}
|
|
2867
|
+
if (maintainScrollAtEnd === true || maintainScrollAtEnd.onLayout) {
|
|
2868
|
+
doMaintainScrollAtEnd(ctx, state, false);
|
|
2869
|
+
}
|
|
2870
|
+
updateAlignItemsPaddingTop(ctx, state);
|
|
2871
|
+
checkAtBottom(ctx, state);
|
|
2872
|
+
checkAtTop(state);
|
|
2873
|
+
if (state) {
|
|
2874
|
+
state.needsOtherAxisSize = otherAxisSize - (state.props.stylePaddingTop || 0) < 10;
|
|
2875
|
+
}
|
|
2876
|
+
if (__DEV__ && measuredLength === 0) {
|
|
2877
|
+
warnDevOnce(
|
|
2878
|
+
"height0",
|
|
2879
|
+
`List ${state.props.horizontal ? "width" : "height"} is 0. You may need to set a style or \`flex: \` for the list, because children are absolutely positioned.`
|
|
2880
|
+
);
|
|
2881
|
+
}
|
|
2882
|
+
setCanRender(true);
|
|
1877
2883
|
}
|
|
1878
|
-
setCanRender(true);
|
|
1879
2884
|
}
|
|
1880
2885
|
|
|
1881
2886
|
// src/core/onScroll.ts
|
|
1882
2887
|
function onScroll(ctx, state, event) {
|
|
1883
|
-
var _a, _b, _c
|
|
2888
|
+
var _a, _b, _c;
|
|
2889
|
+
const {
|
|
2890
|
+
scrollProcessingEnabled,
|
|
2891
|
+
props: { onScroll: onScrollProp }
|
|
2892
|
+
} = state;
|
|
2893
|
+
if (scrollProcessingEnabled === false) {
|
|
2894
|
+
return;
|
|
2895
|
+
}
|
|
1884
2896
|
if (((_b = (_a = event.nativeEvent) == null ? void 0 : _a.contentSize) == null ? void 0 : _b.height) === 0 && ((_c = event.nativeEvent.contentSize) == null ? void 0 : _c.width) === 0) {
|
|
1885
2897
|
return;
|
|
1886
2898
|
}
|
|
@@ -1893,16 +2905,25 @@ function onScroll(ctx, state, event) {
|
|
|
1893
2905
|
}
|
|
1894
2906
|
}
|
|
1895
2907
|
state.scrollPending = newScroll;
|
|
1896
|
-
|
|
1897
|
-
|
|
2908
|
+
{
|
|
2909
|
+
if (!state.onScrollRafScheduled) {
|
|
2910
|
+
state.onScrollRafScheduled = true;
|
|
2911
|
+
requestAnimationFrame(() => {
|
|
2912
|
+
state.onScrollRafScheduled = false;
|
|
2913
|
+
updateScroll(ctx, state, newScroll);
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
onScrollProp == null ? void 0 : onScrollProp(event);
|
|
1898
2918
|
}
|
|
1899
2919
|
function updateScroll(ctx, state, newScroll) {
|
|
1900
2920
|
const scrollingTo = state.scrollingTo;
|
|
1901
2921
|
state.hasScrolled = true;
|
|
1902
2922
|
state.lastBatchingAction = Date.now();
|
|
1903
|
-
const currentTime =
|
|
2923
|
+
const currentTime = Date.now();
|
|
1904
2924
|
if (scrollingTo === void 0 && !(state.scrollHistory.length === 0 && newScroll === state.scroll)) {
|
|
1905
|
-
state.
|
|
2925
|
+
const adjust = state.scrollAdjustHandler.getAdjust();
|
|
2926
|
+
state.scrollHistory.push({ scroll: newScroll - adjust, time: currentTime });
|
|
1906
2927
|
}
|
|
1907
2928
|
if (state.scrollHistory.length > 5) {
|
|
1908
2929
|
state.scrollHistory.shift();
|
|
@@ -1911,9 +2932,11 @@ function updateScroll(ctx, state, newScroll) {
|
|
|
1911
2932
|
state.scrollPrevTime = state.scrollTime;
|
|
1912
2933
|
state.scroll = newScroll;
|
|
1913
2934
|
state.scrollTime = currentTime;
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
2935
|
+
if (Math.abs(state.scroll - state.scrollPrev) > 2) {
|
|
2936
|
+
calculateItemsInView(ctx, state);
|
|
2937
|
+
checkAtBottom(ctx, state);
|
|
2938
|
+
checkAtTop(state);
|
|
2939
|
+
}
|
|
1917
2940
|
}
|
|
1918
2941
|
|
|
1919
2942
|
// src/core/ScrollAdjustHandler.ts
|
|
@@ -1936,13 +2959,19 @@ var ScrollAdjustHandler = class {
|
|
|
1936
2959
|
setMounted() {
|
|
1937
2960
|
this.mounted = true;
|
|
1938
2961
|
}
|
|
2962
|
+
getAdjust() {
|
|
2963
|
+
return this.appliedAdjust;
|
|
2964
|
+
}
|
|
1939
2965
|
};
|
|
1940
2966
|
|
|
1941
2967
|
// src/core/updateItemSize.ts
|
|
1942
|
-
function
|
|
1943
|
-
var _a;
|
|
2968
|
+
function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
2969
|
+
var _a, _b;
|
|
1944
2970
|
const {
|
|
2971
|
+
sizesKnown,
|
|
1945
2972
|
props: {
|
|
2973
|
+
getFixedItemSize,
|
|
2974
|
+
getItemType,
|
|
1946
2975
|
horizontal,
|
|
1947
2976
|
maintainVisibleContentPosition,
|
|
1948
2977
|
suggestEstimatedItemSize,
|
|
@@ -1952,47 +2981,60 @@ function updateItemSizes(ctx, state, itemUpdates) {
|
|
|
1952
2981
|
}
|
|
1953
2982
|
} = state;
|
|
1954
2983
|
if (!data) return;
|
|
2984
|
+
if (getFixedItemSize) {
|
|
2985
|
+
const index2 = state.indexByKey.get(itemKey);
|
|
2986
|
+
if (index2 === void 0) {
|
|
2987
|
+
return;
|
|
2988
|
+
}
|
|
2989
|
+
const itemData = state.props.data[index2];
|
|
2990
|
+
if (itemData === void 0) {
|
|
2991
|
+
return;
|
|
2992
|
+
}
|
|
2993
|
+
const type = getItemType ? (_a = getItemType(itemData, index2)) != null ? _a : "" : "";
|
|
2994
|
+
const size2 = getFixedItemSize(index2, itemData, type);
|
|
2995
|
+
if (size2 !== void 0 && size2 === sizesKnown.get(itemKey)) {
|
|
2996
|
+
return;
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
1955
2999
|
const containersDidLayout = peek$(ctx, "containersDidLayout");
|
|
1956
3000
|
let needsRecalculate = !containersDidLayout;
|
|
1957
3001
|
let shouldMaintainScrollAtEnd = false;
|
|
1958
3002
|
let minIndexSizeChanged;
|
|
1959
3003
|
let maxOtherAxisSize = peek$(ctx, "otherAxisSize") || 0;
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
break;
|
|
1978
|
-
}
|
|
3004
|
+
const index = state.indexByKey.get(itemKey);
|
|
3005
|
+
const prevSizeKnown = state.sizesKnown.get(itemKey);
|
|
3006
|
+
const diff = updateOneItemSize(state, itemKey, sizeObj);
|
|
3007
|
+
const size = Math.floor((horizontal ? sizeObj.width : sizeObj.height) * 8) / 8;
|
|
3008
|
+
if (diff !== 0) {
|
|
3009
|
+
minIndexSizeChanged = minIndexSizeChanged !== void 0 ? Math.min(minIndexSizeChanged, index) : index;
|
|
3010
|
+
if (((_b = state.scrollingTo) == null ? void 0 : _b.viewPosition) && maintainVisibleContentPosition && index === state.scrollingTo.index && diff > 0) {
|
|
3011
|
+
requestAdjust(ctx, state, diff * state.scrollingTo.viewPosition);
|
|
3012
|
+
}
|
|
3013
|
+
const { startBuffered, endBuffered } = state;
|
|
3014
|
+
needsRecalculate || (needsRecalculate = index >= startBuffered && index <= endBuffered);
|
|
3015
|
+
if (!needsRecalculate) {
|
|
3016
|
+
const numContainers = ctx.values.get("numContainers");
|
|
3017
|
+
for (let i = 0; i < numContainers; i++) {
|
|
3018
|
+
if (peek$(ctx, `containerItemKey${i}`) === itemKey) {
|
|
3019
|
+
needsRecalculate = true;
|
|
3020
|
+
break;
|
|
1979
3021
|
}
|
|
1980
3022
|
}
|
|
1981
|
-
if (state.needsOtherAxisSize) {
|
|
1982
|
-
const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
|
|
1983
|
-
maxOtherAxisSize = Math.max(maxOtherAxisSize, otherAxisSize);
|
|
1984
|
-
}
|
|
1985
|
-
if (prevSizeKnown !== void 0 && Math.abs(prevSizeKnown - size) > 5) {
|
|
1986
|
-
shouldMaintainScrollAtEnd = true;
|
|
1987
|
-
}
|
|
1988
|
-
onItemSizeChanged == null ? void 0 : onItemSizeChanged({
|
|
1989
|
-
index,
|
|
1990
|
-
itemData: state.props.data[index],
|
|
1991
|
-
itemKey,
|
|
1992
|
-
previous: size - diff,
|
|
1993
|
-
size
|
|
1994
|
-
});
|
|
1995
3023
|
}
|
|
3024
|
+
if (state.needsOtherAxisSize) {
|
|
3025
|
+
const otherAxisSize = horizontal ? sizeObj.height : sizeObj.width;
|
|
3026
|
+
maxOtherAxisSize = Math.max(maxOtherAxisSize, otherAxisSize);
|
|
3027
|
+
}
|
|
3028
|
+
if (prevSizeKnown !== void 0 && Math.abs(prevSizeKnown - size) > 5) {
|
|
3029
|
+
shouldMaintainScrollAtEnd = true;
|
|
3030
|
+
}
|
|
3031
|
+
onItemSizeChanged == null ? void 0 : onItemSizeChanged({
|
|
3032
|
+
index,
|
|
3033
|
+
itemData: state.props.data[index],
|
|
3034
|
+
itemKey,
|
|
3035
|
+
previous: size - diff,
|
|
3036
|
+
size
|
|
3037
|
+
});
|
|
1996
3038
|
}
|
|
1997
3039
|
if (minIndexSizeChanged !== void 0) {
|
|
1998
3040
|
state.minIndexSizeChanged = state.minIndexSizeChanged !== void 0 ? Math.min(state.minIndexSizeChanged, minIndexSizeChanged) : minIndexSizeChanged;
|
|
@@ -2025,43 +3067,30 @@ function updateItemSizes(ctx, state, itemUpdates) {
|
|
|
2025
3067
|
}
|
|
2026
3068
|
}
|
|
2027
3069
|
}
|
|
2028
|
-
function updateItemSize(ctx, state, itemKey, sizeObj) {
|
|
2029
|
-
const { queuedItemSizeUpdates, queuedItemSizeUpdatesWaiting } = state;
|
|
2030
|
-
const containersDidLayout = peek$(ctx, "containersDidLayout");
|
|
2031
|
-
if (!containersDidLayout || !queuedItemSizeUpdatesWaiting) {
|
|
2032
|
-
updateItemSizes(ctx, state, [{ itemKey, sizeObj }]);
|
|
2033
|
-
if (containersDidLayout) {
|
|
2034
|
-
state.queuedItemSizeUpdatesWaiting = true;
|
|
2035
|
-
requestAnimationFrame(() => {
|
|
2036
|
-
state.queuedItemSizeUpdatesWaiting = false;
|
|
2037
|
-
updateItemSizes(ctx, state, queuedItemSizeUpdates);
|
|
2038
|
-
queuedItemSizeUpdates.length = 0;
|
|
2039
|
-
});
|
|
2040
|
-
}
|
|
2041
|
-
} else {
|
|
2042
|
-
queuedItemSizeUpdates.push({ itemKey, sizeObj });
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2045
3070
|
function updateOneItemSize(state, itemKey, sizeObj) {
|
|
3071
|
+
var _a;
|
|
2046
3072
|
const {
|
|
2047
3073
|
sizes,
|
|
2048
3074
|
indexByKey,
|
|
2049
3075
|
sizesKnown,
|
|
2050
3076
|
averageSizes,
|
|
2051
|
-
props: { data, horizontal }
|
|
3077
|
+
props: { data, horizontal, getEstimatedItemSize, getItemType, getFixedItemSize }
|
|
2052
3078
|
} = state;
|
|
2053
3079
|
if (!data) return 0;
|
|
2054
3080
|
const index = indexByKey.get(itemKey);
|
|
2055
3081
|
const prevSize = getItemSize(state, itemKey, index, data);
|
|
2056
|
-
const
|
|
3082
|
+
const rawSize = horizontal ? sizeObj.width : sizeObj.height;
|
|
3083
|
+
const size = Math.round(rawSize) ;
|
|
2057
3084
|
sizesKnown.set(itemKey, size);
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
averages
|
|
3085
|
+
if (!getEstimatedItemSize && !getFixedItemSize && size > 0) {
|
|
3086
|
+
const itemType = getItemType ? (_a = getItemType(data[index], index)) != null ? _a : "" : "";
|
|
3087
|
+
let averages = averageSizes[itemType];
|
|
3088
|
+
if (!averages) {
|
|
3089
|
+
averages = averageSizes[itemType] = { avg: 0, num: 0 };
|
|
3090
|
+
}
|
|
3091
|
+
averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
|
|
3092
|
+
averages.num++;
|
|
2062
3093
|
}
|
|
2063
|
-
averages.avg = (averages.avg * averages.num + size) / (averages.num + 1);
|
|
2064
|
-
averages.num++;
|
|
2065
3094
|
if (!prevSize || Math.abs(prevSize - size) > 0.1) {
|
|
2066
3095
|
sizes.set(itemKey, size);
|
|
2067
3096
|
return size - prevSize;
|
|
@@ -2084,6 +3113,22 @@ var useCombinedRef = (...refs) => {
|
|
|
2084
3113
|
return callback;
|
|
2085
3114
|
};
|
|
2086
3115
|
|
|
3116
|
+
// src/platform/RefreshControl.tsx
|
|
3117
|
+
function RefreshControl(props) {
|
|
3118
|
+
return null;
|
|
3119
|
+
}
|
|
3120
|
+
|
|
3121
|
+
// src/platform/StyleSheet.tsx
|
|
3122
|
+
var StyleSheet = {
|
|
3123
|
+
create: (styles) => styles,
|
|
3124
|
+
flatten: (style) => style
|
|
3125
|
+
};
|
|
3126
|
+
|
|
3127
|
+
// src/platform/useStickyScrollHandler.ts
|
|
3128
|
+
function useStickyScrollHandler(stickyIndices, horizontal, ctx, onScroll2) {
|
|
3129
|
+
return onScroll2;
|
|
3130
|
+
}
|
|
3131
|
+
|
|
2087
3132
|
// src/utils/createColumnWrapperStyle.ts
|
|
2088
3133
|
function createColumnWrapperStyle(contentContainerStyle) {
|
|
2089
3134
|
const { gap, columnGap, rowGap } = contentContainerStyle;
|
|
@@ -2099,89 +3144,203 @@ function createColumnWrapperStyle(contentContainerStyle) {
|
|
|
2099
3144
|
}
|
|
2100
3145
|
}
|
|
2101
3146
|
function getRenderedItem(ctx, state, key) {
|
|
3147
|
+
var _a;
|
|
2102
3148
|
if (!state) {
|
|
2103
3149
|
return null;
|
|
2104
3150
|
}
|
|
2105
3151
|
const {
|
|
2106
3152
|
indexByKey,
|
|
2107
|
-
props: { data, renderItem
|
|
3153
|
+
props: { data, getItemType, renderItem }
|
|
2108
3154
|
} = state;
|
|
2109
3155
|
const index = indexByKey.get(key);
|
|
2110
3156
|
if (index === void 0) {
|
|
2111
3157
|
return null;
|
|
2112
3158
|
}
|
|
2113
3159
|
let renderedItem = null;
|
|
2114
|
-
if (
|
|
3160
|
+
if (renderItem && data[index]) {
|
|
2115
3161
|
const itemProps = {
|
|
3162
|
+
data,
|
|
2116
3163
|
extraData: peek$(ctx, "extraData"),
|
|
2117
3164
|
index,
|
|
2118
|
-
item: data[index]
|
|
3165
|
+
item: data[index],
|
|
3166
|
+
type: getItemType ? (_a = getItemType(data[index], index)) != null ? _a : "" : ""
|
|
2119
3167
|
};
|
|
2120
|
-
renderedItem = React3__namespace.default.createElement(
|
|
3168
|
+
renderedItem = isFunction(renderItem) ? renderItem(itemProps) : React3__namespace.default.createElement(renderItem, itemProps);
|
|
2121
3169
|
}
|
|
2122
3170
|
return { index, item: data[index], renderedItem };
|
|
2123
3171
|
}
|
|
3172
|
+
function useThrottleDebounce(mode) {
|
|
3173
|
+
const timeoutRef = React3.useRef(null);
|
|
3174
|
+
const lastCallTimeRef = React3.useRef(0);
|
|
3175
|
+
const lastArgsRef = React3.useRef(null);
|
|
3176
|
+
const clearTimeoutRef = () => {
|
|
3177
|
+
if (timeoutRef.current) {
|
|
3178
|
+
clearTimeout(timeoutRef.current);
|
|
3179
|
+
timeoutRef.current = null;
|
|
3180
|
+
}
|
|
3181
|
+
};
|
|
3182
|
+
const execute = React3.useCallback(
|
|
3183
|
+
(callback, delay, ...args) => {
|
|
3184
|
+
{
|
|
3185
|
+
const now = Date.now();
|
|
3186
|
+
lastArgsRef.current = args;
|
|
3187
|
+
if (now - lastCallTimeRef.current >= delay) {
|
|
3188
|
+
lastCallTimeRef.current = now;
|
|
3189
|
+
callback(...args);
|
|
3190
|
+
clearTimeoutRef();
|
|
3191
|
+
} else {
|
|
3192
|
+
clearTimeoutRef();
|
|
3193
|
+
timeoutRef.current = setTimeout(
|
|
3194
|
+
() => {
|
|
3195
|
+
if (lastArgsRef.current) {
|
|
3196
|
+
lastCallTimeRef.current = Date.now();
|
|
3197
|
+
callback(...lastArgsRef.current);
|
|
3198
|
+
timeoutRef.current = null;
|
|
3199
|
+
lastArgsRef.current = null;
|
|
3200
|
+
}
|
|
3201
|
+
},
|
|
3202
|
+
delay - (now - lastCallTimeRef.current)
|
|
3203
|
+
);
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
},
|
|
3207
|
+
[mode]
|
|
3208
|
+
);
|
|
3209
|
+
return execute;
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
// src/utils/throttledOnScroll.ts
|
|
3213
|
+
function useThrottledOnScroll(originalHandler, scrollEventThrottle) {
|
|
3214
|
+
const throttle = useThrottleDebounce("throttle");
|
|
3215
|
+
return (event) => throttle(originalHandler, scrollEventThrottle, { nativeEvent: event.nativeEvent });
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
// src/utils/updateAveragesOnDataChange.ts
|
|
3219
|
+
function updateAveragesOnDataChange(state, oldData, newData) {
|
|
3220
|
+
var _a;
|
|
3221
|
+
const {
|
|
3222
|
+
averageSizes,
|
|
3223
|
+
sizesKnown,
|
|
3224
|
+
indexByKey,
|
|
3225
|
+
props: { itemsAreEqual, getItemType, keyExtractor }
|
|
3226
|
+
} = state;
|
|
3227
|
+
if (!itemsAreEqual || !oldData.length || !newData.length) {
|
|
3228
|
+
for (const key in averageSizes) {
|
|
3229
|
+
delete averageSizes[key];
|
|
3230
|
+
}
|
|
3231
|
+
return;
|
|
3232
|
+
}
|
|
3233
|
+
const itemTypesToPreserve = {};
|
|
3234
|
+
const newDataLength = newData.length;
|
|
3235
|
+
const oldDataLength = oldData.length;
|
|
3236
|
+
for (let newIndex = 0; newIndex < newDataLength; newIndex++) {
|
|
3237
|
+
const newItem = newData[newIndex];
|
|
3238
|
+
const id = keyExtractor ? keyExtractor(newItem, newIndex) : String(newIndex);
|
|
3239
|
+
const oldIndex = indexByKey.get(id);
|
|
3240
|
+
if (oldIndex !== void 0 && oldIndex < oldDataLength) {
|
|
3241
|
+
const knownSize = sizesKnown.get(id);
|
|
3242
|
+
if (knownSize === void 0) continue;
|
|
3243
|
+
const oldItem = oldData[oldIndex];
|
|
3244
|
+
const areEqual = itemsAreEqual(oldItem, newItem, newIndex, newData);
|
|
3245
|
+
if (areEqual) {
|
|
3246
|
+
const itemType = getItemType ? (_a = getItemType(newItem, newIndex)) != null ? _a : "" : "";
|
|
3247
|
+
let typeData = itemTypesToPreserve[itemType];
|
|
3248
|
+
if (!typeData) {
|
|
3249
|
+
typeData = itemTypesToPreserve[itemType] = { count: 0, totalSize: 0 };
|
|
3250
|
+
}
|
|
3251
|
+
typeData.totalSize += knownSize;
|
|
3252
|
+
typeData.count++;
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
for (const key in averageSizes) {
|
|
3257
|
+
delete averageSizes[key];
|
|
3258
|
+
}
|
|
3259
|
+
for (const itemType in itemTypesToPreserve) {
|
|
3260
|
+
const { totalSize, count } = itemTypesToPreserve[itemType];
|
|
3261
|
+
if (count > 0) {
|
|
3262
|
+
averageSizes[itemType] = {
|
|
3263
|
+
avg: totalSize / count,
|
|
3264
|
+
num: count
|
|
3265
|
+
};
|
|
3266
|
+
}
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
2124
3269
|
|
|
2125
3270
|
// src/components/LegendList.tsx
|
|
2126
3271
|
var DEFAULT_DRAW_DISTANCE = 250;
|
|
2127
3272
|
var DEFAULT_ITEM_SIZE = 100;
|
|
2128
|
-
var LegendList =
|
|
2129
|
-
|
|
2130
|
-
}
|
|
3273
|
+
var LegendList = typedMemo(
|
|
3274
|
+
typedForwardRef(function LegendList2(props, forwardedRef) {
|
|
3275
|
+
const { children, data: dataProp, renderItem: renderItemProp, ...restProps } = props;
|
|
3276
|
+
const isChildrenMode = children !== void 0 && dataProp === void 0;
|
|
3277
|
+
const processedProps = isChildrenMode ? {
|
|
3278
|
+
...restProps,
|
|
3279
|
+
data: (isArray(children) ? children : React3__namespace.Children.toArray(children)).flat(1),
|
|
3280
|
+
renderItem: ({ item }) => item
|
|
3281
|
+
} : {
|
|
3282
|
+
...restProps,
|
|
3283
|
+
data: dataProp || [],
|
|
3284
|
+
renderItem: renderItemProp
|
|
3285
|
+
};
|
|
3286
|
+
return /* @__PURE__ */ React3__namespace.createElement(StateProvider, null, /* @__PURE__ */ React3__namespace.createElement(LegendListInner, { ...processedProps, ref: forwardedRef }));
|
|
3287
|
+
})
|
|
3288
|
+
);
|
|
2131
3289
|
var LegendListInner = typedForwardRef(function LegendListInner2(props, forwardedRef) {
|
|
2132
|
-
var _a;
|
|
2133
3290
|
const {
|
|
2134
|
-
data: dataProp = [],
|
|
2135
|
-
initialScrollIndex: initialScrollIndexProp,
|
|
2136
|
-
initialScrollOffset,
|
|
2137
|
-
horizontal,
|
|
2138
|
-
drawDistance = 250,
|
|
2139
|
-
recycleItems = false,
|
|
2140
|
-
onEndReachedThreshold = 0.5,
|
|
2141
|
-
onStartReachedThreshold = 0.5,
|
|
2142
|
-
maintainScrollAtEnd = false,
|
|
2143
|
-
maintainScrollAtEndThreshold = 0.1,
|
|
2144
3291
|
alignItemsAtEnd = false,
|
|
2145
|
-
maintainVisibleContentPosition = false,
|
|
2146
|
-
onScroll: onScrollProp,
|
|
2147
|
-
onMomentumScrollEnd,
|
|
2148
|
-
numColumns: numColumnsProp = 1,
|
|
2149
3292
|
columnWrapperStyle,
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
3293
|
+
contentContainerStyle: contentContainerStyleProp,
|
|
3294
|
+
data: dataProp = [],
|
|
3295
|
+
drawDistance = 250,
|
|
3296
|
+
enableAverages = true,
|
|
2153
3297
|
estimatedItemSize: estimatedItemSizeProp,
|
|
3298
|
+
estimatedListSize,
|
|
3299
|
+
extraData,
|
|
2154
3300
|
getEstimatedItemSize,
|
|
2155
|
-
|
|
2156
|
-
|
|
3301
|
+
getFixedItemSize,
|
|
3302
|
+
getItemType,
|
|
3303
|
+
horizontal,
|
|
3304
|
+
initialContainerPoolRatio = 2,
|
|
3305
|
+
initialScrollIndex: initialScrollIndexProp,
|
|
3306
|
+
initialScrollOffset: initialScrollOffsetProp,
|
|
3307
|
+
itemsAreEqual,
|
|
3308
|
+
keyExtractor: keyExtractorProp,
|
|
2157
3309
|
ListEmptyComponent,
|
|
3310
|
+
ListHeaderComponent,
|
|
3311
|
+
maintainScrollAtEnd = false,
|
|
3312
|
+
maintainScrollAtEndThreshold = 0.1,
|
|
3313
|
+
maintainVisibleContentPosition = true,
|
|
3314
|
+
numColumns: numColumnsProp = 1,
|
|
3315
|
+
onEndReached,
|
|
3316
|
+
onEndReachedThreshold = 0.5,
|
|
2158
3317
|
onItemSizeChanged,
|
|
2159
|
-
refScrollView,
|
|
2160
|
-
waitForInitialLayout = true,
|
|
2161
|
-
extraData,
|
|
2162
|
-
contentContainerStyle: contentContainerStyleProp,
|
|
2163
|
-
style: styleProp,
|
|
2164
3318
|
onLayout: onLayoutProp,
|
|
3319
|
+
onLoad,
|
|
3320
|
+
onMomentumScrollEnd,
|
|
2165
3321
|
onRefresh,
|
|
2166
|
-
|
|
3322
|
+
onScroll: onScrollProp,
|
|
3323
|
+
onStartReached,
|
|
3324
|
+
onStartReachedThreshold = 0.5,
|
|
2167
3325
|
progressViewOffset,
|
|
3326
|
+
recycleItems = false,
|
|
2168
3327
|
refreshControl,
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
3328
|
+
refreshing,
|
|
3329
|
+
refScrollView,
|
|
3330
|
+
renderItem,
|
|
3331
|
+
scrollEventThrottle,
|
|
2172
3332
|
snapToIndices,
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
3333
|
+
stickyIndices,
|
|
3334
|
+
style: styleProp,
|
|
3335
|
+
suggestEstimatedItemSize,
|
|
3336
|
+
waitForInitialLayout = true,
|
|
2177
3337
|
...rest
|
|
2178
3338
|
} = props;
|
|
2179
3339
|
const [renderNum, setRenderNum] = React3.useState(0);
|
|
2180
|
-
const initialScroll = typeof initialScrollIndexProp === "
|
|
2181
|
-
const initialScrollIndex = initialScroll == null ? void 0 : initialScroll.index;
|
|
3340
|
+
const initialScroll = initialScrollIndexProp || initialScrollOffsetProp ? typeof initialScrollIndexProp === "object" ? { index: initialScrollIndexProp.index || 0, viewOffset: initialScrollIndexProp.viewOffset || 0 } : { index: initialScrollIndexProp || 0, viewOffset: initialScrollOffsetProp || 0 } : void 0;
|
|
2182
3341
|
const [canRender, setCanRender] = React3__namespace.useState(!IsNewArchitecture);
|
|
2183
|
-
const contentContainerStyle = { ...
|
|
2184
|
-
const style = { ...
|
|
3342
|
+
const contentContainerStyle = { ...StyleSheet.flatten(contentContainerStyleProp) };
|
|
3343
|
+
const style = { ...StyleSheet.flatten(styleProp) };
|
|
2185
3344
|
const stylePaddingTopState = extractPadding(style, contentContainerStyle, "Top");
|
|
2186
3345
|
const stylePaddingBottomState = extractPadding(style, contentContainerStyle, "Bottom");
|
|
2187
3346
|
const ctx = useStateContext();
|
|
@@ -2193,68 +3352,82 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2193
3352
|
const keyExtractor = keyExtractorProp != null ? keyExtractorProp : (_item, index) => index.toString();
|
|
2194
3353
|
const refState = React3.useRef();
|
|
2195
3354
|
if (!refState.current) {
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
3355
|
+
if (!ctx.internalState) {
|
|
3356
|
+
const initialScrollLength = (estimatedListSize != null ? estimatedListSize : { height: 0, width: 0 } )[horizontal ? "width" : "height"];
|
|
3357
|
+
ctx.internalState = {
|
|
3358
|
+
activeStickyIndex: void 0,
|
|
3359
|
+
averageSizes: {},
|
|
3360
|
+
columns: /* @__PURE__ */ new Map(),
|
|
3361
|
+
containerItemKeys: /* @__PURE__ */ new Set(),
|
|
3362
|
+
containerItemTypes: /* @__PURE__ */ new Map(),
|
|
3363
|
+
enableScrollForNextCalculateItemsInView: true,
|
|
3364
|
+
endBuffered: -1,
|
|
3365
|
+
endNoBuffer: -1,
|
|
3366
|
+
endReachedBlockedByTimer: false,
|
|
3367
|
+
firstFullyOnScreenIndex: -1,
|
|
3368
|
+
idCache: /* @__PURE__ */ new Map(),
|
|
3369
|
+
idsInView: [],
|
|
3370
|
+
indexByKey: /* @__PURE__ */ new Map(),
|
|
3371
|
+
initialScroll,
|
|
3372
|
+
isAtEnd: false,
|
|
3373
|
+
isAtStart: false,
|
|
3374
|
+
isEndReached: false,
|
|
3375
|
+
isStartReached: false,
|
|
3376
|
+
lastBatchingAction: Date.now(),
|
|
3377
|
+
lastLayout: void 0,
|
|
3378
|
+
loadStartTime: Date.now(),
|
|
3379
|
+
minIndexSizeChanged: 0,
|
|
3380
|
+
nativeMarginTop: 0,
|
|
3381
|
+
positions: /* @__PURE__ */ new Map(),
|
|
3382
|
+
props: {},
|
|
3383
|
+
queuedCalculateItemsInView: 0,
|
|
3384
|
+
refScroller: void 0,
|
|
3385
|
+
scroll: 0,
|
|
3386
|
+
scrollAdjustHandler: new ScrollAdjustHandler(ctx),
|
|
3387
|
+
scrollForNextCalculateItemsInView: void 0,
|
|
3388
|
+
scrollHistory: [],
|
|
3389
|
+
scrollLength: initialScrollLength,
|
|
3390
|
+
scrollPending: 0,
|
|
3391
|
+
scrollPrev: 0,
|
|
3392
|
+
scrollPrevTime: 0,
|
|
3393
|
+
scrollProcessingEnabled: true,
|
|
3394
|
+
scrollTime: 0,
|
|
3395
|
+
sizes: /* @__PURE__ */ new Map(),
|
|
3396
|
+
sizesKnown: /* @__PURE__ */ new Map(),
|
|
3397
|
+
startBuffered: -1,
|
|
3398
|
+
startNoBuffer: -1,
|
|
3399
|
+
startReachedBlockedByTimer: false,
|
|
3400
|
+
stickyContainerPool: /* @__PURE__ */ new Set(),
|
|
3401
|
+
stickyContainers: /* @__PURE__ */ new Map(),
|
|
3402
|
+
timeoutSizeMessage: 0,
|
|
3403
|
+
timeouts: /* @__PURE__ */ new Set(),
|
|
3404
|
+
totalSize: 0,
|
|
3405
|
+
viewabilityConfigCallbackPairs: void 0
|
|
3406
|
+
};
|
|
3407
|
+
set$(ctx, "maintainVisibleContentPosition", maintainVisibleContentPosition);
|
|
3408
|
+
set$(ctx, "extraData", extraData);
|
|
3409
|
+
}
|
|
3410
|
+
refState.current = ctx.internalState;
|
|
2246
3411
|
}
|
|
2247
3412
|
const state = refState.current;
|
|
2248
3413
|
const isFirst = !state.props.renderItem;
|
|
2249
3414
|
const didDataChange = state.props.data !== dataProp;
|
|
3415
|
+
const throttleScrollFn = (
|
|
3416
|
+
// @ts-expect-error TODO Fix this
|
|
3417
|
+
scrollEventThrottle && onScrollProp ? useThrottledOnScroll(onScrollProp, scrollEventThrottle) : onScrollProp
|
|
3418
|
+
);
|
|
2250
3419
|
state.props = {
|
|
2251
3420
|
alignItemsAtEnd,
|
|
2252
3421
|
data: dataProp,
|
|
3422
|
+
enableAverages,
|
|
2253
3423
|
estimatedItemSize,
|
|
2254
3424
|
getEstimatedItemSize,
|
|
3425
|
+
getFixedItemSize,
|
|
3426
|
+
getItemType,
|
|
2255
3427
|
horizontal: !!horizontal,
|
|
2256
3428
|
initialContainerPoolRatio,
|
|
2257
3429
|
initialScroll,
|
|
3430
|
+
itemsAreEqual,
|
|
2258
3431
|
keyExtractor,
|
|
2259
3432
|
maintainScrollAtEnd,
|
|
2260
3433
|
maintainScrollAtEndThreshold,
|
|
@@ -2264,12 +3437,15 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2264
3437
|
onEndReachedThreshold,
|
|
2265
3438
|
onItemSizeChanged,
|
|
2266
3439
|
onLoad,
|
|
2267
|
-
onScroll:
|
|
3440
|
+
onScroll: throttleScrollFn,
|
|
2268
3441
|
onStartReached,
|
|
2269
3442
|
onStartReachedThreshold,
|
|
2270
|
-
|
|
3443
|
+
recycleItems: !!recycleItems,
|
|
3444
|
+
renderItem,
|
|
2271
3445
|
scrollBuffer,
|
|
2272
3446
|
snapToIndices,
|
|
3447
|
+
stickyIndicesArr: stickyIndices != null ? stickyIndices : [],
|
|
3448
|
+
stickyIndicesSet: React3.useMemo(() => new Set(stickyIndices != null ? stickyIndices : []), [stickyIndices == null ? void 0 : stickyIndices.join(",")]),
|
|
2273
3449
|
stylePaddingBottom: stylePaddingBottomState,
|
|
2274
3450
|
stylePaddingTop: stylePaddingTopState,
|
|
2275
3451
|
suggestEstimatedItemSize: !!suggestEstimatedItemSize
|
|
@@ -2278,6 +3454,9 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2278
3454
|
const checkResetContainers = (isFirst2) => {
|
|
2279
3455
|
const state2 = refState.current;
|
|
2280
3456
|
if (state2) {
|
|
3457
|
+
if (!isFirst2 && state2.props.data !== dataProp) {
|
|
3458
|
+
updateAveragesOnDataChange(state2, state2.props.data, dataProp);
|
|
3459
|
+
}
|
|
2281
3460
|
state2.props.data = dataProp;
|
|
2282
3461
|
if (!isFirst2) {
|
|
2283
3462
|
calculateItemsInView(ctx, state2, { dataChanged: true, doMVCP: true });
|
|
@@ -2307,7 +3486,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2307
3486
|
setPaddingTop(ctx, state, { stylePaddingTop: stylePaddingTopState });
|
|
2308
3487
|
refState.current.props.stylePaddingBottom = stylePaddingBottomState;
|
|
2309
3488
|
let paddingDiff = stylePaddingTopState - prevPaddingTop;
|
|
2310
|
-
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 &&
|
|
3489
|
+
if (maintainVisibleContentPosition && paddingDiff && prevPaddingTop !== void 0 && Platform.OS === "ios") {
|
|
2311
3490
|
if (state.scroll < 0) {
|
|
2312
3491
|
paddingDiff += state.scroll;
|
|
2313
3492
|
}
|
|
@@ -2319,53 +3498,39 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2319
3498
|
updateAllPositions(ctx, state);
|
|
2320
3499
|
}
|
|
2321
3500
|
const initialContentOffset = React3.useMemo(() => {
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
3501
|
+
if (initialScroll) {
|
|
3502
|
+
const { index, viewOffset } = initialScroll;
|
|
3503
|
+
let initialContentOffset2 = viewOffset || 0;
|
|
3504
|
+
if (index !== void 0) {
|
|
3505
|
+
initialContentOffset2 += calculateOffsetForIndex(ctx, state, index);
|
|
3506
|
+
}
|
|
3507
|
+
refState.current.isStartReached = initialContentOffset2 < refState.current.scrollLength * onStartReachedThreshold;
|
|
3508
|
+
if (initialContentOffset2 > 0) {
|
|
3509
|
+
scrollTo(state, { animated: false, index, offset: initialContentOffset2 });
|
|
3510
|
+
}
|
|
3511
|
+
return initialContentOffset2;
|
|
2326
3512
|
}
|
|
2327
|
-
return
|
|
3513
|
+
return 0;
|
|
2328
3514
|
}, [renderNum]);
|
|
2329
3515
|
if (isFirst || didDataChange || numColumnsProp !== peek$(ctx, "numColumns")) {
|
|
2330
|
-
|
|
3516
|
+
state.lastBatchingAction = Date.now();
|
|
2331
3517
|
if (!keyExtractorProp && !isFirst && didDataChange) {
|
|
2332
3518
|
__DEV__ && warnDevOnce(
|
|
2333
3519
|
"keyExtractor",
|
|
2334
3520
|
"Changing data without a keyExtractor can cause slow performance and resetting scroll. If your list data can change you should use a keyExtractor with a unique id for best performance and behavior."
|
|
2335
3521
|
);
|
|
2336
|
-
|
|
2337
|
-
|
|
3522
|
+
state.sizes.clear();
|
|
3523
|
+
state.positions.clear();
|
|
2338
3524
|
}
|
|
2339
3525
|
}
|
|
2340
|
-
React3.useLayoutEffect(() => {
|
|
2341
|
-
if (IsNewArchitecture) {
|
|
2342
|
-
let measured;
|
|
2343
|
-
refScroller.current.measure((x, y, width, height) => {
|
|
2344
|
-
measured = { height, width, x, y };
|
|
2345
|
-
});
|
|
2346
|
-
if (measured) {
|
|
2347
|
-
const size = Math.floor(measured[horizontal ? "width" : "height"] * 8) / 8;
|
|
2348
|
-
if (size) {
|
|
2349
|
-
handleLayout(ctx, state, measured, setCanRender);
|
|
2350
|
-
}
|
|
2351
|
-
}
|
|
2352
|
-
}
|
|
2353
|
-
if (!isFirst) {
|
|
2354
|
-
calculateItemsInView(ctx, state, { doMVCP: true });
|
|
2355
|
-
}
|
|
2356
|
-
}, [dataProp]);
|
|
2357
3526
|
const onLayoutHeader = React3.useCallback((rect, fromLayoutEffect) => {
|
|
2358
3527
|
const size = rect[horizontal ? "width" : "height"];
|
|
2359
3528
|
set$(ctx, "headerSize", size);
|
|
2360
|
-
if (initialScroll) {
|
|
2361
|
-
|
|
3529
|
+
if ((initialScroll == null ? void 0 : initialScroll.index) !== void 0) {
|
|
3530
|
+
{
|
|
2362
3531
|
if (fromLayoutEffect) {
|
|
2363
3532
|
setRenderNum((v) => v + 1);
|
|
2364
3533
|
}
|
|
2365
|
-
} else {
|
|
2366
|
-
setTimeout(() => {
|
|
2367
|
-
scrollToIndex(ctx, state, { ...initialScroll, animated: false });
|
|
2368
|
-
}, 17);
|
|
2369
3534
|
}
|
|
2370
3535
|
}
|
|
2371
3536
|
}, []);
|
|
@@ -2375,7 +3540,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2375
3540
|
}
|
|
2376
3541
|
}, [snapToIndices]);
|
|
2377
3542
|
React3.useLayoutEffect(() => {
|
|
2378
|
-
const didAllocateContainers = doInitialAllocateContainersCallback();
|
|
3543
|
+
const didAllocateContainers = dataProp.length > 0 && doInitialAllocateContainersCallback();
|
|
2379
3544
|
if (!didAllocateContainers) {
|
|
2380
3545
|
checkResetContainers(
|
|
2381
3546
|
/*isFirst*/
|
|
@@ -2386,6 +3551,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2386
3551
|
React3.useLayoutEffect(() => {
|
|
2387
3552
|
set$(ctx, "extraData", extraData);
|
|
2388
3553
|
}, [extraData]);
|
|
3554
|
+
const { onLayout } = useSyncLayout({
|
|
3555
|
+
onLayout: onLayoutProp,
|
|
3556
|
+
onLayoutChange: React3.useCallback(
|
|
3557
|
+
(rectangle) => {
|
|
3558
|
+
handleLayout(ctx, state, rectangle, setCanRender);
|
|
3559
|
+
},
|
|
3560
|
+
[ctx, state, setCanRender]
|
|
3561
|
+
),
|
|
3562
|
+
ref: refScroller
|
|
3563
|
+
});
|
|
2389
3564
|
React3.useLayoutEffect(initializeStateVars, [
|
|
2390
3565
|
memoizedLastItemKeys.join(","),
|
|
2391
3566
|
numColumnsProp,
|
|
@@ -2395,27 +3570,6 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2395
3570
|
const doInitialAllocateContainersCallback = () => {
|
|
2396
3571
|
return doInitialAllocateContainers(ctx, state);
|
|
2397
3572
|
};
|
|
2398
|
-
React3.useEffect(() => {
|
|
2399
|
-
const viewability = setupViewability({
|
|
2400
|
-
onViewableItemsChanged,
|
|
2401
|
-
viewabilityConfig,
|
|
2402
|
-
viewabilityConfigCallbackPairs
|
|
2403
|
-
});
|
|
2404
|
-
state.viewabilityConfigCallbackPairs = viewability;
|
|
2405
|
-
state.enableScrollForNextCalculateItemsInView = !viewability;
|
|
2406
|
-
}, [viewabilityConfig, viewabilityConfigCallbackPairs, onViewableItemsChanged]);
|
|
2407
|
-
if (!IsNewArchitecture) {
|
|
2408
|
-
useInit(() => {
|
|
2409
|
-
doInitialAllocateContainersCallback();
|
|
2410
|
-
});
|
|
2411
|
-
}
|
|
2412
|
-
const onLayout = React3.useCallback((event) => {
|
|
2413
|
-
const layout = event.nativeEvent.layout;
|
|
2414
|
-
handleLayout(ctx, state, layout, setCanRender);
|
|
2415
|
-
if (onLayoutProp) {
|
|
2416
|
-
onLayoutProp(event);
|
|
2417
|
-
}
|
|
2418
|
-
}, []);
|
|
2419
3573
|
React3.useImperativeHandle(forwardedRef, () => {
|
|
2420
3574
|
const scrollIndexIntoView = (options) => {
|
|
2421
3575
|
const state2 = refState.current;
|
|
@@ -2433,18 +3587,23 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2433
3587
|
}
|
|
2434
3588
|
};
|
|
2435
3589
|
return {
|
|
2436
|
-
flashScrollIndicators: () =>
|
|
3590
|
+
flashScrollIndicators: () => {
|
|
3591
|
+
var _a, _b;
|
|
3592
|
+
return (_b = (_a = refScroller.current) == null ? void 0 : _a.flashScrollIndicators) == null ? void 0 : _b.call(_a);
|
|
3593
|
+
},
|
|
2437
3594
|
getNativeScrollRef: () => refScroller.current,
|
|
2438
|
-
getScrollableNode: () => refScroller.current
|
|
2439
|
-
getScrollResponder: () => refScroller.current
|
|
3595
|
+
getScrollableNode: () => refScroller.current,
|
|
3596
|
+
getScrollResponder: () => refScroller.current,
|
|
2440
3597
|
getState: () => {
|
|
2441
3598
|
const state2 = refState.current;
|
|
2442
3599
|
return state2 ? {
|
|
2443
3600
|
contentLength: state2.totalSize,
|
|
3601
|
+
data: state2.props.data,
|
|
2444
3602
|
end: state2.endNoBuffer,
|
|
2445
3603
|
endBuffered: state2.endBuffered,
|
|
2446
3604
|
isAtEnd: state2.isAtEnd,
|
|
2447
3605
|
isAtStart: state2.isAtStart,
|
|
3606
|
+
positionAtIndex: (index) => state2.positions.get(getId(state2, index)),
|
|
2448
3607
|
positions: state2.positions,
|
|
2449
3608
|
scroll: state2.scroll,
|
|
2450
3609
|
scrollLength: state2.scrollLength,
|
|
@@ -2471,7 +3630,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2471
3630
|
const footerSize = peek$(ctx, "footerSize") || 0;
|
|
2472
3631
|
scrollToIndex(ctx, state, {
|
|
2473
3632
|
index,
|
|
2474
|
-
viewOffset: -paddingBottom - footerSize,
|
|
3633
|
+
viewOffset: -paddingBottom - footerSize + ((options == null ? void 0 : options.viewOffset) || 0),
|
|
2475
3634
|
viewPosition: 1,
|
|
2476
3635
|
...options
|
|
2477
3636
|
});
|
|
@@ -2486,13 +3645,16 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2486
3645
|
}
|
|
2487
3646
|
},
|
|
2488
3647
|
scrollToOffset: (params) => scrollTo(state, params),
|
|
3648
|
+
setScrollProcessingEnabled: (enabled) => {
|
|
3649
|
+
refState.current.scrollProcessingEnabled = enabled;
|
|
3650
|
+
},
|
|
2489
3651
|
setVisibleContentAnchorOffset: (value) => {
|
|
2490
3652
|
const val = typeof value === "function" ? value(peek$(ctx, "scrollAdjustUserOffset") || 0) : value;
|
|
2491
3653
|
set$(ctx, "scrollAdjustUserOffset", val);
|
|
2492
3654
|
}
|
|
2493
3655
|
};
|
|
2494
3656
|
}, []);
|
|
2495
|
-
|
|
3657
|
+
{
|
|
2496
3658
|
React3.useEffect(() => {
|
|
2497
3659
|
if (initialContentOffset) {
|
|
2498
3660
|
scrollTo(state, { animated: false, offset: initialContentOffset });
|
|
@@ -2507,6 +3669,7 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2507
3669
|
}),
|
|
2508
3670
|
[]
|
|
2509
3671
|
);
|
|
3672
|
+
const onScrollHandler = useStickyScrollHandler(stickyIndices, horizontal, ctx, fns.onScroll);
|
|
2510
3673
|
return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement(
|
|
2511
3674
|
ListComponent,
|
|
2512
3675
|
{
|
|
@@ -2523,19 +3686,21 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2523
3686
|
onLayout,
|
|
2524
3687
|
onLayoutHeader,
|
|
2525
3688
|
onMomentumScrollEnd: (event) => {
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
3689
|
+
{
|
|
3690
|
+
requestAnimationFrame(() => {
|
|
3691
|
+
finishScrollTo(refState.current);
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
2529
3694
|
if (onMomentumScrollEnd) {
|
|
2530
3695
|
onMomentumScrollEnd(event);
|
|
2531
3696
|
}
|
|
2532
3697
|
},
|
|
2533
|
-
onScroll:
|
|
3698
|
+
onScroll: onScrollHandler,
|
|
2534
3699
|
recycleItems,
|
|
2535
3700
|
refreshControl: refreshControl ? stylePaddingTopState > 0 ? React3__namespace.cloneElement(refreshControl, {
|
|
2536
3701
|
progressViewOffset: (refreshControl.props.progressViewOffset || 0) + stylePaddingTopState
|
|
2537
3702
|
}) : refreshControl : onRefresh && /* @__PURE__ */ React3__namespace.createElement(
|
|
2538
|
-
|
|
3703
|
+
RefreshControl,
|
|
2539
3704
|
{
|
|
2540
3705
|
onRefresh,
|
|
2541
3706
|
progressViewOffset: (progressViewOffset || 0) + stylePaddingTopState,
|
|
@@ -2543,34 +3708,45 @@ var LegendListInner = typedForwardRef(function LegendListInner2(props, forwarded
|
|
|
2543
3708
|
}
|
|
2544
3709
|
),
|
|
2545
3710
|
refScrollView: combinedRef,
|
|
2546
|
-
scrollAdjustHandler:
|
|
2547
|
-
scrollEventThrottle: reactNative.Platform.OS === "web" ? 16 : void 0,
|
|
3711
|
+
scrollAdjustHandler: state.scrollAdjustHandler,
|
|
2548
3712
|
snapToIndices,
|
|
3713
|
+
stickyIndices,
|
|
2549
3714
|
style,
|
|
2550
3715
|
updateItemSize: fns.updateItemSize,
|
|
2551
3716
|
waitForInitialLayout
|
|
2552
3717
|
}
|
|
2553
3718
|
), __DEV__ && ENABLE_DEBUG_VIEW && /* @__PURE__ */ React3__namespace.createElement(DebugView, { state: refState.current }));
|
|
2554
3719
|
});
|
|
3720
|
+
/*! Bundled license information:
|
|
2555
3721
|
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
3722
|
+
react-dom/cjs/react-dom.production.js:
|
|
3723
|
+
(**
|
|
3724
|
+
* @license React
|
|
3725
|
+
* react-dom.production.js
|
|
3726
|
+
*
|
|
3727
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3728
|
+
*
|
|
3729
|
+
* This source code is licensed under the MIT license found in the
|
|
3730
|
+
* LICENSE file in the root directory of this source tree.
|
|
3731
|
+
*)
|
|
3732
|
+
|
|
3733
|
+
react-dom/cjs/react-dom.development.js:
|
|
3734
|
+
(**
|
|
3735
|
+
* @license React
|
|
3736
|
+
* react-dom.development.js
|
|
3737
|
+
*
|
|
3738
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3739
|
+
*
|
|
3740
|
+
* This source code is licensed under the MIT license found in the
|
|
3741
|
+
* LICENSE file in the root directory of this source tree.
|
|
3742
|
+
*)
|
|
3743
|
+
*/
|
|
2568
3744
|
|
|
2569
|
-
exports.LazyLegendList = LazyLegendList;
|
|
2570
3745
|
exports.LegendList = LegendList;
|
|
2571
3746
|
exports.useIsLastItem = useIsLastItem;
|
|
2572
3747
|
exports.useListScrollSize = useListScrollSize;
|
|
2573
3748
|
exports.useRecyclingEffect = useRecyclingEffect;
|
|
2574
3749
|
exports.useRecyclingState = useRecyclingState;
|
|
3750
|
+
exports.useSyncLayout = useSyncLayout2;
|
|
2575
3751
|
exports.useViewability = useViewability;
|
|
2576
3752
|
exports.useViewabilityAmount = useViewabilityAmount;
|