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

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

Loading…
Cancel
Save