From 7687803148f655c76f265b7dcece45f7e1d0799e Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Wed, 24 Jan 2024 19:34:05 -0500 Subject: [PATCH] fix(striker-ui): add form dialog open setters to CRUD list form tools --- striker-ui/components/CrudList.tsx | 8 +++++++- striker-ui/types/CrudList.d.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/striker-ui/components/CrudList.tsx b/striker-ui/components/CrudList.tsx index a020521f..08ebb78e 100644 --- a/striker-ui/components/CrudList.tsx +++ b/striker-ui/components/CrudList.tsx @@ -87,12 +87,18 @@ const CrudList = < const formTools = useMemo( () => ({ + add: { + open: (v = true) => addDialogRef?.current?.setOpen(v), + }, confirm: { finish: finishConfirm, loading: setConfirmDialogLoading, - open: setConfirmDialogOpen, + open: (v = true) => setConfirmDialogOpen(v), prepare: setConfirmDialogProps, }, + edit: { + open: (v = true) => editDialogRef?.current?.setOpen(v), + }, }), [ finishConfirm, diff --git a/striker-ui/types/CrudList.d.ts b/striker-ui/types/CrudList.d.ts index 7526bc63..7247dc1e 100644 --- a/striker-ui/types/CrudList.d.ts +++ b/striker-ui/types/CrudList.d.ts @@ -2,9 +2,15 @@ type CrudListFormTools = { confirm: { finish: (header: React.ReactNode, message: Message) => void; loading: (value: boolean) => void; - open: (value: boolean) => void; + open: (value?: boolean) => void; prepare: (value: React.SetStateAction) => void; }; + add: { + open: (value?: boolean) => void; + }; + edit: { + open: (value?: boolean) => void; + }; }; type CrudListItemClickHandler = Exclude<