@react-aria/virtualizer 3.6.2-nightly.3674 → 3.6.2-nightly.3682
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/main.js +13 -5
- package/dist/main.js.map +1 -1
- package/dist/module.js +14 -6
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/Virtualizer.tsx +8 -3
package/dist/main.js
CHANGED
|
@@ -456,10 +456,17 @@ function $e1fb6f3669e1c329$export$dd6d526d88b5a137(props, state, ref) {
|
|
|
456
456
|
// Exception made if focus isn't within the virtualizer (e.g. opening a picker via click should scroll the selected item into view)
|
|
457
457
|
let modality = (0, $kYtlh$reactariainteractions.getInteractionModality)();
|
|
458
458
|
if (focusedKey !== lastFocusedKey.current && (modality !== "pointer" || !isFocusWithin.current)) {
|
|
459
|
-
if (scrollToItem)
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
459
|
+
if (scrollToItem) // If user provides scrolltoitem, then it is their responsibility to call scrollIntoViewport if desired
|
|
460
|
+
// since we don't know if their scrollToItem may take some time to actually bring the active element into the virtualizer's visible rect.
|
|
461
|
+
scrollToItem(focusedKey);
|
|
462
|
+
else {
|
|
463
|
+
virtualizer.scrollToItem(focusedKey, {
|
|
464
|
+
duration: 0
|
|
465
|
+
});
|
|
466
|
+
if (modality === "keyboard" && ref.current.contains(document.activeElement)) (0, $kYtlh$reactariautils.scrollIntoViewport)(document.activeElement, {
|
|
467
|
+
containingElement: ref.current
|
|
468
|
+
});
|
|
469
|
+
}
|
|
463
470
|
}
|
|
464
471
|
lastFocusedKey.current = focusedKey;
|
|
465
472
|
}, [
|
|
@@ -467,7 +474,8 @@ function $e1fb6f3669e1c329$export$dd6d526d88b5a137(props, state, ref) {
|
|
|
467
474
|
virtualizer.visibleRect.height,
|
|
468
475
|
virtualizer,
|
|
469
476
|
lastFocusedKey,
|
|
470
|
-
scrollToItem
|
|
477
|
+
scrollToItem,
|
|
478
|
+
ref
|
|
471
479
|
]);
|
|
472
480
|
// Persist the focusedKey and prevent it from being removed from the DOM when scrolled out of view.
|
|
473
481
|
virtualizer.persistedKeys = (0, $kYtlh$react.useMemo)(()=>focusedKey ? new Set([
|
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,CAAC;IAED,OAAO;AACT;AAEO,SAAS,0CAAc,IAAa,EAAE,SAAoB,EAAU;IACzE,IAAI,cAAC,WAAU,EAAC,GAAG;IAEnB,mEAAmE;IACnE,qDAAqD;IACrD,IAAI,cAAc,OAAO;QACvB,IAAI,eAAC,YAAW,eAAE,YAAW,EAAC,GAAG;QACjC,OAAQ;YACN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AC3F,+FAA+F;IAC/F,wFAAwF;IACxF,wGAAwG;IACxG,IAAI;IACJ,IAAI,CAAC,uBACH,sGAAsG;IACtG,sGAAsG;IACtG,qEAAqE;IACrE,WAAW,eAAe,mBAAmB,KAAK,CAAC;IAGrD,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;;CDpNC,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/useHasTabbableChild.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, 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 {useHasTabbableChild} from './useHasTabbableChild';\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 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\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 scrollToItem(focusedKey);\n } else {\n virtualizer.scrollToItem(focusedKey, {duration: 0});\n }\n }\n\n lastFocusedKey.current = focusedKey;\n }, [focusedKey, virtualizer.visibleRect.height, virtualizer, lastFocusedKey, scrollToItem]);\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 let hasTabbableChild = useHasTabbableChild({\n isEmpty: virtualizer.collection.size === 0,\n hasRenderedAnything: virtualizer.contentSize.height > 0 || virtualizer.contentSize.width > 0\n }, ref);\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 || hasTabbableChild ? -1 : 0;\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 2022 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 {getFocusableTreeWalker} from '@react-aria/focus';\nimport {RefObject, useEffect, useState} from 'react';\n\ninterface AriaHasTabbableChildProps {\n isEmpty: boolean,\n hasRenderedAnything: boolean\n}\n\n// This was created for a special empty case of a component that can have child or\n// be empty, like Collection/Virtualizer/Table/ListView/etc. When these components\n// are empty they can have a message with a tabbable element, which is like them\n// being not empty, when it comes to focus and tab order.\n//\n// This looks at the element's children and determines if any are tabbable.\nexport function useHasTabbableChild({isEmpty, hasRenderedAnything}: AriaHasTabbableChildProps, ref: RefObject<HTMLElement>): boolean {\n let [hasTabbableChild, setHasTabbableChild] = useState(false);\n\n useEffect(() => {\n if (ref?.current && isEmpty && hasRenderedAnything) {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setHasTabbableChild(!!walker.nextNode());\n }\n }, [ref, isEmpty, hasRenderedAnything]);\n\n return hasTabbableChild;\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 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,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,CAAC;IAED,OAAO;AACT;AAEO,SAAS,0CAAc,IAAa,EAAE,SAAoB,EAAU;IACzE,IAAI,cAAC,WAAU,EAAC,GAAG;IAEnB,mEAAmE;IACnE,qDAAqD;IACrD,IAAI,cAAc,OAAO;QACvB,IAAI,eAAC,YAAW,eAAE,YAAW,EAAC,GAAG;QACjC,OAAQ;YACN,KAAK;gBACH,aAAa,CAAC;gBACd,KAAM;YACR,KAAK;gBACH,aAAa,cAAc,cAAc;gBACzC,KAAM;QACV;IACF,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;QACzC,qBAAqB,YAAY,WAAW,CAAC,MAAM,GAAG,KAAK,YAAY,WAAW,CAAC,KAAK,GAAG;IAC7F,GAAG;IAEH,2FAA2F;IAC3F,+FAA+F;IAC/F,wFAAwF;IACxF,wGAAwG;IACxG,IAAI;IACJ,IAAI,CAAC,uBACH,sGAAsG;IACtG,sGAAsG;IACtG,qEAAqE;IACrE,WAAW,eAAe,mBAAmB,KAAK,CAAC;IAGrD,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;;CDzNC,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/useHasTabbableChild.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 {useHasTabbableChild} from './useHasTabbableChild';\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 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 let hasTabbableChild = useHasTabbableChild({\n isEmpty: virtualizer.collection.size === 0,\n hasRenderedAnything: virtualizer.contentSize.height > 0 || virtualizer.contentSize.width > 0\n }, ref);\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 || hasTabbableChild ? -1 : 0;\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 2022 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 {getFocusableTreeWalker} from '@react-aria/focus';\nimport {RefObject, useEffect, useState} from 'react';\n\ninterface AriaHasTabbableChildProps {\n isEmpty: boolean,\n hasRenderedAnything: boolean\n}\n\n// This was created for a special empty case of a component that can have child or\n// be empty, like Collection/Virtualizer/Table/ListView/etc. When these components\n// are empty they can have a message with a tabbable element, which is like them\n// being not empty, when it comes to focus and tab order.\n//\n// This looks at the element's children and determines if any are tabbable.\nexport function useHasTabbableChild({isEmpty, hasRenderedAnything}: AriaHasTabbableChildProps, ref: RefObject<HTMLElement>): boolean {\n let [hasTabbableChild, setHasTabbableChild] = useState(false);\n\n useEffect(() => {\n if (ref?.current && isEmpty && hasRenderedAnything) {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setHasTabbableChild(!!walker.nextNode());\n }\n }, [ref, isEmpty, hasRenderedAnything]);\n\n return hasTabbableChild;\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 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"}
|
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useLayoutEffect as $kSaV5$useLayoutEffect, mergeProps as $kSaV5$mergeProps, focusWithoutScrolling as $kSaV5$focusWithoutScrolling, useResizeObserver as $kSaV5$useResizeObserver} from "@react-aria/utils";
|
|
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
2
|
import {getInteractionModality as $kSaV5$getInteractionModality} from "@react-aria/interactions";
|
|
3
3
|
import {useVirtualizerState as $kSaV5$useVirtualizerState, Rect as $kSaV5$Rect, Size as $kSaV5$Size} from "@react-stately/virtualizer";
|
|
4
4
|
import $kSaV5$react, {useRef as $kSaV5$useRef, useCallback as $kSaV5$useCallback, useEffect as $kSaV5$useEffect, useMemo as $kSaV5$useMemo, useState as $kSaV5$useState} from "react";
|
|
@@ -440,10 +440,17 @@ function $6d0a5c394373ae64$export$dd6d526d88b5a137(props, state, ref) {
|
|
|
440
440
|
// Exception made if focus isn't within the virtualizer (e.g. opening a picker via click should scroll the selected item into view)
|
|
441
441
|
let modality = (0, $kSaV5$getInteractionModality)();
|
|
442
442
|
if (focusedKey !== lastFocusedKey.current && (modality !== "pointer" || !isFocusWithin.current)) {
|
|
443
|
-
if (scrollToItem)
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
443
|
+
if (scrollToItem) // If user provides scrolltoitem, then it is their responsibility to call scrollIntoViewport if desired
|
|
444
|
+
// since we don't know if their scrollToItem may take some time to actually bring the active element into the virtualizer's visible rect.
|
|
445
|
+
scrollToItem(focusedKey);
|
|
446
|
+
else {
|
|
447
|
+
virtualizer.scrollToItem(focusedKey, {
|
|
448
|
+
duration: 0
|
|
449
|
+
});
|
|
450
|
+
if (modality === "keyboard" && ref.current.contains(document.activeElement)) (0, $kSaV5$scrollIntoViewport)(document.activeElement, {
|
|
451
|
+
containingElement: ref.current
|
|
452
|
+
});
|
|
453
|
+
}
|
|
447
454
|
}
|
|
448
455
|
lastFocusedKey.current = focusedKey;
|
|
449
456
|
}, [
|
|
@@ -451,7 +458,8 @@ function $6d0a5c394373ae64$export$dd6d526d88b5a137(props, state, ref) {
|
|
|
451
458
|
virtualizer.visibleRect.height,
|
|
452
459
|
virtualizer,
|
|
453
460
|
lastFocusedKey,
|
|
454
|
-
scrollToItem
|
|
461
|
+
scrollToItem,
|
|
462
|
+
ref
|
|
455
463
|
]);
|
|
456
464
|
// Persist the focusedKey and prevent it from being removed from the DOM when scrolled out of view.
|
|
457
465
|
virtualizer.persistedKeys = (0, $kSaV5$useMemo)(()=>focusedKey ? new Set([
|
package/dist/module.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,M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","packages/@react-aria/virtualizer/src/ScrollView.tsx","packages/@react-aria/virtualizer/src/utils.ts","packages/@react-aria/virtualizer/src/useHasTabbableChild.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, 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 {useHasTabbableChild} from './useHasTabbableChild';\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 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\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 scrollToItem(focusedKey);\n } else {\n virtualizer.scrollToItem(focusedKey, {duration: 0});\n }\n }\n\n lastFocusedKey.current = focusedKey;\n }, [focusedKey, virtualizer.visibleRect.height, virtualizer, lastFocusedKey, scrollToItem]);\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 let hasTabbableChild = useHasTabbableChild({\n isEmpty: virtualizer.collection.size === 0,\n hasRenderedAnything: virtualizer.contentSize.height > 0 || virtualizer.contentSize.width > 0\n }, ref);\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 || hasTabbableChild ? -1 : 0;\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 2022 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 {getFocusableTreeWalker} from '@react-aria/focus';\nimport {RefObject, useEffect, useState} from 'react';\n\ninterface AriaHasTabbableChildProps {\n isEmpty: boolean,\n hasRenderedAnything: boolean\n}\n\n// This was created for a special empty case of a component that can have child or\n// be empty, like Collection/Virtualizer/Table/ListView/etc. When these components\n// are empty they can have a message with a tabbable element, which is like them\n// being not empty, when it comes to focus and tab order.\n//\n// This looks at the element's children and determines if any are tabbable.\nexport function useHasTabbableChild({isEmpty, hasRenderedAnything}: AriaHasTabbableChildProps, ref: RefObject<HTMLElement>): boolean {\n let [hasTabbableChild, setHasTabbableChild] = useState(false);\n\n useEffect(() => {\n if (ref?.current && isEmpty && hasRenderedAnything) {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setHasTabbableChild(!!walker.nextNode());\n }\n }, [ref, isEmpty, hasRenderedAnything]);\n\n return hasTabbableChild;\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 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":"module.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,MAA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DzNC,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/useHasTabbableChild.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 {useHasTabbableChild} from './useHasTabbableChild';\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 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 let hasTabbableChild = useHasTabbableChild({\n isEmpty: virtualizer.collection.size === 0,\n hasRenderedAnything: virtualizer.contentSize.height > 0 || virtualizer.contentSize.width > 0\n }, ref);\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 || hasTabbableChild ? -1 : 0;\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 2022 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 {getFocusableTreeWalker} from '@react-aria/focus';\nimport {RefObject, useEffect, useState} from 'react';\n\ninterface AriaHasTabbableChildProps {\n isEmpty: boolean,\n hasRenderedAnything: boolean\n}\n\n// This was created for a special empty case of a component that can have child or\n// be empty, like Collection/Virtualizer/Table/ListView/etc. When these components\n// are empty they can have a message with a tabbable element, which is like them\n// being not empty, when it comes to focus and tab order.\n//\n// This looks at the element's children and determines if any are tabbable.\nexport function useHasTabbableChild({isEmpty, hasRenderedAnything}: AriaHasTabbableChildProps, ref: RefObject<HTMLElement>): boolean {\n let [hasTabbableChild, setHasTabbableChild] = useState(false);\n\n useEffect(() => {\n if (ref?.current && isEmpty && hasRenderedAnything) {\n // Detect if there are any tabbable elements and update the tabIndex accordingly.\n let walker = getFocusableTreeWalker(ref.current, {tabbable: true});\n setHasTabbableChild(!!walker.nextNode());\n }\n }, [ref, isEmpty, hasRenderedAnything]);\n\n return hasTabbableChild;\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 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":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAcA,4BACI,UAAU,GACV,qBAAqB,GACrB,oBAAoB,CAAC;AAezB,iCAAiC,WAAW,GAAE,OAAe,GAAG,aAAa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AAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IAClC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED,+BAA+B,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC;;;qBAoC/G,UAAU;oBAiBX,UAAU;;EAqCxC;AAID,OAAA,MAAM;UAA6G,UAAU,cAAc,CAAC;MAAM,YAAY,CAAC","sources":["packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/utils.ts","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/ScrollView.tsx","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/useHasTabbableChild.ts","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/useVirtualizerItem.ts","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/VirtualizerItem.tsx","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/Virtualizer.tsx","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/index.ts","packages/@react-aria/virtualizer/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\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"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/virtualizer",
|
|
3
|
-
"version": "3.6.2-nightly.
|
|
3
|
+
"version": "3.6.2-nightly.3682+c53cfb204",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"url": "https://github.com/adobe/react-spectrum"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@react-aria/focus": "3.0.0-nightly.
|
|
21
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
22
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
23
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
24
|
-
"@react-stately/virtualizer": "3.4.2-nightly.
|
|
25
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
20
|
+
"@react-aria/focus": "3.0.0-nightly.1982+c53cfb204",
|
|
21
|
+
"@react-aria/i18n": "3.0.0-nightly.1982+c53cfb204",
|
|
22
|
+
"@react-aria/interactions": "3.0.0-nightly.1982+c53cfb204",
|
|
23
|
+
"@react-aria/utils": "3.0.0-nightly.1982+c53cfb204",
|
|
24
|
+
"@react-stately/virtualizer": "3.4.2-nightly.3682+c53cfb204",
|
|
25
|
+
"@react-types/shared": "3.0.0-nightly.1982+c53cfb204",
|
|
26
26
|
"@swc/helpers": "^0.4.14"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "c53cfb204f6977e1ac620fdfa841ffdcf567c5f0"
|
|
36
36
|
}
|
package/src/Virtualizer.tsx
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {Collection} from '@react-types/shared';
|
|
14
|
-
import {focusWithoutScrolling, mergeProps, useLayoutEffect} from '@react-aria/utils';
|
|
14
|
+
import {focusWithoutScrolling, mergeProps, scrollIntoViewport, useLayoutEffect} from '@react-aria/utils';
|
|
15
15
|
import {getInteractionModality} from '@react-aria/interactions';
|
|
16
16
|
import {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer';
|
|
17
17
|
import React, {FocusEvent, HTMLAttributes, Key, ReactElement, RefObject, useCallback, useEffect, useMemo, useRef} from 'react';
|
|
@@ -121,7 +121,6 @@ interface VirtualizerOptions {
|
|
|
121
121
|
export function useVirtualizer<T extends object, V, W>(props: VirtualizerOptions, state: VirtualizerState<T, V, W>, ref: RefObject<HTMLElement>) {
|
|
122
122
|
let {focusedKey, scrollToItem, shouldUseVirtualFocus} = props;
|
|
123
123
|
let {virtualizer} = state;
|
|
124
|
-
|
|
125
124
|
// Scroll to the focusedKey when it changes. Actually focusing the focusedKey
|
|
126
125
|
// is up to the implementation using Virtualizer since we don't have refs
|
|
127
126
|
// to all of the item DOM nodes.
|
|
@@ -137,14 +136,20 @@ export function useVirtualizer<T extends object, V, W>(props: VirtualizerOptions
|
|
|
137
136
|
let modality = getInteractionModality();
|
|
138
137
|
if (focusedKey !== lastFocusedKey.current && (modality !== 'pointer' || !isFocusWithin.current)) {
|
|
139
138
|
if (scrollToItem) {
|
|
139
|
+
// If user provides scrolltoitem, then it is their responsibility to call scrollIntoViewport if desired
|
|
140
|
+
// since we don't know if their scrollToItem may take some time to actually bring the active element into the virtualizer's visible rect.
|
|
140
141
|
scrollToItem(focusedKey);
|
|
141
142
|
} else {
|
|
142
143
|
virtualizer.scrollToItem(focusedKey, {duration: 0});
|
|
144
|
+
|
|
145
|
+
if (modality === 'keyboard' && ref.current.contains(document.activeElement)) {
|
|
146
|
+
scrollIntoViewport(document.activeElement, {containingElement: ref.current});
|
|
147
|
+
}
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
lastFocusedKey.current = focusedKey;
|
|
147
|
-
}, [focusedKey, virtualizer.visibleRect.height, virtualizer, lastFocusedKey, scrollToItem]);
|
|
152
|
+
}, [focusedKey, virtualizer.visibleRect.height, virtualizer, lastFocusedKey, scrollToItem, ref]);
|
|
148
153
|
|
|
149
154
|
// Persist the focusedKey and prevent it from being removed from the DOM when scrolled out of view.
|
|
150
155
|
virtualizer.persistedKeys = useMemo(() => focusedKey ? new Set([focusedKey]) : new Set(), [focusedKey]);
|