diff --git a/core/dimensions-model/src/types/ListDimensionsModel.types.ts b/core/dimensions-model/src/types/ListDimensionsModel.types.ts index d561fa0f..ca59a1d2 100644 --- a/core/dimensions-model/src/types/ListDimensionsModel.types.ts +++ b/core/dimensions-model/src/types/ListDimensionsModel.types.ts @@ -12,6 +12,7 @@ import { IMasonryDimensions, IMasonryDimensionsModel, } from '@infinite-list/types'; +import { RecyclerProps } from '@infinite-list/strategies'; import { IDefaultKeyExtra } from '@infinite-list/utils'; export type GetItemSeparatorLength = ( @@ -42,6 +43,7 @@ export type OnListDimensionsModelDataChanged< export interface ListDimensionsModelProps< ItemT extends GenericItemT = GenericItemT > extends ListBaseDimensionsProps, + RecyclerProps, BaseDimensionsProps { /** * @template ItemT the generic data item type @@ -84,8 +86,6 @@ export interface ListDimensionsModelProps< */ manuallyApplyInitialData?: boolean; - recyclerTypes?: Array; - onListDimensionsModelDataChanged?: OnListDimensionsModelDataChanged; } diff --git a/core/strategies/src/RecycleStateImpl.ts b/core/strategies/src/RecycleStateImpl.ts index 23b0df33..5cdf8cd8 100644 --- a/core/strategies/src/RecycleStateImpl.ts +++ b/core/strategies/src/RecycleStateImpl.ts @@ -78,7 +78,6 @@ class RecycleStateImpl< (indexInfo as ListGroupIndexInfo)?.indexInGroup || indexInfo?.index; if (typeof index !== 'number') { - console.log('meta ', meta); console.error( '[RecycleStateImpl error]: index should has a valid number ' + 'or will cause recycler not work correctly' diff --git a/core/strategies/src/types/stateHub.types.ts b/core/strategies/src/types/stateHub.types.ts index 5c423906..0efd6d84 100644 --- a/core/strategies/src/types/stateHub.types.ts +++ b/core/strategies/src/types/stateHub.types.ts @@ -9,6 +9,13 @@ export type BaseStateImplProps = { export type SpaceStateImplProps = {} & BaseStateImplProps; +export type RecyclerProps = { + recyclerTypes?: string[]; + recyclerBufferSize?: number; + recyclerReservedBufferPerBatch?: number; + onRecyclerProcess?: (type?: string, index?: number) => boolean; +}; + export type RecycleStateImplProps = { recyclerTypes?: string[]; recyclerBufferSize?: number; diff --git a/examples/react-playground/src/app/group.stories.tsx b/examples/react-playground/src/app/group.stories.tsx index 05366d94..39a65173 100644 --- a/examples/react-playground/src/app/group.stories.tsx +++ b/examples/react-playground/src/app/group.stories.tsx @@ -27,13 +27,15 @@ const meta: Meta = { // overflowY: 'auto', }} > - + ) => { const { item } = props; return ( @@ -50,15 +52,12 @@ const meta: Meta = { ); }} - keyExtractor={defaultKeyExtractor as KeyExtractor} + keyExtractor={defaultKeyExtractor} /> ) => { const { item } = props; @@ -76,7 +75,7 @@ const meta: Meta = { ); }} - keyExtractor={defaultKeyExtractor as KeyExtractor} + keyExtractor={defaultKeyExtractor} /> diff --git a/ui/group/src/react-native/index.ts b/ui/group/src/react-native/index.ts index bd80e7cd..c8389c32 100644 --- a/ui/group/src/react-native/index.ts +++ b/ui/group/src/react-native/index.ts @@ -2,4 +2,3 @@ export { default as ListGroup } from './ListGroup'; export { default as GroupList } from '../common/GroupList'; export { default as ListGroupContext } from '../common/context'; export { default as GroupListItem } from '../common/GroupDimensionItem'; -export * from './types'; diff --git a/ui/group/src/react-native/types/ListGroup.types.ts b/ui/group/src/react-native/types/ListGroup.types.ts index cd2c0596..cf2d2e47 100644 --- a/ui/group/src/react-native/types/ListGroup.types.ts +++ b/ui/group/src/react-native/types/ListGroup.types.ts @@ -1,13 +1,8 @@ -import { - OnEndReachedHelperProps, - ViewabilityConfig, - OnViewableItemsChanged, - ViewabilityConfigCallbackPairs, -} from '@infinite-list/viewable'; -import { ComponentType, PropsWithChildren, MutableRefObject } from 'react'; +import { MutableRefObject } from 'react'; import { View, ScrollView, LayoutChangeEvent } from 'react-native'; -import { GenericItemT } from '@infinite-list/item-meta'; +import { GenericItemT } from '@infinite-list/types'; import { RefObject } from 'react'; +import { ListGroupProps as CommonListGroupProps } from '../../types'; export type ScrollComponentUseMeasureLayout = ( itemRef: MutableRefObject, @@ -24,19 +19,5 @@ export type ScrollComponentUseMeasureLayout = ( export type ContainerRef = RefObject; -export type ListGroupProps = PropsWithChildren<{ - id: string; - onViewableItemsChanged?: OnViewableItemsChanged; - viewabilityConfig?: ViewabilityConfig; - viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs; - initialNumToRender?: number; - windowSize?: number; - maxToRenderPerBatch?: number; - onRenderFinished?: () => void; - persistanceIndices?: number[]; - - scrollComponentContext: any; - containerRef: ContainerRef; - GroupListSeparatorComponent?: ComponentType | null | undefined; -}> & - OnEndReachedHelperProps; +export type ListGroupProps = + CommonListGroupProps; diff --git a/ui/group/src/react/index.ts b/ui/group/src/react/index.ts index bd80e7cd..c8389c32 100644 --- a/ui/group/src/react/index.ts +++ b/ui/group/src/react/index.ts @@ -2,4 +2,3 @@ export { default as ListGroup } from './ListGroup'; export { default as GroupList } from '../common/GroupList'; export { default as ListGroupContext } from '../common/context'; export { default as GroupListItem } from '../common/GroupDimensionItem'; -export * from './types'; diff --git a/ui/group/src/react/types/ListGroup.types.ts b/ui/group/src/react/types/ListGroup.types.ts index 2a5d8fcf..82d7ae75 100644 --- a/ui/group/src/react/types/ListGroup.types.ts +++ b/ui/group/src/react/types/ListGroup.types.ts @@ -1,11 +1,7 @@ -import { - OnEndReachedHelperProps, - ViewabilityConfig, - OnViewableItemsChanged, - ViewabilityConfigCallbackPairs, -} from '@infinite-list/viewable'; -import { ComponentType, PropsWithChildren, MutableRefObject } from 'react'; +import { MutableRefObject } from 'react'; import { View, LayoutChangeEvent } from 'react-native'; +import { GenericItemT } from '@infinite-list/types'; +import { ListGroupProps as CommonListGroupProps } from '../../types'; export type ScrollComponentUseMeasureLayout = ( itemRef: MutableRefObject, @@ -20,18 +16,5 @@ export type ScrollComponentUseMeasureLayout = ( layoutHandler: (e: LayoutChangeEvent) => void; }; -export type ListGroupProps = PropsWithChildren<{ - GroupListSeparatorComponent?: ComponentType | null | undefined; - id: string; - onViewableItemsChanged?: OnViewableItemsChanged; - viewabilityConfig?: ViewabilityConfig; - viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs; - initialNumToRender?: number; - windowSize?: number; - maxToRenderPerBatch?: number; - onRenderFinished?: () => void; - persistanceIndices?: number[]; - - scrollComponentContext: any; -}> & - OnEndReachedHelperProps; +export type ListGroupProps = + CommonListGroupProps; diff --git a/ui/group/src/types/ListGroup.types.ts b/ui/group/src/types/ListGroup.types.ts index 43ee06e9..c035e46d 100644 --- a/ui/group/src/types/ListGroup.types.ts +++ b/ui/group/src/types/ListGroup.types.ts @@ -6,51 +6,23 @@ import { GenericItemT, } from '@infinite-list/viewable'; import { ComponentType, PropsWithChildren } from 'react'; -// import { View, LayoutChangeEvent } from 'react-native'; +import { RecyclerProps } from '@infinite-list/strategies'; -// export type ScrollComponentUseMeasureLayout = ( -// itemRef: MutableRefObject, -// options: { -// onLayout?: Function; -// getCurrentKey?: () => string; -// isIntervalTreeItem?: boolean; -// onMeasureLayout?: Function; -// } -// ) => { -// handler: Function; -// layoutHandler: (e: LayoutChangeEvent) => void; -// }; +export type ListGroupProps = PropsWithChildren< + { + id: string; + horizontal?: boolean; + onViewableItemsChanged?: OnViewableItemsChanged; + viewabilityConfig?: ViewabilityConfig; + viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs; + initialNumToRender?: number; + windowSize?: number; + maxToRenderPerBatch?: number; + onRenderFinished?: () => void; + persistanceIndices?: number[]; -// export type ListGroupProps = PropsWithChildren<{ -// GroupListSeparatorComponent?: ComponentType | null | undefined; -// id: string; -// onViewableItemsChanged?: OnViewableItemsChanged; -// viewabilityConfig?: ViewabilityConfig; -// viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs; -// initialNumToRender?: number; -// windowSize?: number; -// maxToRenderPerBatch?: number; -// onRenderFinished?: () => void; -// persistanceIndices?: number[]; - -// scrollComponentContext: any; -// scrollComponentUseMeasureLayout: ScrollComponentUseMeasureLayout; -// }> & -// OnEndReachedHelperProps; -export type ListGroupProps = PropsWithChildren<{ - GroupListSeparatorComponent?: ComponentType | null | undefined; - id: string; - horizontal?: boolean; - onViewableItemsChanged?: OnViewableItemsChanged; - viewabilityConfig?: ViewabilityConfig; - viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs; - initialNumToRender?: number; - windowSize?: number; - maxToRenderPerBatch?: number; - onRenderFinished?: () => void; - persistanceIndices?: number[]; - - scrollComponentContext?: any; - // scrollComponentUseMeasureLayout?: ScrollComponentUseMeasureLayout; -}> & - OnEndReachedHelperProps; + scrollComponentContext?: any; + GroupListSeparatorComponent?: ComponentType | null | undefined; + } & OnEndReachedHelperProps & + RecyclerProps +>;