@react-aria/virtualizer 3.10.2-nightly.4700 → 3.10.2-nightly.4704
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/Virtualizer.main.js.map +1 -1
- package/dist/Virtualizer.module.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/useVirtualizerItem.main.js.map +1 -1
- package/dist/useVirtualizerItem.module.js.map +1 -1
- package/package.json +7 -7
- package/src/Virtualizer.tsx +2 -2
- package/src/useVirtualizerItem.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6BD,SAAS,kCAAsD,KAAgC,EAAE,GAAqC;IACpI,IAAI,EACF,UAAU,UAAU,iBACpB,aAAa,UACb,MAAM,cACN,UAAU,aACV,SAAS,mBACT,eAAe,aACf,6DAA6D;IAC7D,SAAS,cACT,6DAA6D;IAC7D,UAAU,iBACV,aAAa,iBACb,aAAa,EACb,GAAG,YACJ,GAAG;IAEJ,IAAI,cAAc,CAAA,GAAA,mBAAK,EAAkB;IACzC,MAAM,OAAO;IAEb,IAAI,QAAQ,CAAA,GAAA,kDAAkB,EAAE;gBAC9B;oBACA;oBACA;QACA,qBAAoB,IAAI;YACtB,IAAI,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;YAC/B,IAAI,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;QAChC;uBACA;uBACA;IACF;IAEA,IAAI,oBAAC,gBAAgB,mBAAE,eAAe,EAAC,GAAG,0CAAe,OAAO,OAAO;IAEvE,qBACE,0DAAC,CAAA,GAAA,oCAAS;QACP,GAAG,CAAA,GAAA,gCAAS,EAAE,YAAY,kBAAkB,gBAAgB;QAC7D,KAAK;QACL,aAAa,MAAM,WAAW;QAC9B,eAAe,MAAM,cAAc;QACnC,aAAa,MAAM,YAAY;QAC/B,WAAW;QACX,iBAAi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vE,OAAO;QACL,kBAAkB,CAAC;QACnB,iBAAiB;iCACf;QACF;IACF;AACF;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC;AAGtC,SAAS,qCAAoC,MAAiC,EAAE,KAA2B,EAAE,aAAkC;IAC7I,OAAO,MAAM,GAAG,CAAC,CAAA;QACf,OAAO,cACL,QACA,MACA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,QAAQ,IAAI,EAAE,EAC9C,CAAA,aAAc,qCAAe,MAAM,YAAY;IAEnD;AACF;AAEA,SAAS,2CACP,MAAiC,EACjC,YAAgC;IAEhC,qBACE,0DAAC,CAAA,GAAA,yCAAc;QACb,KAAK,aAAa,GAAG;QACrB,YAAY,aAAa,UAAU;QACnC,aAAa,aAAa,WAAW;QACrC,MAAM,EAAE,mBAAA,6BAAA,OAAQ,UAAU;OACzB,aAAa,QAAQ;AAG5B","sources":["packages/@react-aria/virtualizer/src/Virtualizer.tsx"],"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\nimport {Collection, Key} from '@react-types/shared';\nimport {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLayoutEffect} from '@react-aria/utils';\nimport React, {HTMLAttributes, ReactElement, ReactNode,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6BD,SAAS,kCAAsD,KAAgC,EAAE,GAAqC;IACpI,IAAI,EACF,UAAU,UA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Aa,WAAW;QACrC,MAAM,EAAE,mBAAA,6BAAA,OAAQ,UAAU;OACzB,aAAa,QAAQ;AAG5B","sources":["packages/@react-aria/virtualizer/src/Virtualizer.tsx"],"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\nimport {Collection, Key, RefObject} from '@react-types/shared';\nimport {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLayoutEffect} from '@react-aria/utils';\nimport React, {HTMLAttributes, ReactElement, ReactNode, useCallback, useRef} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ntype RenderWrapper<T extends object, V> = (\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\ninterface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n children: (type: string, content: T) => V,\n renderWrapper?: RenderWrapper<T, V>,\n layout: Layout<T, O>,\n collection: Collection<T>,\n persistedKeys?: Set<Key> | null,\n sizeToFit?: 'width' | 'height',\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n isLoading?: boolean,\n onLoadMore?: () => void,\n layoutOptions?: O\n}\n\nfunction Virtualizer<T extends object, V extends ReactNode, O>(props: VirtualizerProps<T, V, O>, ref: RefObject<HTMLDivElement | null>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n sizeToFit,\n scrollDirection,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isLoading,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onLoadMore,\n persistedKeys,\n layoutOptions,\n ...otherProps\n } = props;\n\n let fallbackRef = useRef<HTMLDivElement>(undefined);\n ref = ref || fallbackRef;\n\n let state = useVirtualizerState({\n layout,\n collection,\n renderView,\n onVisibleRectChange(rect) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n },\n persistedKeys,\n layoutOptions\n });\n\n let {virtualizerProps, scrollViewProps} = useVirtualizer(props, state, ref);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, virtualizerProps, scrollViewProps)}\n ref={ref}\n contentSize={state.contentSize}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n sizeToFit={sizeToFit}\n scrollDirection={scrollDirection}>\n {renderChildren(null, state.visibleViews, renderWrapper || defaultRenderWrapper)}\n </ScrollView>\n );\n}\n\ninterface VirtualizerOptions {\n tabIndex?: number,\n focusedKey?: Key,\n isLoading?: boolean,\n onLoadMore?: () => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useVirtualizer<T extends object, V extends ReactNode, W>(props: VirtualizerOptions, state: VirtualizerState<T, V>, ref: RefObject<HTMLElement | null>) {\n let {isLoading, onLoadMore} = props;\n let {setVisibleRect, virtualizer} = state;\n\n // Handle scrolling, and call onLoadMore when nearing the bottom.\n let isLoadingRef = useRef(isLoading);\n let prevProps = useRef(props);\n let onVisibleRectChange = useCallback((rect: Rect) => {\n setVisibleRect(rect);\n\n if (!isLoadingRef.current && onLoadMore) {\n let scrollOffset = virtualizer.contentSize.height - rect.height * 2;\n if (rect.y > scrollOffset) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n }\n }, [onLoadMore, setVisibleRect, virtualizer]);\n\n let lastContentSize = useRef(0);\n useLayoutEffect(() => {\n // Only update isLoadingRef if props object actually changed,\n // not if a local state change occurred.\n let wasLoading = isLoadingRef.current;\n if (props !== prevProps.current) {\n isLoadingRef.current = isLoading;\n prevProps.current = props;\n }\n\n let shouldLoadMore = !isLoadingRef.current\n && onLoadMore\n && state.contentSize.height > 0\n && state.contentSize.height <= state.virtualizer.visibleRect.height\n // Only try loading more if the content size changed, or if we just finished\n // loading and still have room for more items.\n && (wasLoading || state.contentSize.height !== lastContentSize.current);\n\n if (shouldLoadMore) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n lastContentSize.current = state.contentSize.height;\n }, [state.contentSize, state.virtualizer, isLoading, onLoadMore, props]);\n\n return {\n virtualizerProps: {},\n scrollViewProps: {\n onVisibleRectChange\n }\n };\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _Virtualizer = React.forwardRef(Virtualizer) as <T extends object, V, O>(props: VirtualizerProps<T, V, O> & {ref?: RefObject<HTMLDivElement | null>}) => ReactElement;\nexport {_Virtualizer as Virtualizer};\n\nfunction renderChildren<T extends object, V>(parent: ReusableView<T, V> | null, views: ReusableView<T, V>[], renderWrapper: RenderWrapper<T, V>) {\n return views.map(view => {\n return renderWrapper(\n parent,\n view,\n view.children ? Array.from(view.children) : [],\n childViews => renderChildren(view, childViews, renderWrapper)\n );\n });\n}\n\nfunction defaultRenderWrapper<T extends object, V extends ReactNode>(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>\n) {\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n}\n"],"names":[],"version":3,"file":"Virtualizer.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6BD,SAAS,kCAAsD,KAAgC,EAAE,GAAqC;IACpI,IAAI,EACF,UAAU,UAAU,iBACpB,aAAa,UACb,MAAM,cACN,UAAU,aACV,SAAS,mBACT,eA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Aa,QAAQ;AAG5B","sources":["packages/@react-aria/virtualizer/src/Virtualizer.tsx"],"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\nimport {Collection, Key} from '@react-types/shared';\nimport {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLayoutEffect} from '@react-aria/utils';\nimport React, {HTMLAttributes, ReactElement, ReactNode,
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6BD,SAAS,kCAAsD,KAAgC,EAAE,GAAqC;IACpI,IAAI,EACF,UAAU,UAAU,iBACpB,aAAa,UACb,MAAM,cACN,UAAU,aACV,SAAS,mBACT,eAAe,aACf,6DAA6D;IAC7D,SAAS,cACT,6DAA6D;IAC7D,UAAU,iBACV,aAAa,iBACb,aAAa,EACb,GAAG,YACJ,GAAG;IAEJ,IAAI,cAAc,CAAA,GAAA,aAAK,EAAkB;IACzC,MAAM,OAAO;IAEb,IAAI,QAAQ,CAAA,GAAA,0BAAkB,EAAE;gBAC9B;oBACA;oBACA;QACA,qBAAoB,IAAI;YACtB,IAAI,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;YAC/B,IAAI,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;QAChC;uBACA;uBACA;IACF;IAEA,IAAI,oBAAC,gBAAgB,mBAAE,eAAe,EAAC,GAAG,0CAAe,OAAO,OAAO;IAEvE,qBACE,gCAAC,CAAA,GAAA,wCAAS;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,kBAAkB,gBAAg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O,GAAG,MAAM,WAAW,CAAC,MAAM;IACpD,GAAG;QAAC,MAAM,WAAW;QAAE,MAAM,WAAW;QAAE;QAAW;QAAY;KAAM;IAEvE,OAAO;QACL,kBAAkB,CAAC;QACnB,iBAAiB;iCACf;QACF;IACF;AACF;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC;AAGtC,SAAS,qCAAoC,MAAiC,EAAE,KAA2B,EAAE,aAAkC;IAC7I,OAAO,MAAM,GAAG,CAAC,CAAA;QACf,OAAO,cACL,QACA,MACA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,QAAQ,IAAI,EAAE,EAC9C,CAAA,aAAc,qCAAe,MAAM,YAAY;IAEnD;AACF;AAEA,SAAS,2CACP,MAAiC,EACjC,YAAgC;IAEhC,qBACE,gCAAC,CAAA,GAAA,yCAAc;QACb,KAAK,aAAa,GAAG;QACrB,YAAY,aAAa,UAAU;QACnC,aAAa,aAAa,WAAW;QACrC,MAAM,EAAE,mBAAA,6BAAA,OAAQ,UAAU;OACzB,aAAa,QAAQ;AAG5B","sources":["packages/@react-aria/virtualizer/src/Virtualizer.tsx"],"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\nimport {Collection, Key, RefObject} from '@react-types/shared';\nimport {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLayoutEffect} from '@react-aria/utils';\nimport React, {HTMLAttributes, ReactElement, ReactNode, useCallback, useRef} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ntype RenderWrapper<T extends object, V> = (\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\ninterface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n children: (type: string, content: T) => V,\n renderWrapper?: RenderWrapper<T, V>,\n layout: Layout<T, O>,\n collection: Collection<T>,\n persistedKeys?: Set<Key> | null,\n sizeToFit?: 'width' | 'height',\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n isLoading?: boolean,\n onLoadMore?: () => void,\n layoutOptions?: O\n}\n\nfunction Virtualizer<T extends object, V extends ReactNode, O>(props: VirtualizerProps<T, V, O>, ref: RefObject<HTMLDivElement | null>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n sizeToFit,\n scrollDirection,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isLoading,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onLoadMore,\n persistedKeys,\n layoutOptions,\n ...otherProps\n } = props;\n\n let fallbackRef = useRef<HTMLDivElement>(undefined);\n ref = ref || fallbackRef;\n\n let state = useVirtualizerState({\n layout,\n collection,\n renderView,\n onVisibleRectChange(rect) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n },\n persistedKeys,\n layoutOptions\n });\n\n let {virtualizerProps, scrollViewProps} = useVirtualizer(props, state, ref);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, virtualizerProps, scrollViewProps)}\n ref={ref}\n contentSize={state.contentSize}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n sizeToFit={sizeToFit}\n scrollDirection={scrollDirection}>\n {renderChildren(null, state.visibleViews, renderWrapper || defaultRenderWrapper)}\n </ScrollView>\n );\n}\n\ninterface VirtualizerOptions {\n tabIndex?: number,\n focusedKey?: Key,\n isLoading?: boolean,\n onLoadMore?: () => void\n}\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function useVirtualizer<T extends object, V extends ReactNode, W>(props: VirtualizerOptions, state: VirtualizerState<T, V>, ref: RefObject<HTMLElement | null>) {\n let {isLoading, onLoadMore} = props;\n let {setVisibleRect, virtualizer} = state;\n\n // Handle scrolling, and call onLoadMore when nearing the bottom.\n let isLoadingRef = useRef(isLoading);\n let prevProps = useRef(props);\n let onVisibleRectChange = useCallback((rect: Rect) => {\n setVisibleRect(rect);\n\n if (!isLoadingRef.current && onLoadMore) {\n let scrollOffset = virtualizer.contentSize.height - rect.height * 2;\n if (rect.y > scrollOffset) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n }\n }, [onLoadMore, setVisibleRect, virtualizer]);\n\n let lastContentSize = useRef(0);\n useLayoutEffect(() => {\n // Only update isLoadingRef if props object actually changed,\n // not if a local state change occurred.\n let wasLoading = isLoadingRef.current;\n if (props !== prevProps.current) {\n isLoadingRef.current = isLoading;\n prevProps.current = props;\n }\n\n let shouldLoadMore = !isLoadingRef.current\n && onLoadMore\n && state.contentSize.height > 0\n && state.contentSize.height <= state.virtualizer.visibleRect.height\n // Only try loading more if the content size changed, or if we just finished\n // loading and still have room for more items.\n && (wasLoading || state.contentSize.height !== lastContentSize.current);\n\n if (shouldLoadMore) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n lastContentSize.current = state.contentSize.height;\n }, [state.contentSize, state.virtualizer, isLoading, onLoadMore, props]);\n\n return {\n virtualizerProps: {},\n scrollViewProps: {\n onVisibleRectChange\n }\n };\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _Virtualizer = React.forwardRef(Virtualizer) as <T extends object, V, O>(props: VirtualizerProps<T, V, O> & {ref?: RefObject<HTMLDivElement | null>}) => ReactElement;\nexport {_Virtualizer as Virtualizer};\n\nfunction renderChildren<T extends object, V>(parent: ReusableView<T, V> | null, views: ReusableView<T, V>[], renderWrapper: RenderWrapper<T, V>) {\n return views.map(view => {\n return renderWrapper(\n parent,\n view,\n view.children ? Array.from(view.children) : [],\n childViews => renderChildren(view, childViews, renderWrapper)\n );\n });\n}\n\nfunction defaultRenderWrapper<T extends object, V extends ReactNode>(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>\n) {\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n}\n"],"names":[],"version":3,"file":"Virtualizer.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Direction, Key, Collection } from "@react-types/shared";
|
|
1
|
+
import { Direction, Key, RefObject, Collection } from "@react-types/shared";
|
|
2
2
|
import { LayoutInfo, Size, Rect, Layout, ReusableView, VirtualizerState } from "@react-stately/virtualizer";
|
|
3
|
-
import React, {
|
|
3
|
+
import React, { CSSProperties, HTMLAttributes, ReactNode, RefObject as _RefObject1, ReactElement } from "react";
|
|
4
4
|
export type RTLOffsetType = 'negative' | 'positive-descending' | 'positive-ascending';
|
|
5
5
|
export function getRTLOffsetType(recalculate?: boolean): RTLOffsetType;
|
|
6
6
|
export function getScrollLeft(node: Element, direction: Direction): number;
|
|
@@ -27,7 +27,7 @@ interface ScrollViewProps extends HTMLAttributes<HTMLElement> {
|
|
|
27
27
|
scrollDirection?: 'horizontal' | 'vertical' | 'both';
|
|
28
28
|
}
|
|
29
29
|
export const ScrollView: React.ForwardRefExoticComponent<ScrollViewProps & React.RefAttributes<HTMLDivElement>>;
|
|
30
|
-
export function useScrollView(props: ScrollViewProps, ref:
|
|
30
|
+
export function useScrollView(props: ScrollViewProps, ref: _RefObject1<HTMLElement | null>): {
|
|
31
31
|
scrollViewProps: {
|
|
32
32
|
style: React.CSSProperties;
|
|
33
33
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IAC/B,eAAe,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,CAAA;CAClB;AAkDD;IACE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;CACxB;AAGD,+BAA+B,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC;;;oCAOtH,IAAI;;EA2ClD;AAID,OAAA,MAAM,aAAgD,CAAC,CAAgB,SAAN,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,UAAU,cAAc,GAAG,IAAI,CAAC,CAAA;CAAC,KAAK,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/useVirtualizerItem.ts","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/ScrollView.tsx","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,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {RTLOffsetType} from './utils';\nexport type {VirtualizerItemOptions} from './useVirtualizerItem';\nexport {useVirtualizer, Virtualizer} from './Virtualizer';\nexport {useVirtualizerItem} from './useVirtualizerItem';\nexport {VirtualizerItem, layoutInfoToStyle} from './VirtualizerItem';\nexport {ScrollView, useScrollView} from './ScrollView';\nexport {getRTLOffsetType, getScrollLeft, setScrollLeft} from './utils';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;IAErC,IAAI,aAAa,CAAA,GAAA,wBAAU,EAAE;QAC3B,IAAI,YAAY;YACd,IAAI,OAAO,8BAAQ,IAAI,OAAO;YAC9B,YAAY,cAAc,CAAC,WAAW,GAAG,EAAE;QAC7C;IACF,GAAG;QAAC;QAAa,uBAAA,iCAAA,WAAY,GAAG;QAAE;KAAI;IAEtC,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,uBAAA,iCAAA,WAAY,aAAa,EAC3B;IAEJ;IAEA,OAAO;oBAAC;IAAU;AACpB;AAEA,SAAS,8BAAQ,IAAiB;IAChC,6DAA6D;IAC7D,IAAI,SAAS,KAAK,KAAK,CAAC,MAAM;IAC9B,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,IAAI,OAAO,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY;IACvD,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,OAAO;AACT","sources":["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\nimport {Key} from '@react-types/shared';\nimport {LayoutInfo, Size} from '@react-stately/virtualizer';\nimport {
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;IAErC,IAAI,aAAa,CAAA,GAAA,wBAAU,EAAE;QAC3B,IAAI,YAAY;YACd,IAAI,OAAO,8BAAQ,IAAI,OAAO;YAC9B,YAAY,cAAc,CAAC,WAAW,GAAG,EAAE;QAC7C;IACF,GAAG;QAAC;QAAa,uBAAA,iCAAA,WAAY,GAAG;QAAE;KAAI;IAEtC,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,uBAAA,iCAAA,WAAY,aAAa,EAC3B;IAEJ;IAEA,OAAO;oBAAC;IAAU;AACpB;AAEA,SAAS,8BAAQ,IAAiB;IAChC,6DAA6D;IAC7D,IAAI,SAAS,KAAK,KAAK,CAAC,MAAM;IAC9B,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,IAAI,OAAO,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY;IACvD,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,OAAO;AACT","sources":["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\nimport {Key, RefObject} from '@react-types/shared';\nimport {LayoutInfo, Size} from '@react-stately/virtualizer';\nimport {useCallback} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\ninterface IVirtualizer {\n updateItemSize(key: Key, size: Size): void\n}\n\nexport interface VirtualizerItemOptions {\n layoutInfo: LayoutInfo,\n virtualizer: IVirtualizer,\n ref: RefObject<HTMLElement | null>\n}\n\nexport function useVirtualizerItem(options: VirtualizerItemOptions) {\n let {layoutInfo, virtualizer, ref} = options;\n\n let updateSize = useCallback(() => {\n if (layoutInfo) {\n let size = getSize(ref.current);\n virtualizer.updateItemSize(layoutInfo.key, size);\n }\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":"useVirtualizerItem.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;IAErC,IAAI,aAAa,CAAA,GAAA,kBAAU,EAAE;QAC3B,IAAI,YAAY;YACd,IAAI,OAAO,8BAAQ,IAAI,OAAO;YAC9B,YAAY,cAAc,CAAC,WAAW,GAAG,EAAE;QAC7C;IACF,GAAG;QAAC;QAAa,uBAAA,iCAAA,WAAY,GAAG;QAAE;KAAI;IAEtC,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,uBAAA,iCAAA,WAAY,aAAa,EAC3B;IAEJ;IAEA,OAAO;oBAAC;IAAU;AACpB;AAEA,SAAS,8BAAQ,IAAiB;IAChC,6DAA6D;IAC7D,IAAI,SAAS,KAAK,KAAK,CAAC,MAAM;IAC9B,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,IAAI,OAAO,IAAI,CAAA,GAAA,WAAG,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY;IACvD,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,OAAO;AACT","sources":["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\nimport {Key} from '@react-types/shared';\nimport {LayoutInfo, Size} from '@react-stately/virtualizer';\nimport {
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;IAErC,IAAI,aAAa,CAAA,GAAA,kBAAU,EAAE;QAC3B,IAAI,YAAY;YACd,IAAI,OAAO,8BAAQ,IAAI,OAAO;YAC9B,YAAY,cAAc,CAAC,WAAW,GAAG,EAAE;QAC7C;IACF,GAAG;QAAC;QAAa,uBAAA,iCAAA,WAAY,GAAG;QAAE;KAAI;IAEtC,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,uBAAA,iCAAA,WAAY,aAAa,EAC3B;IAEJ;IAEA,OAAO;oBAAC;IAAU;AACpB;AAEA,SAAS,8BAAQ,IAAiB;IAChC,6DAA6D;IAC7D,IAAI,SAAS,KAAK,KAAK,CAAC,MAAM;IAC9B,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,IAAI,OAAO,IAAI,CAAA,GAAA,WAAG,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY;IACvD,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,OAAO;AACT","sources":["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\nimport {Key, RefObject} from '@react-types/shared';\nimport {LayoutInfo, Size} from '@react-stately/virtualizer';\nimport {useCallback} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\ninterface IVirtualizer {\n updateItemSize(key: Key, size: Size): void\n}\n\nexport interface VirtualizerItemOptions {\n layoutInfo: LayoutInfo,\n virtualizer: IVirtualizer,\n ref: RefObject<HTMLElement | null>\n}\n\nexport function useVirtualizerItem(options: VirtualizerItemOptions) {\n let {layoutInfo, virtualizer, ref} = options;\n\n let updateSize = useCallback(() => {\n if (layoutInfo) {\n let size = getSize(ref.current);\n virtualizer.updateItemSize(layoutInfo.key, size);\n }\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":"useVirtualizerItem.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/virtualizer",
|
|
3
|
-
"version": "3.10.2-nightly.
|
|
3
|
+
"version": "3.10.2-nightly.4704+546ffa41f",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
26
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
27
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
28
|
-
"@react-stately/virtualizer": "3.7.2-nightly.
|
|
29
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
25
|
+
"@react-aria/i18n": "3.0.0-nightly.2992+546ffa41f",
|
|
26
|
+
"@react-aria/interactions": "3.0.0-nightly.2992+546ffa41f",
|
|
27
|
+
"@react-aria/utils": "3.0.0-nightly.2992+546ffa41f",
|
|
28
|
+
"@react-stately/virtualizer": "3.7.2-nightly.4704+546ffa41f",
|
|
29
|
+
"@react-types/shared": "3.0.0-nightly.2992+546ffa41f",
|
|
30
30
|
"@swc/helpers": "^0.5.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "546ffa41f7d1d3a566950a14d8f46cf726891220"
|
|
40
40
|
}
|
package/src/Virtualizer.tsx
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {Collection, Key} from '@react-types/shared';
|
|
13
|
+
import {Collection, Key, RefObject} from '@react-types/shared';
|
|
14
14
|
import {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer';
|
|
15
15
|
import {mergeProps, useLayoutEffect} from '@react-aria/utils';
|
|
16
|
-
import React, {HTMLAttributes, ReactElement, ReactNode,
|
|
16
|
+
import React, {HTMLAttributes, ReactElement, ReactNode, useCallback, useRef} from 'react';
|
|
17
17
|
import {ScrollView} from './ScrollView';
|
|
18
18
|
import {VirtualizerItem} from './VirtualizerItem';
|
|
19
19
|
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {Key} from '@react-types/shared';
|
|
13
|
+
import {Key, RefObject} from '@react-types/shared';
|
|
14
14
|
import {LayoutInfo, Size} from '@react-stately/virtualizer';
|
|
15
|
-
import {
|
|
15
|
+
import {useCallback} from 'react';
|
|
16
16
|
import {useLayoutEffect} from '@react-aria/utils';
|
|
17
17
|
|
|
18
18
|
interface IVirtualizer {
|