UNPKG

koval-ui

Version:

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

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