UNPKG

koval-ui

Version:

React components collection with minimalistic design. Supports theming, layout, and input validation.

36 lines (35 loc) 814 B
"use client"; import { useCallback as e } from "react"; import { last as u } from "../../internal/utils/last.js"; import { useDialogContext as r } from "./DialogContext.js"; import { Actions as n } from "./DialogReducer.js"; const a = (o) => { const { state: t } = r(); return o(t); }, I = (o) => { const { dispatch: t } = r(), p = e( (s) => { t({ type: n.DIALOG_OPEN, id: o, params: s }); }, [o, t] ), c = e(() => { t({ type: n.DIALOG_CLOSE, id: o }); }, [o, t]), i = a((s) => u(s.open)?.id), l = o === i, D = a((s) => s.open.find(({ id: m }) => o === m)?.params); return { openDialog: p, closeDialog: c, isOpen: l, dialogParams: D }; }; export { I as useDialogState }; //# sourceMappingURL=useDialogState.js.map