@react-aria/virtualizer 3.8.2-nightly.3940 → 3.8.2-nightly.3960
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +73 -58
- package/dist/main.js +72 -57
- package/dist/main.js.map +1 -1
- package/dist/module.js +73 -58
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +26 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/Virtualizer.tsx +78 -51
- package/src/VirtualizerItem.tsx +13 -12
- package/src/index.ts +1 -0
- package/src/useVirtualizerItem.ts +11 -6
package/dist/import.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {useLayoutEffect as $kSaV5$useLayoutEffect, mergeProps as $kSaV5$mergeProps, scrollIntoViewport as $kSaV5$scrollIntoViewport, focusWithoutScrolling as $kSaV5$focusWithoutScrolling, useResizeObserver as $kSaV5$useResizeObserver} from "@react-aria/utils";
|
|
2
1
|
import {getInteractionModality as $kSaV5$getInteractionModality} from "@react-aria/interactions";
|
|
3
2
|
import {useVirtualizerState as $kSaV5$useVirtualizerState, Rect as $kSaV5$Rect, Size as $kSaV5$Size} from "@react-stately/virtualizer";
|
|
4
|
-
import
|
|
3
|
+
import {mergeProps as $kSaV5$mergeProps, useLayoutEffect as $kSaV5$useLayoutEffect, useResizeObserver as $kSaV5$useResizeObserver} from "@react-aria/utils";
|
|
4
|
+
import $kSaV5$react, {useRef as $kSaV5$useRef, useEffect as $kSaV5$useEffect, useMemo as $kSaV5$useMemo, useCallback as $kSaV5$useCallback, useState as $kSaV5$useState} from "react";
|
|
5
5
|
import {flushSync as $kSaV5$flushSync} from "react-dom";
|
|
6
6
|
import {useLocale as $kSaV5$useLocale} from "@react-aria/i18n";
|
|
7
7
|
|
|
@@ -265,7 +265,7 @@ const $44a6ee657928b002$export$5665e3d6be6adea = /*#__PURE__*/ (0, $kSaV5$react)
|
|
|
265
265
|
|
|
266
266
|
|
|
267
267
|
function $47736c1e63ba1c6d$export$1da781778207e0a2(options) {
|
|
268
|
-
let {
|
|
268
|
+
let { layoutInfo: layoutInfo , virtualizer: virtualizer , ref: ref } = options;
|
|
269
269
|
let updateSize = (0, $kSaV5$useCallback)(()=>{
|
|
270
270
|
let size = $47736c1e63ba1c6d$var$getSize(ref.current);
|
|
271
271
|
virtualizer.updateItemSize(layoutInfo.key, size);
|
|
@@ -292,19 +292,20 @@ function $47736c1e63ba1c6d$var$getSize(node) {
|
|
|
292
292
|
|
|
293
293
|
|
|
294
294
|
function $ccf8a0a04e4175ae$export$6796df8ba7398521(props) {
|
|
295
|
-
let { className: className ,
|
|
295
|
+
let { className: className , layoutInfo: layoutInfo , virtualizer: virtualizer , parent: parent , children: children } = props;
|
|
296
296
|
let { direction: direction } = (0, $kSaV5$useLocale)();
|
|
297
297
|
let ref = (0, $kSaV5$useRef)();
|
|
298
298
|
(0, $47736c1e63ba1c6d$export$1da781778207e0a2)({
|
|
299
|
-
|
|
299
|
+
layoutInfo: layoutInfo,
|
|
300
|
+
virtualizer: virtualizer,
|
|
300
301
|
ref: ref
|
|
301
302
|
});
|
|
302
303
|
return /*#__PURE__*/ (0, $kSaV5$react).createElement("div", {
|
|
303
304
|
role: "presentation",
|
|
304
305
|
ref: ref,
|
|
305
306
|
className: className,
|
|
306
|
-
style: $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(
|
|
307
|
-
},
|
|
307
|
+
style: $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, direction, parent)
|
|
308
|
+
}, children);
|
|
308
309
|
}
|
|
309
310
|
let $ccf8a0a04e4175ae$var$cache = new WeakMap();
|
|
310
311
|
function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
@@ -341,10 +342,13 @@ function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
|
341
342
|
|
|
342
343
|
|
|
343
344
|
function $6d0a5c394373ae64$var$Virtualizer(props, ref) {
|
|
344
|
-
let { children: renderView , renderWrapper: renderWrapper , layout: layout , collection: collection , sizeToFit: sizeToFit , scrollDirection: scrollDirection , transitionDuration: transitionDuration , isLoading:
|
|
345
|
+
let { children: renderView , renderWrapper: renderWrapper , layout: layout , collection: collection , sizeToFit: sizeToFit , scrollDirection: scrollDirection , transitionDuration: transitionDuration , isLoading: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
346
|
+
isLoading , onLoadMore: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
347
|
+
onLoadMore , focusedKey: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
345
348
|
focusedKey , shouldUseVirtualFocus: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
346
349
|
shouldUseVirtualFocus , scrollToItem: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
347
|
-
scrollToItem ,
|
|
350
|
+
scrollToItem , autoFocus: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
351
|
+
autoFocus , ...otherProps } = props;
|
|
348
352
|
let fallbackRef = (0, $kSaV5$useRef)();
|
|
349
353
|
ref = ref || fallbackRef;
|
|
350
354
|
let state = (0, $kSaV5$useVirtualizerState)({
|
|
@@ -358,38 +362,14 @@ function $6d0a5c394373ae64$var$Virtualizer(props, ref) {
|
|
|
358
362
|
ref.current.scrollTop = rect.y;
|
|
359
363
|
}
|
|
360
364
|
});
|
|
361
|
-
let { virtualizerProps: virtualizerProps } = $6d0a5c394373ae64$export$dd6d526d88b5a137(props, state, ref);
|
|
362
|
-
// Handle scrolling, and call onLoadMore when nearing the bottom.
|
|
363
|
-
let onVisibleRectChange = (0, $kSaV5$useCallback)((rect)=>{
|
|
364
|
-
state.setVisibleRect(rect);
|
|
365
|
-
if (!isLoading && onLoadMore) {
|
|
366
|
-
let scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;
|
|
367
|
-
if (rect.y > scrollOffset) onLoadMore();
|
|
368
|
-
}
|
|
369
|
-
}, [
|
|
370
|
-
isLoading,
|
|
371
|
-
onLoadMore,
|
|
372
|
-
state
|
|
373
|
-
]);
|
|
374
|
-
(0, $kSaV5$useLayoutEffect)(()=>{
|
|
375
|
-
if (!isLoading && onLoadMore && !state.isAnimating) {
|
|
376
|
-
if (state.contentSize.height > 0 && state.contentSize.height <= state.virtualizer.visibleRect.height) onLoadMore();
|
|
377
|
-
}
|
|
378
|
-
}, [
|
|
379
|
-
state.contentSize,
|
|
380
|
-
state.isAnimating,
|
|
381
|
-
state.virtualizer,
|
|
382
|
-
onLoadMore,
|
|
383
|
-
isLoading
|
|
384
|
-
]);
|
|
365
|
+
let { virtualizerProps: virtualizerProps , scrollViewProps: scrollViewProps } = $6d0a5c394373ae64$export$dd6d526d88b5a137(props, state, ref);
|
|
385
366
|
return /*#__PURE__*/ (0, $kSaV5$react).createElement((0, $44a6ee657928b002$export$5665e3d6be6adea), {
|
|
386
|
-
...(0, $kSaV5$mergeProps)(otherProps, virtualizerProps),
|
|
367
|
+
...(0, $kSaV5$mergeProps)(otherProps, virtualizerProps, scrollViewProps),
|
|
387
368
|
ref: ref,
|
|
388
369
|
innerStyle: state.isAnimating ? {
|
|
389
370
|
transition: `none ${state.virtualizer.transitionDuration}ms`
|
|
390
371
|
} : undefined,
|
|
391
372
|
contentSize: state.contentSize,
|
|
392
|
-
onVisibleRectChange: onVisibleRectChange,
|
|
393
373
|
onScrollStart: state.startScrolling,
|
|
394
374
|
onScrollEnd: state.endScrolling,
|
|
395
375
|
sizeToFit: sizeToFit,
|
|
@@ -397,30 +377,26 @@ function $6d0a5c394373ae64$var$Virtualizer(props, ref) {
|
|
|
397
377
|
}, state.visibleViews);
|
|
398
378
|
}
|
|
399
379
|
function $6d0a5c394373ae64$export$dd6d526d88b5a137(props, state, ref) {
|
|
400
|
-
let { focusedKey: focusedKey , scrollToItem: scrollToItem , shouldUseVirtualFocus: shouldUseVirtualFocus } = props;
|
|
380
|
+
let { focusedKey: focusedKey , scrollToItem: scrollToItem , shouldUseVirtualFocus: shouldUseVirtualFocus , isLoading: isLoading , onLoadMore: onLoadMore } = props;
|
|
401
381
|
let { virtualizer: virtualizer } = state;
|
|
402
382
|
// Scroll to the focusedKey when it changes. Actually focusing the focusedKey
|
|
403
383
|
// is up to the implementation using Virtualizer since we don't have refs
|
|
404
384
|
// to all of the item DOM nodes.
|
|
405
385
|
let lastFocusedKey = (0, $kSaV5$useRef)(null);
|
|
406
386
|
let isFocusWithin = (0, $kSaV5$useRef)(false);
|
|
387
|
+
let autoFocus = (0, $kSaV5$useRef)(props.autoFocus);
|
|
407
388
|
(0, $kSaV5$useEffect)(()=>{
|
|
408
389
|
if (virtualizer.visibleRect.height === 0) return;
|
|
409
390
|
// Only scroll the focusedKey into view if the modality is not pointer to avoid jumps in position when clicking/pressing tall items.
|
|
410
|
-
// Exception made if focus isn't within the virtualizer (e.g. opening a picker via click should scroll the selected item into view)
|
|
411
391
|
let modality = (0, $kSaV5$getInteractionModality)();
|
|
412
|
-
if (focusedKey !== lastFocusedKey.current && (modality !== "pointer" ||
|
|
392
|
+
if (focusedKey !== lastFocusedKey.current && (modality !== "pointer" || autoFocus.current)) {
|
|
393
|
+
autoFocus.current = false;
|
|
413
394
|
if (scrollToItem) // If user provides scrolltoitem, then it is their responsibility to call scrollIntoViewport if desired
|
|
414
395
|
// since we don't know if their scrollToItem may take some time to actually bring the active element into the virtualizer's visible rect.
|
|
415
396
|
scrollToItem(focusedKey);
|
|
416
|
-
else {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
});
|
|
420
|
-
if (modality === "keyboard" && ref.current.contains(document.activeElement)) (0, $kSaV5$scrollIntoViewport)(document.activeElement, {
|
|
421
|
-
containingElement: ref.current
|
|
422
|
-
});
|
|
423
|
-
}
|
|
397
|
+
else virtualizer.scrollToItem(focusedKey, {
|
|
398
|
+
duration: 0
|
|
399
|
+
});
|
|
424
400
|
}
|
|
425
401
|
lastFocusedKey.current = focusedKey;
|
|
426
402
|
}, [
|
|
@@ -461,31 +437,69 @@ function $6d0a5c394373ae64$export$dd6d526d88b5a137(props, state, ref) {
|
|
|
461
437
|
}, [
|
|
462
438
|
ref
|
|
463
439
|
]);
|
|
464
|
-
//
|
|
465
|
-
// move focus to the collection view as a whole if focus was within before.
|
|
466
|
-
let focusedView = virtualizer.getView(focusedKey);
|
|
467
|
-
(0, $kSaV5$useEffect)(()=>{
|
|
468
|
-
if (focusedKey && !focusedView && isFocusWithin.current && document.activeElement !== ref.current) (0, $kSaV5$focusWithoutScrolling)(ref.current);
|
|
469
|
-
});
|
|
470
|
-
// Set tabIndex to -1 if the focused view is in the DOM, otherwise 0 so that the collection
|
|
440
|
+
// Set tabIndex to -1 if there is a focused key, otherwise 0 so that the collection
|
|
471
441
|
// itself is tabbable. When the collection receives focus, we scroll the focused item back into
|
|
472
442
|
// view, which will allow it to be properly focused. If using virtual focus, don't set a
|
|
473
443
|
// tabIndex at all so that VoiceOver on iOS 14 doesn't try to move real DOM focus to the element anyway.
|
|
474
444
|
let tabIndex;
|
|
475
445
|
if (!shouldUseVirtualFocus) {
|
|
476
|
-
// When there is no
|
|
446
|
+
// When there is no focusedKey the default tabIndex is 0. We include logic for empty collections too.
|
|
477
447
|
// For collections that are empty, but have a link in the empty children we want to skip focusing this
|
|
478
448
|
// and let focus move to the link similar to link moving to children.
|
|
479
|
-
tabIndex =
|
|
449
|
+
tabIndex = focusedKey != null ? -1 : 0;
|
|
480
450
|
// If the collection is empty, we want the tabIndex provided from props (if any)
|
|
481
451
|
// so that we handle when tabbable items are added to the empty state.
|
|
482
452
|
if (virtualizer.collection.size === 0 && props.tabIndex != null) tabIndex = props.tabIndex;
|
|
483
453
|
}
|
|
454
|
+
// Handle scrolling, and call onLoadMore when nearing the bottom.
|
|
455
|
+
let isLoadingRef = (0, $kSaV5$useRef)(isLoading);
|
|
456
|
+
let prevProps = (0, $kSaV5$useRef)(props);
|
|
457
|
+
let onVisibleRectChange = (0, $kSaV5$useCallback)((rect)=>{
|
|
458
|
+
state.setVisibleRect(rect);
|
|
459
|
+
if (!isLoadingRef.current && onLoadMore) {
|
|
460
|
+
let scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;
|
|
461
|
+
if (rect.y > scrollOffset) {
|
|
462
|
+
isLoadingRef.current = true;
|
|
463
|
+
onLoadMore();
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}, [
|
|
467
|
+
onLoadMore,
|
|
468
|
+
state
|
|
469
|
+
]);
|
|
470
|
+
let lastContentSize = (0, $kSaV5$useRef)(0);
|
|
471
|
+
(0, $kSaV5$useLayoutEffect)(()=>{
|
|
472
|
+
// If animating, wait until we're done.
|
|
473
|
+
if (state.isAnimating) return;
|
|
474
|
+
// Only update isLoadingRef if props object actually changed,
|
|
475
|
+
// not if a local state change occurred.
|
|
476
|
+
let wasLoading = isLoadingRef.current;
|
|
477
|
+
if (props !== prevProps.current) {
|
|
478
|
+
isLoadingRef.current = isLoading;
|
|
479
|
+
prevProps.current = props;
|
|
480
|
+
}
|
|
481
|
+
let shouldLoadMore = !isLoadingRef.current && onLoadMore && state.contentSize.height > 0 && state.contentSize.height <= state.virtualizer.visibleRect.height && (wasLoading || state.contentSize.height !== lastContentSize.current);
|
|
482
|
+
if (shouldLoadMore) {
|
|
483
|
+
isLoadingRef.current = true;
|
|
484
|
+
onLoadMore();
|
|
485
|
+
}
|
|
486
|
+
lastContentSize.current = state.contentSize.height;
|
|
487
|
+
}, [
|
|
488
|
+
state.contentSize,
|
|
489
|
+
state.isAnimating,
|
|
490
|
+
state.virtualizer,
|
|
491
|
+
isLoading,
|
|
492
|
+
onLoadMore,
|
|
493
|
+
props
|
|
494
|
+
]);
|
|
484
495
|
return {
|
|
485
496
|
virtualizerProps: {
|
|
486
497
|
tabIndex: tabIndex,
|
|
487
498
|
onFocus: onFocus,
|
|
488
499
|
onBlur: onBlur
|
|
500
|
+
},
|
|
501
|
+
scrollViewProps: {
|
|
502
|
+
onVisibleRectChange: onVisibleRectChange
|
|
489
503
|
}
|
|
490
504
|
};
|
|
491
505
|
}
|
|
@@ -495,9 +509,10 @@ const $6d0a5c394373ae64$export$89be5a243e59c4b2 = /*#__PURE__*/ (0, $kSaV5$react
|
|
|
495
509
|
function $6d0a5c394373ae64$var$defaultRenderWrapper(parent, reusableView) {
|
|
496
510
|
return /*#__PURE__*/ (0, $kSaV5$react).createElement((0, $ccf8a0a04e4175ae$export$6796df8ba7398521), {
|
|
497
511
|
key: reusableView.key,
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
512
|
+
layoutInfo: reusableView.layoutInfo,
|
|
513
|
+
virtualizer: reusableView.virtualizer,
|
|
514
|
+
parent: parent === null || parent === void 0 ? void 0 : parent.layoutInfo
|
|
515
|
+
}, reusableView.rendered);
|
|
501
516
|
}
|
|
502
517
|
|
|
503
518
|
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var $kYtlh$reactariautils = require("@react-aria/utils");
|
|
2
1
|
var $kYtlh$reactariainteractions = require("@react-aria/interactions");
|
|
3
2
|
var $kYtlh$reactstatelyvirtualizer = require("@react-stately/virtualizer");
|
|
3
|
+
var $kYtlh$reactariautils = require("@react-aria/utils");
|
|
4
4
|
var $kYtlh$react = require("react");
|
|
5
5
|
var $kYtlh$reactdom = require("react-dom");
|
|
6
6
|
var $kYtlh$reactariai18n = require("@react-aria/i18n");
|
|
@@ -281,7 +281,7 @@ const $00ca8c0b29e3e07c$export$5665e3d6be6adea = /*#__PURE__*/ (0, ($parcel$inte
|
|
|
281
281
|
|
|
282
282
|
|
|
283
283
|
function $7d70e069fceb2deb$export$1da781778207e0a2(options) {
|
|
284
|
-
let {
|
|
284
|
+
let { layoutInfo: layoutInfo , virtualizer: virtualizer , ref: ref } = options;
|
|
285
285
|
let updateSize = (0, $kYtlh$react.useCallback)(()=>{
|
|
286
286
|
let size = $7d70e069fceb2deb$var$getSize(ref.current);
|
|
287
287
|
virtualizer.updateItemSize(layoutInfo.key, size);
|
|
@@ -308,19 +308,20 @@ function $7d70e069fceb2deb$var$getSize(node) {
|
|
|
308
308
|
|
|
309
309
|
|
|
310
310
|
function $d6a26279cc31826b$export$6796df8ba7398521(props) {
|
|
311
|
-
let { className: className ,
|
|
311
|
+
let { className: className , layoutInfo: layoutInfo , virtualizer: virtualizer , parent: parent , children: children } = props;
|
|
312
312
|
let { direction: direction } = (0, $kYtlh$reactariai18n.useLocale)();
|
|
313
313
|
let ref = (0, $kYtlh$react.useRef)();
|
|
314
314
|
(0, $7d70e069fceb2deb$export$1da781778207e0a2)({
|
|
315
|
-
|
|
315
|
+
layoutInfo: layoutInfo,
|
|
316
|
+
virtualizer: virtualizer,
|
|
316
317
|
ref: ref
|
|
317
318
|
});
|
|
318
319
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($kYtlh$react))).createElement("div", {
|
|
319
320
|
role: "presentation",
|
|
320
321
|
ref: ref,
|
|
321
322
|
className: className,
|
|
322
|
-
style: $d6a26279cc31826b$export$1481e64fbe01b8b3(
|
|
323
|
-
},
|
|
323
|
+
style: $d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, direction, parent)
|
|
324
|
+
}, children);
|
|
324
325
|
}
|
|
325
326
|
let $d6a26279cc31826b$var$cache = new WeakMap();
|
|
326
327
|
function $d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
@@ -357,10 +358,13 @@ function $d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
|
357
358
|
|
|
358
359
|
|
|
359
360
|
function $e1fb6f3669e1c329$var$Virtualizer(props, ref) {
|
|
360
|
-
let { children: renderView , renderWrapper: renderWrapper , layout: layout , collection: collection , sizeToFit: sizeToFit , scrollDirection: scrollDirection , transitionDuration: transitionDuration , isLoading:
|
|
361
|
+
let { children: renderView , renderWrapper: renderWrapper , layout: layout , collection: collection , sizeToFit: sizeToFit , scrollDirection: scrollDirection , transitionDuration: transitionDuration , isLoading: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
362
|
+
isLoading , onLoadMore: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
363
|
+
onLoadMore , focusedKey: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
361
364
|
focusedKey , shouldUseVirtualFocus: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
362
365
|
shouldUseVirtualFocus , scrollToItem: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
363
|
-
scrollToItem ,
|
|
366
|
+
scrollToItem , autoFocus: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
367
|
+
autoFocus , ...otherProps } = props;
|
|
364
368
|
let fallbackRef = (0, $kYtlh$react.useRef)();
|
|
365
369
|
ref = ref || fallbackRef;
|
|
366
370
|
let state = (0, $kYtlh$reactstatelyvirtualizer.useVirtualizerState)({
|
|
@@ -374,38 +378,14 @@ function $e1fb6f3669e1c329$var$Virtualizer(props, ref) {
|
|
|
374
378
|
ref.current.scrollTop = rect.y;
|
|
375
379
|
}
|
|
376
380
|
});
|
|
377
|
-
let { virtualizerProps: virtualizerProps } = $e1fb6f3669e1c329$export$dd6d526d88b5a137(props, state, ref);
|
|
378
|
-
// Handle scrolling, and call onLoadMore when nearing the bottom.
|
|
379
|
-
let onVisibleRectChange = (0, $kYtlh$react.useCallback)((rect)=>{
|
|
380
|
-
state.setVisibleRect(rect);
|
|
381
|
-
if (!isLoading && onLoadMore) {
|
|
382
|
-
let scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;
|
|
383
|
-
if (rect.y > scrollOffset) onLoadMore();
|
|
384
|
-
}
|
|
385
|
-
}, [
|
|
386
|
-
isLoading,
|
|
387
|
-
onLoadMore,
|
|
388
|
-
state
|
|
389
|
-
]);
|
|
390
|
-
(0, $kYtlh$reactariautils.useLayoutEffect)(()=>{
|
|
391
|
-
if (!isLoading && onLoadMore && !state.isAnimating) {
|
|
392
|
-
if (state.contentSize.height > 0 && state.contentSize.height <= state.virtualizer.visibleRect.height) onLoadMore();
|
|
393
|
-
}
|
|
394
|
-
}, [
|
|
395
|
-
state.contentSize,
|
|
396
|
-
state.isAnimating,
|
|
397
|
-
state.virtualizer,
|
|
398
|
-
onLoadMore,
|
|
399
|
-
isLoading
|
|
400
|
-
]);
|
|
381
|
+
let { virtualizerProps: virtualizerProps , scrollViewProps: scrollViewProps } = $e1fb6f3669e1c329$export$dd6d526d88b5a137(props, state, ref);
|
|
401
382
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($kYtlh$react))).createElement((0, $00ca8c0b29e3e07c$export$5665e3d6be6adea), {
|
|
402
|
-
...(0, $kYtlh$reactariautils.mergeProps)(otherProps, virtualizerProps),
|
|
383
|
+
...(0, $kYtlh$reactariautils.mergeProps)(otherProps, virtualizerProps, scrollViewProps),
|
|
403
384
|
ref: ref,
|
|
404
385
|
innerStyle: state.isAnimating ? {
|
|
405
386
|
transition: `none ${state.virtualizer.transitionDuration}ms`
|
|
406
387
|
} : undefined,
|
|
407
388
|
contentSize: state.contentSize,
|
|
408
|
-
onVisibleRectChange: onVisibleRectChange,
|
|
409
389
|
onScrollStart: state.startScrolling,
|
|
410
390
|
onScrollEnd: state.endScrolling,
|
|
411
391
|
sizeToFit: sizeToFit,
|
|
@@ -413,30 +393,26 @@ function $e1fb6f3669e1c329$var$Virtualizer(props, ref) {
|
|
|
413
393
|
}, state.visibleViews);
|
|
414
394
|
}
|
|
415
395
|
function $e1fb6f3669e1c329$export$dd6d526d88b5a137(props, state, ref) {
|
|
416
|
-
let { focusedKey: focusedKey , scrollToItem: scrollToItem , shouldUseVirtualFocus: shouldUseVirtualFocus } = props;
|
|
396
|
+
let { focusedKey: focusedKey , scrollToItem: scrollToItem , shouldUseVirtualFocus: shouldUseVirtualFocus , isLoading: isLoading , onLoadMore: onLoadMore } = props;
|
|
417
397
|
let { virtualizer: virtualizer } = state;
|
|
418
398
|
// Scroll to the focusedKey when it changes. Actually focusing the focusedKey
|
|
419
399
|
// is up to the implementation using Virtualizer since we don't have refs
|
|
420
400
|
// to all of the item DOM nodes.
|
|
421
401
|
let lastFocusedKey = (0, $kYtlh$react.useRef)(null);
|
|
422
402
|
let isFocusWithin = (0, $kYtlh$react.useRef)(false);
|
|
403
|
+
let autoFocus = (0, $kYtlh$react.useRef)(props.autoFocus);
|
|
423
404
|
(0, $kYtlh$react.useEffect)(()=>{
|
|
424
405
|
if (virtualizer.visibleRect.height === 0) return;
|
|
425
406
|
// Only scroll the focusedKey into view if the modality is not pointer to avoid jumps in position when clicking/pressing tall items.
|
|
426
|
-
// Exception made if focus isn't within the virtualizer (e.g. opening a picker via click should scroll the selected item into view)
|
|
427
407
|
let modality = (0, $kYtlh$reactariainteractions.getInteractionModality)();
|
|
428
|
-
if (focusedKey !== lastFocusedKey.current && (modality !== "pointer" ||
|
|
408
|
+
if (focusedKey !== lastFocusedKey.current && (modality !== "pointer" || autoFocus.current)) {
|
|
409
|
+
autoFocus.current = false;
|
|
429
410
|
if (scrollToItem) // If user provides scrolltoitem, then it is their responsibility to call scrollIntoViewport if desired
|
|
430
411
|
// since we don't know if their scrollToItem may take some time to actually bring the active element into the virtualizer's visible rect.
|
|
431
412
|
scrollToItem(focusedKey);
|
|
432
|
-
else {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
});
|
|
436
|
-
if (modality === "keyboard" && ref.current.contains(document.activeElement)) (0, $kYtlh$reactariautils.scrollIntoViewport)(document.activeElement, {
|
|
437
|
-
containingElement: ref.current
|
|
438
|
-
});
|
|
439
|
-
}
|
|
413
|
+
else virtualizer.scrollToItem(focusedKey, {
|
|
414
|
+
duration: 0
|
|
415
|
+
});
|
|
440
416
|
}
|
|
441
417
|
lastFocusedKey.current = focusedKey;
|
|
442
418
|
}, [
|
|
@@ -477,31 +453,69 @@ function $e1fb6f3669e1c329$export$dd6d526d88b5a137(props, state, ref) {
|
|
|
477
453
|
}, [
|
|
478
454
|
ref
|
|
479
455
|
]);
|
|
480
|
-
//
|
|
481
|
-
// move focus to the collection view as a whole if focus was within before.
|
|
482
|
-
let focusedView = virtualizer.getView(focusedKey);
|
|
483
|
-
(0, $kYtlh$react.useEffect)(()=>{
|
|
484
|
-
if (focusedKey && !focusedView && isFocusWithin.current && document.activeElement !== ref.current) (0, $kYtlh$reactariautils.focusWithoutScrolling)(ref.current);
|
|
485
|
-
});
|
|
486
|
-
// Set tabIndex to -1 if the focused view is in the DOM, otherwise 0 so that the collection
|
|
456
|
+
// Set tabIndex to -1 if there is a focused key, otherwise 0 so that the collection
|
|
487
457
|
// itself is tabbable. When the collection receives focus, we scroll the focused item back into
|
|
488
458
|
// view, which will allow it to be properly focused. If using virtual focus, don't set a
|
|
489
459
|
// tabIndex at all so that VoiceOver on iOS 14 doesn't try to move real DOM focus to the element anyway.
|
|
490
460
|
let tabIndex;
|
|
491
461
|
if (!shouldUseVirtualFocus) {
|
|
492
|
-
// When there is no
|
|
462
|
+
// When there is no focusedKey the default tabIndex is 0. We include logic for empty collections too.
|
|
493
463
|
// For collections that are empty, but have a link in the empty children we want to skip focusing this
|
|
494
464
|
// and let focus move to the link similar to link moving to children.
|
|
495
|
-
tabIndex =
|
|
465
|
+
tabIndex = focusedKey != null ? -1 : 0;
|
|
496
466
|
// If the collection is empty, we want the tabIndex provided from props (if any)
|
|
497
467
|
// so that we handle when tabbable items are added to the empty state.
|
|
498
468
|
if (virtualizer.collection.size === 0 && props.tabIndex != null) tabIndex = props.tabIndex;
|
|
499
469
|
}
|
|
470
|
+
// Handle scrolling, and call onLoadMore when nearing the bottom.
|
|
471
|
+
let isLoadingRef = (0, $kYtlh$react.useRef)(isLoading);
|
|
472
|
+
let prevProps = (0, $kYtlh$react.useRef)(props);
|
|
473
|
+
let onVisibleRectChange = (0, $kYtlh$react.useCallback)((rect)=>{
|
|
474
|
+
state.setVisibleRect(rect);
|
|
475
|
+
if (!isLoadingRef.current && onLoadMore) {
|
|
476
|
+
let scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;
|
|
477
|
+
if (rect.y > scrollOffset) {
|
|
478
|
+
isLoadingRef.current = true;
|
|
479
|
+
onLoadMore();
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}, [
|
|
483
|
+
onLoadMore,
|
|
484
|
+
state
|
|
485
|
+
]);
|
|
486
|
+
let lastContentSize = (0, $kYtlh$react.useRef)(0);
|
|
487
|
+
(0, $kYtlh$reactariautils.useLayoutEffect)(()=>{
|
|
488
|
+
// If animating, wait until we're done.
|
|
489
|
+
if (state.isAnimating) return;
|
|
490
|
+
// Only update isLoadingRef if props object actually changed,
|
|
491
|
+
// not if a local state change occurred.
|
|
492
|
+
let wasLoading = isLoadingRef.current;
|
|
493
|
+
if (props !== prevProps.current) {
|
|
494
|
+
isLoadingRef.current = isLoading;
|
|
495
|
+
prevProps.current = props;
|
|
496
|
+
}
|
|
497
|
+
let shouldLoadMore = !isLoadingRef.current && onLoadMore && state.contentSize.height > 0 && state.contentSize.height <= state.virtualizer.visibleRect.height && (wasLoading || state.contentSize.height !== lastContentSize.current);
|
|
498
|
+
if (shouldLoadMore) {
|
|
499
|
+
isLoadingRef.current = true;
|
|
500
|
+
onLoadMore();
|
|
501
|
+
}
|
|
502
|
+
lastContentSize.current = state.contentSize.height;
|
|
503
|
+
}, [
|
|
504
|
+
state.contentSize,
|
|
505
|
+
state.isAnimating,
|
|
506
|
+
state.virtualizer,
|
|
507
|
+
isLoading,
|
|
508
|
+
onLoadMore,
|
|
509
|
+
props
|
|
510
|
+
]);
|
|
500
511
|
return {
|
|
501
512
|
virtualizerProps: {
|
|
502
513
|
tabIndex: tabIndex,
|
|
503
514
|
onFocus: onFocus,
|
|
504
515
|
onBlur: onBlur
|
|
516
|
+
},
|
|
517
|
+
scrollViewProps: {
|
|
518
|
+
onVisibleRectChange: onVisibleRectChange
|
|
505
519
|
}
|
|
506
520
|
};
|
|
507
521
|
}
|
|
@@ -511,9 +525,10 @@ const $e1fb6f3669e1c329$export$89be5a243e59c4b2 = /*#__PURE__*/ (0, ($parcel$int
|
|
|
511
525
|
function $e1fb6f3669e1c329$var$defaultRenderWrapper(parent, reusableView) {
|
|
512
526
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($kYtlh$react))).createElement((0, $d6a26279cc31826b$export$6796df8ba7398521), {
|
|
513
527
|
key: reusableView.key,
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
528
|
+
layoutInfo: reusableView.layoutInfo,
|
|
529
|
+
virtualizer: reusableView.virtualizer,
|
|
530
|
+
parent: parent === null || parent === void 0 ? void 0 : parent.layoutInfo
|
|
531
|
+
}, reusableView.rendered);
|
|
517
532
|
}
|
|
518
533
|
|
|
519
534
|
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;;ACZA;;;;;;;;;;CAUC,GAED,aAAa;AACb;ACbA;;;;;;;;;;CAUC,GAED,AAOA,IAAI,wCAAwC,IAAI;AAazC,SAAS,0CAAiB,cAAuB,KAAK,EAAiB;IAC5E,IAAI,0CAAoB,IAAI,IAAI,aAAa;QAC3C,MAAM,WAAW,SAAS,aAAa,CAAC;QACxC,MAAM,aAAa,SAAS,KAAK;QACjC,WAAW,KAAK,GAAG;QACnB,WAAW,MAAM,GAAG;QACpB,WAAW,QAAQ,GAAG;QACtB,WAAW,SAAS,GAAG;QAEvB,MAAM,WAAW,SAAS,aAAa,CAAC;QACxC,MAAM,aAAa,SAAS,KAAK;QACjC,WAAW,KAAK,GAAG;QACnB,WAAW,MAAM,GAAG;QAEpB,SAAS,WAAW,CAAC;QAErB,SAAS,IAAI,CAAC,WAAW,CAAC;QAE1B,IAAI,SAAS,UAAU,GAAG,GACxB,wCAAkB;aACb;YACL,SAAS,UAAU,GAAG;YACtB,IAAI,SAAS,UAAU,KAAK,GAC1B,wCAAkB;iBAElB,wCAAkB;QAEtB,CAAC;QAED,SAAS,IAAI,CAAC,WAAW,CAAC;QAE1B,OAAO;IACT,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AC,IAAI,KAAK,KAAK,MAAM,QAAQ,IAAI,IAAI,EAC7D,WAAW,MAAM,QAAQ;IAE7B,CAAC;IAED,OAAO;QACL,kBAAkB;sBAChB;qBACA;oBACA;QACF;IACF;AACF;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,sCAAK,AAAD,EAAE,UAAU,CAAC;AAGtC,SAAS,2CACP,MAAiC,EACjC,YAAgC,EAChC;IACA,qBACE,0DAAC,CAAA,GAAA,yCAAe,AAAD;QACb,KAAK,aAAa,GAAG;QACrB,cAAc;QACd,QAAQ;;AAEd;;CD1NC,GAED","sources":["packages/@react-aria/virtualizer/src/index.ts","packages/@react-aria/virtualizer/src/Virtualizer.tsx","packages/@react-aria/virtualizer/src/ScrollView.tsx","packages/@react-aria/virtualizer/src/utils.ts","packages/@react-aria/virtualizer/src/VirtualizerItem.tsx","packages/@react-aria/virtualizer/src/useVirtualizerItem.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {RTLOffsetType} from './utils';\nexport {useVirtualizer, Virtualizer} from './Virtualizer';\nexport {useVirtualizerItem} from './useVirtualizerItem';\nexport {VirtualizerItem, layoutInfoToStyle} from './VirtualizerItem';\nexport {ScrollView} from './ScrollView';\nexport {getRTLOffsetType, getScrollLeft, setScrollLeft} from './utils';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection} from '@react-types/shared';\nimport {focusWithoutScrolling, mergeProps, scrollIntoViewport, useLayoutEffect} from '@react-aria/utils';\nimport {getInteractionModality} from '@react-aria/interactions';\nimport {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer';\nimport React, {FocusEvent, HTMLAttributes, Key, ReactElement, RefObject, useCallback, useEffect, useMemo, useRef} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ninterface VirtualizerProps<T extends object, V> extends HTMLAttributes<HTMLElement> {\n children: (type: string, content: T) => V,\n renderWrapper?: (\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>,\n children: ReusableView<T, V>[],\n renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]\n ) => ReactElement,\n layout: Layout<T>,\n collection: Collection<T>,\n focusedKey?: Key,\n sizeToFit?: 'width' | 'height',\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n transitionDuration?: number,\n isLoading?: boolean,\n onLoadMore?: () => void,\n shouldUseVirtualFocus?: boolean,\n scrollToItem?: (key: Key) => void\n}\n\nfunction Virtualizer<T extends object, V>(props: VirtualizerProps<T, V>, ref: RefObject<HTMLDivElement>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n sizeToFit,\n scrollDirection,\n transitionDuration,\n isLoading,\n onLoadMore,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n focusedKey,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldUseVirtualFocus,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n scrollToItem,\n ...otherProps\n } = props;\n\n let fallbackRef = useRef<HTMLDivElement>();\n ref = ref || fallbackRef;\n\n let state = useVirtualizerState({\n transitionDuration,\n layout,\n collection,\n renderView,\n renderWrapper: renderWrapper || defaultRenderWrapper,\n onVisibleRectChange(rect) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n }\n });\n\n let {virtualizerProps} = useVirtualizer(props, state, ref);\n\n // Handle scrolling, and call onLoadMore when nearing the bottom.\n let onVisibleRectChange = useCallback((rect: Rect) => {\n state.setVisibleRect(rect);\n\n if (!isLoading && onLoadMore) {\n let scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;\n if (rect.y > scrollOffset) {\n onLoadMore();\n }\n }\n }, [isLoading, onLoadMore, state]);\n\n useLayoutEffect(() => {\n if (!isLoading && onLoadMore && !state.isAnimating) {\n if (state.contentSize.height > 0 && state.contentSize.height <= state.virtualizer.visibleRect.height) {\n onLoadMore();\n }\n }\n }, [state.contentSize, state.isAnimating, state.virtualizer, onLoadMore, isLoading]);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, virtualizerProps)}\n ref={ref}\n innerStyle={state.isAnimating ? {transition: `none ${state.virtualizer.transitionDuration}ms`} : undefined}\n contentSize={state.contentSize}\n onVisibleRectChange={onVisibleRectChange}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n sizeToFit={sizeToFit}\n scrollDirection={scrollDirection}>\n {state.visibleViews}\n </ScrollView>\n );\n}\n\ninterface VirtualizerOptions {\n tabIndex?: number,\n focusedKey?: Key,\n scrollToItem?: (key: Key) => void,\n shouldUseVirtualFocus?: boolean\n}\n\nexport function useVirtualizer<T extends object, V, W>(props: VirtualizerOptions, state: VirtualizerState<T, V, W>, ref: RefObject<HTMLElement>) {\n let {focusedKey, scrollToItem, shouldUseVirtualFocus} = props;\n let {virtualizer} = state;\n // Scroll to the focusedKey when it changes. Actually focusing the focusedKey\n // is up to the implementation using Virtualizer since we don't have refs\n // to all of the item DOM nodes.\n let lastFocusedKey = useRef(null);\n let isFocusWithin = useRef(false);\n useEffect(() => {\n if (virtualizer.visibleRect.height === 0) {\n return;\n }\n\n // Only scroll the focusedKey into view if the modality is not pointer to avoid jumps in position when clicking/pressing tall items.\n // Exception made if focus isn't within the virtualizer (e.g. opening a picker via click should scroll the selected item into view)\n let modality = getInteractionModality();\n if (focusedKey !== lastFocusedKey.current && (modality !== 'pointer' || !isFocusWithin.current)) {\n if (scrollToItem) {\n // If user provides scrolltoitem, then it is their responsibility to call scrollIntoViewport if desired\n // since we don't know if their scrollToItem may take some time to actually bring the active element into the virtualizer's visible rect.\n scrollToItem(focusedKey);\n } else {\n virtualizer.scrollToItem(focusedKey, {duration: 0});\n\n if (modality === 'keyboard' && ref.current.contains(document.activeElement)) {\n scrollIntoViewport(document.activeElement, {containingElement: ref.current});\n }\n }\n }\n\n lastFocusedKey.current = focusedKey;\n }, [focusedKey, virtualizer.visibleRect.height, virtualizer, lastFocusedKey, scrollToItem, ref]);\n\n // Persist the focusedKey and prevent it from being removed from the DOM when scrolled out of view.\n virtualizer.persistedKeys = useMemo(() => focusedKey ? new Set([focusedKey]) : new Set(), [focusedKey]);\n\n let onFocus = useCallback((e: FocusEvent) => {\n // If the focused item is scrolled out of view and is not in the DOM, the collection\n // will have tabIndex={0}. When tabbing in from outside, scroll the focused item into view.\n // Ignore focus events that bubble through portals (e.g. focus that happens on a menu popover child of the virtualizer)\n // Don't scroll focused key into view if modality is pointer to prevent sudden jump in position (e.g. CardView).\n let modality = getInteractionModality();\n if (!isFocusWithin.current && ref.current.contains(e.target) && modality !== 'pointer') {\n if (scrollToItem) {\n scrollToItem(focusedKey);\n } else {\n virtualizer.scrollToItem(focusedKey, {duration: 0});\n }\n }\n\n isFocusWithin.current = e.target !== ref.current;\n }, [ref, virtualizer, focusedKey, scrollToItem]);\n\n let onBlur = useCallback((e: FocusEvent) => {\n isFocusWithin.current = ref.current.contains(e.relatedTarget as Element);\n }, [ref]);\n\n // When the focused item is scrolled out of view and is removed from the DOM,\n // move focus to the collection view as a whole if focus was within before.\n let focusedView = virtualizer.getView(focusedKey);\n useEffect(() => {\n if (focusedKey && !focusedView && isFocusWithin.current && document.activeElement !== ref.current) {\n focusWithoutScrolling(ref.current);\n }\n });\n\n // Set tabIndex to -1 if the focused view is in the DOM, otherwise 0 so that the collection\n // itself is tabbable. When the collection receives focus, we scroll the focused item back into\n // view, which will allow it to be properly focused. If using virtual focus, don't set a\n // tabIndex at all so that VoiceOver on iOS 14 doesn't try to move real DOM focus to the element anyway.\n let tabIndex: number;\n if (!shouldUseVirtualFocus) {\n // When there is no focusedView the default tabIndex is 0. We include logic for empty collections too.\n // For collections that are empty, but have a link in the empty children we want to skip focusing this\n // and let focus move to the link similar to link moving to children.\n tabIndex = focusedView ? -1 : 0;\n\n // If the collection is empty, we want the tabIndex provided from props (if any)\n // so that we handle when tabbable items are added to the empty state.\n if (virtualizer.collection.size === 0 && props.tabIndex != null) {\n tabIndex = props.tabIndex;\n }\n }\n\n return {\n virtualizerProps: {\n tabIndex,\n onFocus,\n onBlur\n }\n };\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _Virtualizer = React.forwardRef(Virtualizer) as <T extends object, V>(props: VirtualizerProps<T, V> & {ref?: RefObject<HTMLDivElement>}) => ReactElement;\nexport {_Virtualizer as Virtualizer};\n\nfunction defaultRenderWrapper<T extends object, V>(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>\n) {\n return (\n <VirtualizerItem\n key={reusableView.key}\n reusableView={reusableView}\n parent={parent} />\n );\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// @ts-ignore\nimport {flushSync} from 'react-dom';\nimport {getScrollLeft} from './utils';\nimport React, {\n CSSProperties,\n HTMLAttributes,\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport {Rect, Size} from '@react-stately/virtualizer';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\nimport {useResizeObserver} from '@react-aria/utils';\n\ninterface ScrollViewProps extends HTMLAttributes<HTMLElement> {\n contentSize: Size,\n onVisibleRectChange: (rect: Rect) => void,\n children: ReactNode,\n innerStyle?: CSSProperties,\n sizeToFit?: 'width' | 'height',\n onScrollStart?: () => void,\n onScrollEnd?: () => void,\n scrollDirection?: 'horizontal' | 'vertical' | 'both'\n}\n\nfunction ScrollView(props: ScrollViewProps, ref: RefObject<HTMLDivElement>) {\n let {\n contentSize,\n onVisibleRectChange,\n children,\n innerStyle,\n sizeToFit,\n onScrollStart,\n onScrollEnd,\n scrollDirection = 'both',\n ...otherProps\n } = props;\n\n let defaultRef = useRef();\n ref = ref || defaultRef;\n let state = useRef({\n scrollTop: 0,\n scrollLeft: 0,\n scrollEndTime: 0,\n scrollTimeout: null,\n width: 0,\n height: 0,\n isScrolling: false\n }).current;\n let {direction} = useLocale();\n\n let [isScrolling, setScrolling] = useState(false);\n let onScroll = useCallback((e) => {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (props.onScroll) {\n props.onScroll(e);\n }\n\n flushSync(() => {\n let scrollTop = e.currentTarget.scrollTop;\n let scrollLeft = getScrollLeft(e.currentTarget, direction);\n\n // Prevent rubber band scrolling from shaking when scrolling out of bounds\n state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));\n state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));\n\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n\n if (!state.isScrolling) {\n state.isScrolling = true;\n setScrolling(true);\n\n if (onScrollStart) {\n onScrollStart();\n }\n }\n\n // So we don't constantly call clearTimeout and setTimeout,\n // keep track of the current timeout time and only reschedule\n // the timer when it is getting close.\n let now = Date.now();\n if (state.scrollEndTime <= now + 50) {\n state.scrollEndTime = now + 300;\n\n clearTimeout(state.scrollTimeout);\n state.scrollTimeout = setTimeout(() => {\n state.isScrolling = false;\n setScrolling(false);\n state.scrollTimeout = null;\n\n if (onScrollEnd) {\n onScrollEnd();\n }\n }, 300);\n }\n });\n }, [props, direction, state, contentSize, onVisibleRectChange, onScrollStart, onScrollEnd]);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n clearTimeout(state.scrollTimeout);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let updateSize = useCallback(() => {\n let dom = ref.current;\n if (!dom) {\n return;\n }\n\n let w = dom.clientWidth;\n let h = dom.clientHeight;\n if (sizeToFit && contentSize.width > 0 && contentSize.height > 0) {\n if (sizeToFit === 'width') {\n w = Math.min(w, contentSize.width);\n } else if (sizeToFit === 'height') {\n h = Math.min(h, contentSize.height);\n }\n }\n\n if (state.width !== w || state.height !== h) {\n state.width = w;\n state.height = h;\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, w, h));\n }\n }, [onVisibleRectChange, ref, state, sizeToFit, contentSize]);\n\n useLayoutEffect(() => {\n updateSize();\n }, [updateSize]);\n useResizeObserver({ref, onResize: updateSize});\n\n let style: React.CSSProperties = {\n // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.\n padding: 0,\n ...otherProps.style\n };\n\n if (scrollDirection === 'horizontal') {\n style.overflowX = 'auto';\n style.overflowY = 'hidden';\n } else if (scrollDirection === 'vertical') {\n style.overflowY = 'auto';\n style.overflowX = 'hidden';\n } else {\n style.overflow = 'auto';\n }\n\n return (\n <div {...otherProps} style={style} ref={ref} onScroll={onScroll}>\n <div role=\"presentation\" style={{width: contentSize.width, height: contentSize.height, pointerEvents: isScrolling ? 'none' : 'auto', position: 'relative', ...innerStyle}}>\n {children}\n </div>\n </div>\n );\n}\n\nconst ScrollViewForwardRef = React.forwardRef(ScrollView);\nexport {ScrollViewForwardRef as ScrollView};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\n\nexport type RTLOffsetType =\n | 'negative'\n | 'positive-descending'\n | 'positive-ascending';\n\nlet cachedRTLResult: RTLOffsetType | null = null;\n\n\n// Original licensing for the following methods can be found in the\n// NOTICE file in the root directory of this source tree.\n// See https://github.com/bvaughn/react-window/blob/master/src/createGridComponent.js\n\n// According to the spec, scrollLeft should be negative for RTL aligned elements.\n// Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).\n// Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.\n// The safest way to check this is to intentionally set a negative offset,\n// and then verify that the subsequent \"scroll\" event matches the negative offset.\n// If it does not match, then we can assume a non-standard RTL scroll implementation.\nexport function getRTLOffsetType(recalculate: boolean = false): RTLOffsetType {\n if (cachedRTLResult === null || recalculate) {\n const outerDiv = document.createElement('div');\n const outerStyle = outerDiv.style;\n outerStyle.width = '50px';\n outerStyle.height = '50px';\n outerStyle.overflow = 'scroll';\n outerStyle.direction = 'rtl';\n\n const innerDiv = document.createElement('div');\n const innerStyle = innerDiv.style;\n innerStyle.width = '100px';\n innerStyle.height = '100px';\n\n outerDiv.appendChild(innerDiv);\n\n document.body.appendChild(outerDiv);\n\n if (outerDiv.scrollLeft > 0) {\n cachedRTLResult = 'positive-descending';\n } else {\n outerDiv.scrollLeft = 1;\n if (outerDiv.scrollLeft === 0) {\n cachedRTLResult = 'negative';\n } else {\n cachedRTLResult = 'positive-ascending';\n }\n }\n\n document.body.removeChild(outerDiv);\n\n return cachedRTLResult;\n }\n\n return cachedRTLResult;\n}\n\nexport function getScrollLeft(node: Element, direction: Direction): number {\n let {scrollLeft} = node;\n\n // scrollLeft in rtl locales differs across browsers, so normalize.\n // See comment by getRTLOffsetType below for details.\n if (direction === 'rtl') {\n let {scrollWidth, clientWidth} = node;\n switch (getRTLOffsetType()) {\n case 'negative':\n scrollLeft = -scrollLeft;\n break;\n case 'positive-descending':\n scrollLeft = scrollWidth - clientWidth - scrollLeft;\n break;\n }\n }\n\n return scrollLeft;\n}\n\nexport function setScrollLeft(node: Element, direction: Direction, scrollLeft: number) {\n if (direction === 'rtl') {\n switch (getRTLOffsetType()) {\n case 'negative':\n scrollLeft = -scrollLeft;\n break;\n case 'positive-ascending':\n break;\n default: {\n const {clientWidth, scrollWidth} = node;\n scrollLeft = scrollWidth - clientWidth - scrollLeft;\n break;\n }\n }\n }\n\n node.scrollLeft = scrollLeft;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {LayoutInfo, ReusableView} from '@react-stately/virtualizer';\nimport React, {CSSProperties, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps<T extends object, V> {\n reusableView: ReusableView<T, V>,\n parent?: ReusableView<T, V>,\n className?: string\n}\n\nexport function VirtualizerItem<T extends object, V>(props: VirtualizerItemProps<T, V>) {\n let {className, reusableView, parent} = props;\n let {direction} = useLocale();\n let ref = useRef();\n useVirtualizerItem({\n reusableView,\n ref\n });\n\n return (\n <div role=\"presentation\" ref={ref} className={className} style={layoutInfoToStyle(reusableView.layoutInfo, direction, parent && parent.layoutInfo)}>\n {reusableView.rendered}\n </div>\n );\n}\n\nlet cache = new WeakMap();\nexport function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties {\n let xProperty = dir === 'rtl' ? 'right' : 'left';\n let cached = cache.get(layoutInfo);\n if (cached && cached[xProperty] != null) {\n if (!parent) {\n return cached;\n }\n\n // Invalidate if the parent position changed.\n let top = layoutInfo.rect.y - parent.rect.y;\n let x = layoutInfo.rect.x - parent.rect.x;\n if (cached.top === top && cached[xProperty] === x) {\n return cached;\n }\n }\n\n let style: CSSProperties = {\n position: layoutInfo.isSticky ? 'sticky' : 'absolute',\n // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.\n display: layoutInfo.isSticky ? 'inline-block' : undefined,\n overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',\n top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent ? parent.rect.x : 0),\n transition: 'all',\n WebkitTransition: 'all',\n WebkitTransitionDuration: 'inherit',\n transitionDuration: 'inherit',\n width: layoutInfo.rect.width,\n height: layoutInfo.rect.height,\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform,\n contain: 'size layout style'\n };\n\n cache.set(layoutInfo, style);\n return style;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {RefObject, useCallback} from 'react';\nimport {ReusableView, Size} from '@react-stately/virtualizer';\nimport {useLayoutEffect} from '@react-aria/utils';\n\ninterface VirtualizerItemOptions<T extends object, V> {\n reusableView: ReusableView<T, V>,\n ref: RefObject<HTMLElement>\n}\n\nexport function useVirtualizerItem<T extends object, V>(options: VirtualizerItemOptions<T, V>) {\n let {reusableView: {layoutInfo, virtualizer}, ref} = options;\n\n let updateSize = useCallback(() => {\n let size = getSize(ref.current);\n virtualizer.updateItemSize(layoutInfo.key, size);\n }, [virtualizer, layoutInfo.key, ref]);\n\n useLayoutEffect(() => {\n if (layoutInfo.estimatedSize) {\n updateSize();\n }\n });\n\n return {updateSize};\n}\n\nfunction getSize(node: HTMLElement) {\n // Reset height before measuring so we get the intrinsic size\n let height = node.style.height;\n node.style.height = '';\n let size = new Size(node.scrollWidth, node.scrollHeight);\n node.style.height = height;\n return size;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;;ACZA;;;;;;;;;;CAUC,GAED,aAAa;AACb;ACbA;;;;;;;;;;CAUC,GAED,AAOA,IAAI,wCAAwC,IAAI;AAazC,SAAS,0CAAiB,cAAuB,KAAK,EAAiB;IAC5E,IAAI,0CAAoB,IAAI,IAAI,aAAa;QAC3C,MAAM,WAAW,SAAS,aAAa,CAAC;QACxC,MAAM,aAAa,SAAS,KAAK;QACjC,WAAW,KAAK,GAAG;QACnB,WAAW,MAAM,GAAG;QACpB,WAAW,QAAQ,GAAG;QACtB,WAAW,SAAS,GAAG;QAEvB,MAAM,WAAW,SAAS,aAAa,CAAC;QACxC,MAAM,aAAa,SAAS,KAAK;QACjC,WAAW,KAAK,GAAG;QACnB,WAAW,MAAM,GAAG;QAEpB,SAAS,WAAW,CAAC;QAErB,SAAS,IAAI,CAAC,WAAW,CAAC;QAE1B,IAAI,SAA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,aAAa,aAAa,OAAO;QACrC,IAAI,UAAU,UAAU,OAAO,EAAE;YAC/B,aAAa,OAAO,GAAG;YACvB,UAAU,OAAO,GAAG;QACtB,CAAC;QAED,IAAI,iBAAiB,CAAC,aAAa,OAAO,IACrC,cACA,MAAM,WAAW,CAAC,MAAM,GAAG,KAC3B,MAAM,WAAW,CAAC,MAAM,IAAI,MAAM,WAAW,CAAC,WAAW,CAAC,MAAM,IAG/D,CAAA,cAAc,MAAM,WAAW,CAAC,MAAM,KAAK,gBAAgB,OAAO,AAAD;QAEvE,IAAI,gBAAgB;YAClB,aAAa,OAAO,GAAG,IAAI;YAC3B;QACF,CAAC;QACD,gBAAgB,OAAO,GAAG,MAAM,WAAW,CAAC,MAAM;IACpD,GAAG;QAAC,MAAM,WAAW;QAAE,MAAM,WAAW;QAAE,MAAM,WAAW;QAAE;QAAW;QAAY;KAAM;IAE1F,OAAO;QACL,kBAAkB;sBAChB;qBACA;oBACA;QACF;QACA,iBAAiB;iCACf;QACF;IACF;AACF;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,sCAAK,AAAD,EAAE,UAAU,CAAC;AAGtC,SAAS,2CACP,MAAiC,EACjC,YAAgC,EAChC;IACA,qBACE,0DAAC,CAAA,GAAA,yCAAe,AAAD;QACb,KAAK,aAAa,GAAG;QACrB,YAAY,aAAa,UAAU;QACnC,aAAa,aAAa,WAAW;QACrC,QAAQ,mBAAA,oBAAA,KAAA,IAAA,OAAQ,UAAU;OACzB,aAAa,QAAQ;AAG5B;;CDrPC,GAED","sources":["packages/@react-aria/virtualizer/src/index.ts","packages/@react-aria/virtualizer/src/Virtualizer.tsx","packages/@react-aria/virtualizer/src/ScrollView.tsx","packages/@react-aria/virtualizer/src/utils.ts","packages/@react-aria/virtualizer/src/VirtualizerItem.tsx","packages/@react-aria/virtualizer/src/useVirtualizerItem.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {RTLOffsetType} from './utils';\nexport type {VirtualizerItemOptions} from './useVirtualizerItem';\nexport {useVirtualizer, Virtualizer} from './Virtualizer';\nexport {useVirtualizerItem} from './useVirtualizerItem';\nexport {VirtualizerItem, layoutInfoToStyle} from './VirtualizerItem';\nexport {ScrollView} from './ScrollView';\nexport {getRTLOffsetType, getScrollLeft, setScrollLeft} from './utils';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection} from '@react-types/shared';\nimport {getInteractionModality} from '@react-aria/interactions';\nimport {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLayoutEffect} from '@react-aria/utils';\nimport React, {FocusEvent, HTMLAttributes, Key, ReactElement, ReactNode, RefObject, useCallback, useEffect, useMemo, useRef} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ninterface VirtualizerProps<T extends object, V> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n children: (type: string, content: T) => V,\n renderWrapper?: (\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>,\n children: ReusableView<T, V>[],\n renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]\n ) => ReactElement,\n layout: Layout<T>,\n collection: Collection<T>,\n focusedKey?: Key,\n sizeToFit?: 'width' | 'height',\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n transitionDuration?: number,\n isLoading?: boolean,\n onLoadMore?: () => void,\n shouldUseVirtualFocus?: boolean,\n scrollToItem?: (key: Key) => void,\n autoFocus?: boolean\n}\n\nfunction Virtualizer<T extends object, V extends ReactNode>(props: VirtualizerProps<T, V>, ref: RefObject<HTMLDivElement>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n sizeToFit,\n scrollDirection,\n transitionDuration,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isLoading,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onLoadMore,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n focusedKey,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldUseVirtualFocus,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n scrollToItem,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n autoFocus,\n ...otherProps\n } = props;\n\n let fallbackRef = useRef<HTMLDivElement>();\n ref = ref || fallbackRef;\n\n let state = useVirtualizerState({\n transitionDuration,\n layout,\n collection,\n renderView,\n renderWrapper: renderWrapper || defaultRenderWrapper,\n onVisibleRectChange(rect) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n }\n });\n\n let {virtualizerProps, scrollViewProps} = useVirtualizer(props, state, ref);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, virtualizerProps, scrollViewProps)}\n ref={ref}\n innerStyle={state.isAnimating ? {transition: `none ${state.virtualizer.transitionDuration}ms`} : undefined}\n contentSize={state.contentSize}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n sizeToFit={sizeToFit}\n scrollDirection={scrollDirection}>\n {state.visibleViews}\n </ScrollView>\n );\n}\n\ninterface VirtualizerOptions {\n tabIndex?: number,\n focusedKey?: Key,\n scrollToItem?: (key: Key) => void,\n shouldUseVirtualFocus?: boolean,\n autoFocus?: boolean,\n isLoading?: boolean,\n onLoadMore?: () => void\n}\n\nexport function useVirtualizer<T extends object, V extends ReactNode, W>(props: VirtualizerOptions, state: VirtualizerState<T, V, W>, ref: RefObject<HTMLElement>) {\n let {focusedKey, scrollToItem, shouldUseVirtualFocus, isLoading, onLoadMore} = props;\n let {virtualizer} = state;\n // Scroll to the focusedKey when it changes. Actually focusing the focusedKey\n // is up to the implementation using Virtualizer since we don't have refs\n // to all of the item DOM nodes.\n let lastFocusedKey = useRef(null);\n let isFocusWithin = useRef(false);\n let autoFocus = useRef(props.autoFocus);\n useEffect(() => {\n if (virtualizer.visibleRect.height === 0) {\n return;\n }\n\n // Only scroll the focusedKey into view if the modality is not pointer to avoid jumps in position when clicking/pressing tall items.\n let modality = getInteractionModality();\n if (focusedKey !== lastFocusedKey.current && (modality !== 'pointer' || autoFocus.current)) {\n autoFocus.current = false;\n if (scrollToItem) {\n // If user provides scrolltoitem, then it is their responsibility to call scrollIntoViewport if desired\n // since we don't know if their scrollToItem may take some time to actually bring the active element into the virtualizer's visible rect.\n scrollToItem(focusedKey);\n } else {\n virtualizer.scrollToItem(focusedKey, {duration: 0});\n\n }\n }\n\n lastFocusedKey.current = focusedKey;\n }, [focusedKey, virtualizer.visibleRect.height, virtualizer, lastFocusedKey, scrollToItem, ref]);\n\n // Persist the focusedKey and prevent it from being removed from the DOM when scrolled out of view.\n virtualizer.persistedKeys = useMemo(() => focusedKey ? new Set([focusedKey]) : new Set(), [focusedKey]);\n\n let onFocus = useCallback((e: FocusEvent) => {\n // If the focused item is scrolled out of view and is not in the DOM, the collection\n // will have tabIndex={0}. When tabbing in from outside, scroll the focused item into view.\n // Ignore focus events that bubble through portals (e.g. focus that happens on a menu popover child of the virtualizer)\n // Don't scroll focused key into view if modality is pointer to prevent sudden jump in position (e.g. CardView).\n let modality = getInteractionModality();\n if (!isFocusWithin.current && ref.current.contains(e.target) && modality !== 'pointer') {\n if (scrollToItem) {\n scrollToItem(focusedKey);\n } else {\n virtualizer.scrollToItem(focusedKey, {duration: 0});\n }\n }\n\n isFocusWithin.current = e.target !== ref.current;\n }, [ref, virtualizer, focusedKey, scrollToItem]);\n\n let onBlur = useCallback((e: FocusEvent) => {\n isFocusWithin.current = ref.current.contains(e.relatedTarget as Element);\n }, [ref]);\n\n // Set tabIndex to -1 if there is a focused key, otherwise 0 so that the collection\n // itself is tabbable. When the collection receives focus, we scroll the focused item back into\n // view, which will allow it to be properly focused. If using virtual focus, don't set a\n // tabIndex at all so that VoiceOver on iOS 14 doesn't try to move real DOM focus to the element anyway.\n let tabIndex: number;\n if (!shouldUseVirtualFocus) {\n // When there is no focusedKey the default tabIndex is 0. We include logic for empty collections too.\n // For collections that are empty, but have a link in the empty children we want to skip focusing this\n // and let focus move to the link similar to link moving to children.\n tabIndex = focusedKey != null ? -1 : 0;\n\n // If the collection is empty, we want the tabIndex provided from props (if any)\n // so that we handle when tabbable items are added to the empty state.\n if (virtualizer.collection.size === 0 && props.tabIndex != null) {\n tabIndex = props.tabIndex;\n }\n }\n\n // Handle scrolling, and call onLoadMore when nearing the bottom.\n let isLoadingRef = useRef(isLoading);\n let prevProps = useRef(props);\n let onVisibleRectChange = useCallback((rect: Rect) => {\n state.setVisibleRect(rect);\n\n if (!isLoadingRef.current && onLoadMore) {\n let scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;\n if (rect.y > scrollOffset) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n }\n }, [onLoadMore, state]);\n\n let lastContentSize = useRef(0);\n useLayoutEffect(() => {\n // If animating, wait until we're done.\n if (state.isAnimating) {\n return;\n }\n\n // Only update isLoadingRef if props object actually changed,\n // not if a local state change occurred.\n let wasLoading = isLoadingRef.current;\n if (props !== prevProps.current) {\n isLoadingRef.current = isLoading;\n prevProps.current = props;\n }\n\n let shouldLoadMore = !isLoadingRef.current\n && onLoadMore\n && state.contentSize.height > 0\n && state.contentSize.height <= state.virtualizer.visibleRect.height\n // Only try loading more if the content size changed, or if we just finished\n // loading and still have room for more items.\n && (wasLoading || state.contentSize.height !== lastContentSize.current);\n\n if (shouldLoadMore) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n lastContentSize.current = state.contentSize.height;\n }, [state.contentSize, state.isAnimating, state.virtualizer, isLoading, onLoadMore, props]);\n\n return {\n virtualizerProps: {\n tabIndex,\n onFocus,\n onBlur\n },\n scrollViewProps: {\n onVisibleRectChange\n }\n };\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _Virtualizer = React.forwardRef(Virtualizer) as <T extends object, V>(props: VirtualizerProps<T, V> & {ref?: RefObject<HTMLDivElement>}) => ReactElement;\nexport {_Virtualizer as Virtualizer};\n\nfunction defaultRenderWrapper<T extends object, V extends ReactNode>(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>\n) {\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// @ts-ignore\nimport {flushSync} from 'react-dom';\nimport {getScrollLeft} from './utils';\nimport React, {\n CSSProperties,\n HTMLAttributes,\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport {Rect, Size} from '@react-stately/virtualizer';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\nimport {useResizeObserver} from '@react-aria/utils';\n\ninterface ScrollViewProps extends HTMLAttributes<HTMLElement> {\n contentSize: Size,\n onVisibleRectChange: (rect: Rect) => void,\n children: ReactNode,\n innerStyle?: CSSProperties,\n sizeToFit?: 'width' | 'height',\n onScrollStart?: () => void,\n onScrollEnd?: () => void,\n scrollDirection?: 'horizontal' | 'vertical' | 'both'\n}\n\nfunction ScrollView(props: ScrollViewProps, ref: RefObject<HTMLDivElement>) {\n let {\n contentSize,\n onVisibleRectChange,\n children,\n innerStyle,\n sizeToFit,\n onScrollStart,\n onScrollEnd,\n scrollDirection = 'both',\n ...otherProps\n } = props;\n\n let defaultRef = useRef();\n ref = ref || defaultRef;\n let state = useRef({\n scrollTop: 0,\n scrollLeft: 0,\n scrollEndTime: 0,\n scrollTimeout: null,\n width: 0,\n height: 0,\n isScrolling: false\n }).current;\n let {direction} = useLocale();\n\n let [isScrolling, setScrolling] = useState(false);\n let onScroll = useCallback((e) => {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (props.onScroll) {\n props.onScroll(e);\n }\n\n flushSync(() => {\n let scrollTop = e.currentTarget.scrollTop;\n let scrollLeft = getScrollLeft(e.currentTarget, direction);\n\n // Prevent rubber band scrolling from shaking when scrolling out of bounds\n state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));\n state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));\n\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n\n if (!state.isScrolling) {\n state.isScrolling = true;\n setScrolling(true);\n\n if (onScrollStart) {\n onScrollStart();\n }\n }\n\n // So we don't constantly call clearTimeout and setTimeout,\n // keep track of the current timeout time and only reschedule\n // the timer when it is getting close.\n let now = Date.now();\n if (state.scrollEndTime <= now + 50) {\n state.scrollEndTime = now + 300;\n\n clearTimeout(state.scrollTimeout);\n state.scrollTimeout = setTimeout(() => {\n state.isScrolling = false;\n setScrolling(false);\n state.scrollTimeout = null;\n\n if (onScrollEnd) {\n onScrollEnd();\n }\n }, 300);\n }\n });\n }, [props, direction, state, contentSize, onVisibleRectChange, onScrollStart, onScrollEnd]);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n clearTimeout(state.scrollTimeout);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let updateSize = useCallback(() => {\n let dom = ref.current;\n if (!dom) {\n return;\n }\n\n let w = dom.clientWidth;\n let h = dom.clientHeight;\n if (sizeToFit && contentSize.width > 0 && contentSize.height > 0) {\n if (sizeToFit === 'width') {\n w = Math.min(w, contentSize.width);\n } else if (sizeToFit === 'height') {\n h = Math.min(h, contentSize.height);\n }\n }\n\n if (state.width !== w || state.height !== h) {\n state.width = w;\n state.height = h;\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, w, h));\n }\n }, [onVisibleRectChange, ref, state, sizeToFit, contentSize]);\n\n useLayoutEffect(() => {\n updateSize();\n }, [updateSize]);\n useResizeObserver({ref, onResize: updateSize});\n\n let style: React.CSSProperties = {\n // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.\n padding: 0,\n ...otherProps.style\n };\n\n if (scrollDirection === 'horizontal') {\n style.overflowX = 'auto';\n style.overflowY = 'hidden';\n } else if (scrollDirection === 'vertical') {\n style.overflowY = 'auto';\n style.overflowX = 'hidden';\n } else {\n style.overflow = 'auto';\n }\n\n return (\n <div {...otherProps} style={style} ref={ref} onScroll={onScroll}>\n <div role=\"presentation\" style={{width: contentSize.width, height: contentSize.height, pointerEvents: isScrolling ? 'none' : 'auto', position: 'relative', ...innerStyle}}>\n {children}\n </div>\n </div>\n );\n}\n\nconst ScrollViewForwardRef = React.forwardRef(ScrollView);\nexport {ScrollViewForwardRef as ScrollView};\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\n\nexport type RTLOffsetType =\n | 'negative'\n | 'positive-descending'\n | 'positive-ascending';\n\nlet cachedRTLResult: RTLOffsetType | null = null;\n\n\n// Original licensing for the following methods can be found in the\n// NOTICE file in the root directory of this source tree.\n// See https://github.com/bvaughn/react-window/blob/master/src/createGridComponent.js\n\n// According to the spec, scrollLeft should be negative for RTL aligned elements.\n// Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).\n// Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.\n// The safest way to check this is to intentionally set a negative offset,\n// and then verify that the subsequent \"scroll\" event matches the negative offset.\n// If it does not match, then we can assume a non-standard RTL scroll implementation.\nexport function getRTLOffsetType(recalculate: boolean = false): RTLOffsetType {\n if (cachedRTLResult === null || recalculate) {\n const outerDiv = document.createElement('div');\n const outerStyle = outerDiv.style;\n outerStyle.width = '50px';\n outerStyle.height = '50px';\n outerStyle.overflow = 'scroll';\n outerStyle.direction = 'rtl';\n\n const innerDiv = document.createElement('div');\n const innerStyle = innerDiv.style;\n innerStyle.width = '100px';\n innerStyle.height = '100px';\n\n outerDiv.appendChild(innerDiv);\n\n document.body.appendChild(outerDiv);\n\n if (outerDiv.scrollLeft > 0) {\n cachedRTLResult = 'positive-descending';\n } else {\n outerDiv.scrollLeft = 1;\n if (outerDiv.scrollLeft === 0) {\n cachedRTLResult = 'negative';\n } else {\n cachedRTLResult = 'positive-ascending';\n }\n }\n\n document.body.removeChild(outerDiv);\n\n return cachedRTLResult;\n }\n\n return cachedRTLResult;\n}\n\nexport function getScrollLeft(node: Element, direction: Direction): number {\n let {scrollLeft} = node;\n\n // scrollLeft in rtl locales differs across browsers, so normalize.\n // See comment by getRTLOffsetType below for details.\n if (direction === 'rtl') {\n let {scrollWidth, clientWidth} = node;\n switch (getRTLOffsetType()) {\n case 'negative':\n scrollLeft = -scrollLeft;\n break;\n case 'positive-descending':\n scrollLeft = scrollWidth - clientWidth - scrollLeft;\n break;\n }\n }\n\n return scrollLeft;\n}\n\nexport function setScrollLeft(node: Element, direction: Direction, scrollLeft: number) {\n if (direction === 'rtl') {\n switch (getRTLOffsetType()) {\n case 'negative':\n scrollLeft = -scrollLeft;\n break;\n case 'positive-ascending':\n break;\n default: {\n const {clientWidth, scrollWidth} = node;\n scrollLeft = scrollWidth - clientWidth - scrollLeft;\n break;\n }\n }\n }\n\n node.scrollLeft = scrollLeft;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {LayoutInfo} from '@react-stately/virtualizer';\nimport React, {CSSProperties, ReactNode, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {\n parent?: LayoutInfo,\n className?: string,\n children: ReactNode\n}\n\nexport function VirtualizerItem(props: VirtualizerItemProps) {\n let {className, layoutInfo, virtualizer, parent, children} = props;\n let {direction} = useLocale();\n let ref = useRef();\n useVirtualizerItem({\n layoutInfo,\n virtualizer,\n ref\n });\n\n return (\n <div role=\"presentation\" ref={ref} className={className} style={layoutInfoToStyle(layoutInfo, direction, parent)}>\n {children}\n </div>\n );\n}\n\nlet cache = new WeakMap();\nexport function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties {\n let xProperty = dir === 'rtl' ? 'right' : 'left';\n let cached = cache.get(layoutInfo);\n if (cached && cached[xProperty] != null) {\n if (!parent) {\n return cached;\n }\n\n // Invalidate if the parent position changed.\n let top = layoutInfo.rect.y - parent.rect.y;\n let x = layoutInfo.rect.x - parent.rect.x;\n if (cached.top === top && cached[xProperty] === x) {\n return cached;\n }\n }\n\n let style: CSSProperties = {\n position: layoutInfo.isSticky ? 'sticky' : 'absolute',\n // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.\n display: layoutInfo.isSticky ? 'inline-block' : undefined,\n overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',\n top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent ? parent.rect.x : 0),\n transition: 'all',\n WebkitTransition: 'all',\n WebkitTransitionDuration: 'inherit',\n transitionDuration: 'inherit',\n width: layoutInfo.rect.width,\n height: layoutInfo.rect.height,\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform,\n contain: 'size layout style'\n };\n\n cache.set(layoutInfo, style);\n return style;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Key, RefObject, useCallback} from 'react';\nimport {LayoutInfo, Size} from '@react-stately/virtualizer';\nimport {useLayoutEffect} from '@react-aria/utils';\n\ninterface IVirtualizer {\n updateItemSize(key: Key, size: Size): void\n}\n\nexport interface VirtualizerItemOptions {\n layoutInfo: LayoutInfo,\n virtualizer: IVirtualizer,\n ref: RefObject<HTMLElement>\n}\n\nexport function useVirtualizerItem(options: VirtualizerItemOptions) {\n let {layoutInfo, virtualizer, ref} = options;\n\n let updateSize = useCallback(() => {\n let size = getSize(ref.current);\n virtualizer.updateItemSize(layoutInfo.key, size);\n }, [virtualizer, layoutInfo.key, ref]);\n\n useLayoutEffect(() => {\n if (layoutInfo.estimatedSize) {\n updateSize();\n }\n });\n\n return {updateSize};\n}\n\nfunction getSize(node: HTMLElement) {\n // Reset height before measuring so we get the intrinsic size\n let height = node.style.height;\n node.style.height = '';\n let size = new Size(node.scrollWidth, node.scrollHeight);\n node.style.height = height;\n return size;\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|