UNPKG

@ea-lab/reactive-json

Version:

A REACT-based lib that transforms JSON (or YAML) into interactive HTML markup.

35 lines (34 loc) 1.04 kB
import { evaluateTemplateValue as P, dataLocationToPath as m } from "../TemplateSystem.js"; const u = ({ currentPath: v, datafield: D, dataLocation: o, defaultValue: h, globalDataContext: f, templateContext: a }) => { const r = { // This is the data that contains the current checked state. formData: void 0, // This is the path that leads to the data. formDataPath: void 0 }; return o && typeof o == "string" ? (r.formData = P({ globalDataContext: f, templateContext: a, valueToEvaluate: o }) ?? h, r.formDataPath = m({ dataLocation: o, currentPath: v, globalDataContext: f, templateContext: a })) : ((a.templateData[D] ?? void 0) === void 0 && (a.templateData = typeof a.templateData == "object" ? a.templateData : {}, a.templateData[D] = h), r.formData = a.templateData[D], r.formDataPath = m({ dataLocation: "~." + D, currentPath: a.templatePath, globalDataContext: f, templateContext: a })), r; }; export { u as propsDataLocationToPathAndValue };