UNPKG

@react-form-builder/core

Version:

React JSON Schema Form Builder to create complex, validated, reusable forms with no deep React knowledge required

46 lines (45 loc) 1.43 kB
import { isRecord as d } from "../../../utils/isRecord.js"; import { closeCurrentModalActionName as p } from "../../modal/closeCurrentModalActionName.js"; import { ActionDefinition as f } from "../ActionDefinition.js"; const m = "beforeShow", t = "beforeHide", v = "modalOnCloseEventHandler", w = "modalState", D = f.functionalAction(async (s, e) => { const { modalKey: o, useFormData: i } = e; if (!o) { console.warn(`Modal ${o} is missing`); return; } const { formData: n } = s.store, a = n.findByKey(o); if (!a) { console.warn(`Component ${o} is not found`); return; } const r = e[m], c = r ? await r(void 0, void 0, e) : void 0; if (c === !1) return; const l = i === !0 ? n.data : d(c) ? c : void 0, u = d(l) ? JSON.parse(JSON.stringify(l)) : void 0; a.userDefinedProps ??= {}, a.userDefinedProps[w] = { open: !0, initialData: u, [t]: e[t] }; }, { modalKey: "string", useFormData: "boolean", [m]: "function", [t]: "function" }), b = f.functionalAction(async (s, e) => { const o = s.store.formViewerPropsStore.context?.modalContext ?? {}, i = o[t], n = i ? await i(s, e) : void 0; n?.[t] && delete n[t]; const a = o[p]; a?.(n); const r = o[v]; r?.(); }, { result: "string" }); export { b as closeModal, t as modalBeforeHideFnName, v as modalOnCloseEventHandler, w as modalStateKey, D as openModal }; //# sourceMappingURL=modalActions.js.map