Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuever committed Dec 7, 2024
1 parent 6858a0b commit 2e0364d
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 20 deletions.
1 change: 0 additions & 1 deletion packages/react/src/lib/group/GroupList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const MemoedGroupList = genericMemo(
return null;
},
(prev, cur) => {
// @ts-ignore
if (cur.changed) return true;

const keys = Object.keys(prev);
Expand Down
5 changes: 3 additions & 2 deletions packages/react/src/lib/group/GroupListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const MemoedGroupListItem = genericMemo(
}
);

// @ts-ignore
const GroupListItemWrapper = (props) => {
const GroupListItemWrapper = <ItemT extends GenericItemT>(
props: GroupListItemImplProps<ItemT>
) => {
const contextValues = useContext(context);
const contextValuesRef = useRef(contextValues);

Expand Down
12 changes: 8 additions & 4 deletions packages/react/src/lib/group/GroupListItemImpl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const GroupListItemImpl = <ItemT extends DefaultItemT>(
) => {
const {
item,
listKey,
// listKey,
itemKey,
dimensions,
itemMeta,
containerKey,
Expand All @@ -30,13 +31,17 @@ const GroupListItemImpl = <ItemT extends DefaultItemT>(
const teleportProps =
typeof teleportItemProps === 'function'
? // @ts-ignore
teleportItemProps({ item, index: itemMeta.getIndexInfo?.()?.index })
teleportItemProps({
item,
index: itemMeta.getIndexInfo?.()?.index || -1,
})
: {};

return (
<ListItem<ItemT>
item={item}
listKey={listKey}
itemKey={itemKey}
// listKey={listKey}
itemMeta={itemMeta}
dimensions={dimensions}
containerKey={containerKey}
Expand All @@ -51,7 +56,6 @@ const GroupListItemImpl = <ItemT extends DefaultItemT>(
item={item}
{...teleportProps}
{...rest}
// @ts-ignore
itemMeta={itemMeta}
/>
) : null}
Expand Down
3 changes: 0 additions & 3 deletions packages/react/src/lib/group/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ const ListItem = <ItemT extends DefaultItemT>(
onLayout,
forwardRef,

// @ts-ignore
dimensions,
containerKey,
CellRendererComponent,
setMeasureLayoutHandler,
onMeasureLayout: _onMeasureLayout,
// @ts-ignore
measureLayoutHandlerOnDemand,
// @ts-ignore
getMetaOnViewableItemsChanged,
scrollComponentUseMeasureLayout,

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/lib/group/PortalContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const PortalContent = <ItemT extends GenericItemT>(
useEffect(
() =>
listGroupDimensions.addStateListener((newState) => {
setStore(newState as any as RecycleStateResult<T>);
setStore(newState as any as RecycleStateResult<ItemT>);
// setTimeout(() => setStore(newState as any as RecycleStateResult<T>));
}),
[]
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/lib/group/hooks/useMountList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default <ItemT extends DefaultItemT>(props: GroupListProps<ItemT>) => {
const dataRef = useRef(data);

useEffect(() => {
listGroupDimensions!.setOnEndReached(id, onEndReached);
if (onEndReached) listGroupDimensions!.setOnEndReached(id, onEndReached);
}, [onEndReached]);

if (initialRef.current) {
Expand Down
8 changes: 6 additions & 2 deletions packages/react/src/lib/group/types/GroupList.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import {
ListDimensionsModelProps,
OnEndReachedHelperProps,
} from '@infinite-list/data-model';
import { DefaultItemT } from './ListItem.types';
import { DefaultItemT, TeleportItemProps } from './ListItem.types';
import { RenderItem } from './GroupListItemImpl.types';

export interface GroupListProps<ItemT extends DefaultItemT>
extends ListDimensionsModelProps<ItemT>,
OnEndReachedHelperProps {}
OnEndReachedHelperProps {
renderItem: RenderItem<ItemT>;
teleportItemProps?: TeleportItemProps;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export type RenderItem<ItemT extends DefaultItemT = DefaultItemT> = (
export interface GroupListItemImplProps<ItemT extends DefaultItemT>
extends ListItemProps<ItemT> {
renderItem: RenderItem<ItemT>;
scrollComponentUseMeasureLayout: ScrollComponentUseMeasureLayout;
scrollComponentUseMeasureLayout?: ScrollComponentUseMeasureLayout;
}
5 changes: 3 additions & 2 deletions packages/react/src/lib/group/types/ListItem.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export type TeleportItemProps =
export interface ListItemProps<ItemT extends DefaultItemT> {
item: ItemT;

listKey: string;
// listKey: string;
itemKey: string;

itemMeta: ItemMeta<ItemT>;

Expand All @@ -57,5 +58,5 @@ export interface ListItemProps<ItemT extends DefaultItemT> {

containerKey?: string;

scrollComponentUseMeasureLayout: ScrollComponentUseMeasureLayout;
scrollComponentUseMeasureLayout?: ScrollComponentUseMeasureLayout;
}
6 changes: 3 additions & 3 deletions packages/react/src/lib/group/types/PortalContext.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ScrollComponentUseMeasureLayout } from './ListGroup.types';
export type PortalContextProps<ItemT extends GenericItemT = GenericItemT> = {
id: string;
listGroupDimensions: ListGroupDimensions<ItemT>;
scrollComponentUseMeasureLayout: ScrollComponentUseMeasureLayout;
scrollComponentUseMeasureLayout?: ScrollComponentUseMeasureLayout;
};

export type GroupSpaceContentProps<ItemT extends GenericItemT = GenericItemT> =
Expand All @@ -18,7 +18,7 @@ export type GroupSpaceContentProps<ItemT extends GenericItemT = GenericItemT> =
listKey: string;
ownerId: string;
dimensions: ListGroupDimensions<ItemT>;
scrollComponentUseMeasureLayout: ScrollComponentUseMeasureLayout;
scrollComponentUseMeasureLayout?: ScrollComponentUseMeasureLayout;
};

export type GroupRecycleContentProps<
Expand All @@ -28,5 +28,5 @@ export type GroupRecycleContentProps<
listKey: string;
ownerId: string;
dimensions: ListGroupDimensions<ItemT>;
scrollComponentUseMeasureLayout: ScrollComponentUseMeasureLayout;
scrollComponentUseMeasureLayout?: ScrollComponentUseMeasureLayout;
};

0 comments on commit 2e0364d

Please sign in to comment.