@react-aria/virtualizer 3.10.2-nightly.4698 → 3.10.2-nightly.4700

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.
@@ -33,7 +33,7 @@ $parcel$export(module.exports, "Virtualizer", () => $e1fb6f3669e1c329$export$89b
33
33
  function $e1fb6f3669e1c329$var$Virtualizer(props, ref) {
34
34
  let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, sizeToFit: sizeToFit, scrollDirection: scrollDirection, isLoading: // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
35
  isLoading, onLoadMore: // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
- onLoadMore, focusedKey: focusedKey, layoutOptions: layoutOptions, ...otherProps } = props;
36
+ onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
37
37
  let fallbackRef = (0, $knrtk$react.useRef)(undefined);
38
38
  ref = ref || fallbackRef;
39
39
  let state = (0, $knrtk$reactstatelyvirtualizer.useVirtualizerState)({
@@ -44,11 +44,7 @@ function $e1fb6f3669e1c329$var$Virtualizer(props, ref) {
44
44
  ref.current.scrollLeft = rect.x;
45
45
  ref.current.scrollTop = rect.y;
46
46
  },
47
- persistedKeys: (0, $knrtk$react.useMemo)(()=>focusedKey != null ? new Set([
48
- focusedKey
49
- ]) : new Set(), [
50
- focusedKey
51
- ]),
47
+ persistedKeys: persistedKeys,
52
48
  layoutOptions: layoutOptions
53
49
  });
54
50
  let { virtualizerProps: virtualizerProps, scrollViewProps: scrollViewProps } = $e1fb6f3669e1c329$export$dd6d526d88b5a137(props, state, ref);
@@ -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;IAC7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Aa,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, RefObject, useCallback, useMemo, 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 focusedKey?: Key,\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 focusedKey,\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: useMemo(() => focusedKey != null ? new Set([focusedKey]) : new Set(), [focusedKey]),\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
+ {"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6BD,SAAS,kCAAsD,KAAgC,EAAE,GAAqC;IACpI,IAAI,EACF,UAAU,UAAU,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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, RefObject, 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"}
@@ -2,7 +2,7 @@ import {ScrollView as $44a6ee657928b002$export$5665e3d6be6adea} from "./ScrollVi
2
2
  import {VirtualizerItem as $ccf8a0a04e4175ae$export$6796df8ba7398521} from "./VirtualizerItem.mjs";
3
3
  import {useVirtualizerState as $9WwqA$useVirtualizerState} from "@react-stately/virtualizer";
4
4
  import {mergeProps as $9WwqA$mergeProps, useLayoutEffect as $9WwqA$useLayoutEffect} from "@react-aria/utils";
5
- import $9WwqA$react, {useRef as $9WwqA$useRef, useMemo as $9WwqA$useMemo, useCallback as $9WwqA$useCallback} from "react";
5
+ import $9WwqA$react, {useRef as $9WwqA$useRef, useCallback as $9WwqA$useCallback} from "react";
6
6
 
7
7
  /*
8
8
  * Copyright 2020 Adobe. All rights reserved.
@@ -22,7 +22,7 @@ import $9WwqA$react, {useRef as $9WwqA$useRef, useMemo as $9WwqA$useMemo, useCal
22
22
  function $6d0a5c394373ae64$var$Virtualizer(props, ref) {
23
23
  let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, sizeToFit: sizeToFit, scrollDirection: scrollDirection, isLoading: // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
24
  isLoading, onLoadMore: // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
- onLoadMore, focusedKey: focusedKey, layoutOptions: layoutOptions, ...otherProps } = props;
25
+ onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
26
26
  let fallbackRef = (0, $9WwqA$useRef)(undefined);
27
27
  ref = ref || fallbackRef;
28
28
  let state = (0, $9WwqA$useVirtualizerState)({
@@ -33,11 +33,7 @@ function $6d0a5c394373ae64$var$Virtualizer(props, ref) {
33
33
  ref.current.scrollLeft = rect.x;
34
34
  ref.current.scrollTop = rect.y;
35
35
  },
36
- persistedKeys: (0, $9WwqA$useMemo)(()=>focusedKey != null ? new Set([
37
- focusedKey
38
- ]) : new Set(), [
39
- focusedKey
40
- ]),
36
+ persistedKeys: persistedKeys,
41
37
  layoutOptions: layoutOptions
42
38
  });
43
39
  let { virtualizerProps: virtualizerProps, scrollViewProps: scrollViewProps } = $6d0a5c394373ae64$export$dd6d526d88b5a137(props, state, ref);
@@ -2,7 +2,7 @@ import {ScrollView as $44a6ee657928b002$export$5665e3d6be6adea} from "./ScrollVi
2
2
  import {VirtualizerItem as $ccf8a0a04e4175ae$export$6796df8ba7398521} from "./VirtualizerItem.module.js";
3
3
  import {useVirtualizerState as $9WwqA$useVirtualizerState} from "@react-stately/virtualizer";
4
4
  import {mergeProps as $9WwqA$mergeProps, useLayoutEffect as $9WwqA$useLayoutEffect} from "@react-aria/utils";
5
- import $9WwqA$react, {useRef as $9WwqA$useRef, useMemo as $9WwqA$useMemo, useCallback as $9WwqA$useCallback} from "react";
5
+ import $9WwqA$react, {useRef as $9WwqA$useRef, useCallback as $9WwqA$useCallback} from "react";
6
6
 
7
7
  /*
8
8
  * Copyright 2020 Adobe. All rights reserved.
@@ -22,7 +22,7 @@ import $9WwqA$react, {useRef as $9WwqA$useRef, useMemo as $9WwqA$useMemo, useCal
22
22
  function $6d0a5c394373ae64$var$Virtualizer(props, ref) {
23
23
  let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, sizeToFit: sizeToFit, scrollDirection: scrollDirection, isLoading: // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
24
  isLoading, onLoadMore: // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
- onLoadMore, focusedKey: focusedKey, layoutOptions: layoutOptions, ...otherProps } = props;
25
+ onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
26
26
  let fallbackRef = (0, $9WwqA$useRef)(undefined);
27
27
  ref = ref || fallbackRef;
28
28
  let state = (0, $9WwqA$useVirtualizerState)({
@@ -33,11 +33,7 @@ function $6d0a5c394373ae64$var$Virtualizer(props, ref) {
33
33
  ref.current.scrollLeft = rect.x;
34
34
  ref.current.scrollTop = rect.y;
35
35
  },
36
- persistedKeys: (0, $9WwqA$useMemo)(()=>focusedKey != null ? new Set([
37
- focusedKey
38
- ]) : new Set(), [
39
- focusedKey
40
- ]),
36
+ persistedKeys: persistedKeys,
41
37
  layoutOptions: layoutOptions
42
38
  });
43
39
  let { virtualizerProps: virtualizerProps, scrollViewProps: scrollViewProps } = $6d0a5c394373ae64$export$dd6d526d88b5a137(props, state, ref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AAI,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} 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, RefObject, useCallback, useMemo, 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 focusedKey?: Key,\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 focusedKey,\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: useMemo(() => focusedKey != null ? new Set([focusedKey]) : new Set(), [focusedKey]),\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 {re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A,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} 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, RefObject, 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
@@ -325,7 +325,7 @@ interface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<H
325
325
  renderWrapper?: RenderWrapper<T, V>;
326
326
  layout: Layout<T, O>;
327
327
  collection: Collection<T>;
328
- focusedKey?: Key;
328
+ persistedKeys?: Set<Key> | null;
329
329
  sizeToFit?: 'width' | 'height';
330
330
  scrollDirection?: 'horizontal' | 'vertical' | 'both';
331
331
  isLoading?: boolean;
@@ -1 +1 @@
1
- {"mappings":";;;AAcA,4BACI,UAAU,GACV,qBAAqB,GACrB,oBAAoB,CAAC;AAezB,iCAAiC,WAAW,GAAE,OAAe,GAAG,aAAa,CAmC5E;AAED,8BAA8B,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAkBzE;AAED,8BAA8B,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAiBpF;ACzFD;IACE,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;CAC3C;AAED;IACE,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,YAAY,CAAC;IAC1B,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAA;CACnC;AAED,mCAAmC,OAAO,EAAE,sBAAsB;;EAiBjE;ACdD,yBAA0B,SAAQ,eAAe,WAAW,CAAC;IAC3D,WAAW,EAAE,IAAI,CAAC;IAClB,mBAAmB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAA;CACr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ages/@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
+ {"mappings":";;;AAcA,4BACI,UAAU,GACV,qBAAqB,GACrB,oBAAoB,CAAC;AAezB,iCAAiC,WAAW,GAAE,OAAe,GAAG,aAAa,CAmC5E;AAED,8BAA8B,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAkBzE;AAED,8BAA8B,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAiBpF;ACzFD;IACE,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;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AG,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/virtualizer",
3
- "version": "3.10.2-nightly.4698+b940126e4",
3
+ "version": "3.10.2-nightly.4700+81abb2185",
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.2986+b940126e4",
26
- "@react-aria/interactions": "3.0.0-nightly.2986+b940126e4",
27
- "@react-aria/utils": "3.0.0-nightly.2986+b940126e4",
28
- "@react-stately/virtualizer": "3.7.2-nightly.4698+b940126e4",
29
- "@react-types/shared": "3.0.0-nightly.2986+b940126e4",
25
+ "@react-aria/i18n": "3.0.0-nightly.2988+81abb2185",
26
+ "@react-aria/interactions": "3.0.0-nightly.2988+81abb2185",
27
+ "@react-aria/utils": "3.0.0-nightly.2988+81abb2185",
28
+ "@react-stately/virtualizer": "3.7.2-nightly.4700+81abb2185",
29
+ "@react-types/shared": "3.0.0-nightly.2988+81abb2185",
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": "b940126e4d67a11d28b7c0b098eab23205598b6c"
39
+ "gitHead": "81abb2185cb3a9c52a8feaf76a136c64852aea13"
40
40
  }
@@ -13,7 +13,7 @@
13
13
  import {Collection, Key} 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, RefObject, useCallback, useMemo, useRef} from 'react';
16
+ import React, {HTMLAttributes, ReactElement, ReactNode, RefObject, useCallback, useRef} from 'react';
17
17
  import {ScrollView} from './ScrollView';
18
18
  import {VirtualizerItem} from './VirtualizerItem';
19
19
 
@@ -29,7 +29,7 @@ interface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<H
29
29
  renderWrapper?: RenderWrapper<T, V>,
30
30
  layout: Layout<T, O>,
31
31
  collection: Collection<T>,
32
- focusedKey?: Key,
32
+ persistedKeys?: Set<Key> | null,
33
33
  sizeToFit?: 'width' | 'height',
34
34
  scrollDirection?: 'horizontal' | 'vertical' | 'both',
35
35
  isLoading?: boolean,
@@ -49,7 +49,7 @@ function Virtualizer<T extends object, V extends ReactNode, O>(props: Virtualize
49
49
  isLoading,
50
50
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
51
51
  onLoadMore,
52
- focusedKey,
52
+ persistedKeys,
53
53
  layoutOptions,
54
54
  ...otherProps
55
55
  } = props;
@@ -65,7 +65,7 @@ function Virtualizer<T extends object, V extends ReactNode, O>(props: Virtualize
65
65
  ref.current.scrollLeft = rect.x;
66
66
  ref.current.scrollTop = rect.y;
67
67
  },
68
- persistedKeys: useMemo(() => focusedKey != null ? new Set([focusedKey]) : new Set(), [focusedKey]),
68
+ persistedKeys,
69
69
  layoutOptions
70
70
  });
71
71