fix(striker-ui): expose item click handler in CRUD list

main
Tsu-ba-me 11 months ago
parent 7e43104a35
commit 253d4f3623
  1. 7
      striker-ui/components/CrudList.tsx
  2. 9
      striker-ui/types/CrudList.d.ts

@ -32,6 +32,7 @@ const CrudList = <
getEditLoading = (previous?: boolean) => previous, getEditLoading = (previous?: boolean) => previous,
listEmpty, listEmpty,
listProps, listProps,
onItemClick = (base, ...args) => base(...args),
refreshInterval = 5000, refreshInterval = 5000,
renderAddForm, renderAddForm,
renderDeleteItem, renderDeleteItem,
@ -168,11 +169,13 @@ const CrudList = <
setConfirmDialogOpen(true); setConfirmDialogOpen(true);
}} }}
onEdit={() => setEdit((previous) => !previous)} onEdit={() => setEdit((previous) => !previous)}
onItemClick={(value, key) => { onItemClick={(...args) =>
onItemClick((value, key) => {
editDialogRef?.current?.setOpen(true); editDialogRef?.current?.setOpen(true);
getEntry(`/${key}`); getEntry(`/${key}`);
}} }, ...args)
}
renderListItem={renderListItem} renderListItem={renderListItem}
{...listProps} {...listProps}
/> />

@ -7,10 +7,19 @@ type CrudListFormTools = {
}; };
}; };
type CrudListItemClickHandler = Exclude<
ListProps<Overview>['onItemClick'],
undefined
>;
type CrudListOptionalProps<Overview> = { type CrudListOptionalProps<Overview> = {
getAddLoading?: (previous?: boolean) => boolean; getAddLoading?: (previous?: boolean) => boolean;
getEditLoading?: (previous?: boolean) => boolean; getEditLoading?: (previous?: boolean) => boolean;
listProps?: Partial<ListProps<Overview>>; listProps?: Partial<ListProps<Overview>>;
onItemClick?: (
base: CrudListItemClickHandler,
...args: Parameters<CrudListItemClickHandler>
) => ReturnType<CrudListItemClickHandler>;
refreshInterval?: number; refreshInterval?: number;
}; };

Loading…
Cancel
Save